From 71f025e256a74e3ba9a9008d02a86be6010f0c79 Mon Sep 17 00:00:00 2001 From: Scott Prue Date: Thu, 28 May 2020 01:30:01 -0400 Subject: [PATCH] v0.9.3 * fix(app): add createdBy editing of roles and environments (will be removed when projects are created with correct roles by default) --- package.json | 2 +- .../routes/Actions/components/ActionsPage/ActionsPage.js | 2 +- .../Actions/components/ActionsPage/useActionsPage.js | 4 +++- .../EditEnvironmentDialog/EditEnvironmentDialog.js | 4 +++- .../components/PermissionsTable/PermissionsTable.js | 7 +++++-- .../PermissionsTableRow/PermissionsTableRow.js | 3 ++- .../Permissions/components/RolesTable/RolesTable.js | 9 +++++++-- 7 files changed, 22 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 0c11afde..e784c4fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fireadmin", - "version": "0.9.2", + "version": "0.9.3", "description": "Application for Managing Firebase Applications. Includes support for multiple environments and data migrations.", "scripts": { "clean": "rimraf build", diff --git a/src/routes/Projects/routes/Project/routes/Actions/components/ActionsPage/ActionsPage.js b/src/routes/Projects/routes/Project/routes/Actions/components/ActionsPage/ActionsPage.js index e40f9230..e8e98770 100644 --- a/src/routes/Projects/routes/Project/routes/Actions/components/ActionsPage/ActionsPage.js +++ b/src/routes/Projects/routes/Project/routes/Actions/components/ActionsPage/ActionsPage.js @@ -55,7 +55,7 @@ function ActionsPage({ projectId }) { const templateName = selectedTemplate?.name ? `Template: ${selectedTemplate.name}` : 'Template' - // TODO: Disable run action button if form is not fully filled out + return (
Actions diff --git a/src/routes/Projects/routes/Project/routes/Actions/components/ActionsPage/useActionsPage.js b/src/routes/Projects/routes/Project/routes/Actions/components/ActionsPage/useActionsPage.js index 25fcd51f..37dc60ab 100644 --- a/src/routes/Projects/routes/Project/routes/Actions/components/ActionsPage/useActionsPage.js +++ b/src/routes/Projects/routes/Project/routes/Actions/components/ActionsPage/useActionsPage.js @@ -5,6 +5,7 @@ import { useFirestore, useFirestoreCollectionData } from 'reactfire' +import * as Sentry from '@sentry/browser' import { ACTION_RUNNER_REQUESTS_PATH, PROJECTS_COLLECTION @@ -141,7 +142,8 @@ export default function useActionRunner({ } catch (err) { console.error('Error starting action request: ', err.message) // eslint-disable-line no-console showError('Error starting action request') - triggerAnalyticsEvent('actionRunError', { + Sentry.captureException(err) + triggerAnalyticsEvent('action-run-error', { err, message: err.message, projectId, diff --git a/src/routes/Projects/routes/Project/routes/Environments/components/EditEnvironmentDialog/EditEnvironmentDialog.js b/src/routes/Projects/routes/Project/routes/Environments/components/EditEnvironmentDialog/EditEnvironmentDialog.js index f2de6f60..fabfb0da 100644 --- a/src/routes/Projects/routes/Project/routes/Environments/components/EditEnvironmentDialog/EditEnvironmentDialog.js +++ b/src/routes/Projects/routes/Project/routes/Environments/components/EditEnvironmentDialog/EditEnvironmentDialog.js @@ -35,7 +35,9 @@ function EditEnvironmentDialog({ const projectRef = firestore.doc(`${PROJECTS_COLLECTION}/${projectId}`) const project = useFirestoreDocData(projectRef) const userHasPermission = createPermissionGetter(project, user?.uid) - const hasUpdatePermission = userHasPermission('update.environments') + // TODO: Remove checking of ownership once update role is setup by default on project + const hasUpdatePermission = + user?.uid === project.createdBy || userHasPermission('update.environments') // Form const { diff --git a/src/routes/Projects/routes/Project/routes/Permissions/components/PermissionsTable/PermissionsTable.js b/src/routes/Projects/routes/Project/routes/Permissions/components/PermissionsTable/PermissionsTable.js index cbf08b97..57b37a4a 100644 --- a/src/routes/Projects/routes/Project/routes/Permissions/components/PermissionsTable/PermissionsTable.js +++ b/src/routes/Projects/routes/Project/routes/Permissions/components/PermissionsTable/PermissionsTable.js @@ -13,7 +13,10 @@ import { triggerAnalyticsEvent } from 'utils/analytics' import useNotifications from 'modules/notification/useNotifications' import PermissionsTableRow from '../PermissionsTableRow' import DeleteMemberModal from '../DeleteMemberModal' -import { PROJECTS_COLLECTION } from 'constants/firebasePaths' +import { + PROJECTS_COLLECTION, + DISPLAY_NAMES_PATH +} from 'constants/firebasePaths' import styles from './PermissionsTable.styles' const useStyles = makeStyles(styles) @@ -29,7 +32,7 @@ function PermissionsTable({ projectId }) { changeSelectedMemberId(selectedId) } const database = useDatabase() - const displayNamesRef = database.ref('displayNames') + const displayNamesRef = database.ref(DISPLAY_NAMES_PATH) const displayNames = useDatabaseObjectData(displayNamesRef) const firestore = useFirestore() diff --git a/src/routes/Projects/routes/Project/routes/Permissions/components/PermissionsTableRow/PermissionsTableRow.js b/src/routes/Projects/routes/Project/routes/Permissions/components/PermissionsTableRow/PermissionsTableRow.js index 5c908b3d..0ef2b822 100644 --- a/src/routes/Projects/routes/Project/routes/Permissions/components/PermissionsTableRow/PermissionsTableRow.js +++ b/src/routes/Projects/routes/Project/routes/Permissions/components/PermissionsTableRow/PermissionsTableRow.js @@ -24,6 +24,7 @@ import { makeStyles } from '@material-ui/core/styles' import { triggerAnalyticsEvent, createProjectEvent } from 'utils/analytics' import useNotifications from 'modules/notification/useNotifications' import styles from './PermissionsTableRow.styles' +import { PROJECTS_COLLECTION } from 'constants/firebasePaths' const useStyles = makeStyles(styles) @@ -54,7 +55,7 @@ function PermissionsTableRow({ const { showSuccess } = useNotifications() const user = useUser() - const projectRef = firestore.doc(`projects/${projectId}`) + const projectRef = firestore.doc(`${PROJECTS_COLLECTION}/${projectId}`) const project = useFirestoreDocData(projectRef) const roleOptions = map(project.roles, ({ name }, value) => ({ value, name })) diff --git a/src/routes/Projects/routes/Project/routes/Permissions/components/RolesTable/RolesTable.js b/src/routes/Projects/routes/Project/routes/Permissions/components/RolesTable/RolesTable.js index 99d695d5..7ebc25a7 100644 --- a/src/routes/Projects/routes/Project/routes/Permissions/components/RolesTable/RolesTable.js +++ b/src/routes/Projects/routes/Project/routes/Permissions/components/RolesTable/RolesTable.js @@ -14,6 +14,7 @@ import NewRoleCard from '../NewRoleCard' import NoRolesFound from './NoRolesFound' import styles from './RolesTable.styles' import { createPermissionGetter } from 'utils/data' +import { PROJECTS_COLLECTION } from 'constants/firebasePaths' const useStyles = makeStyles(styles) @@ -24,7 +25,7 @@ function RolesTable({ projectId }) { const { FieldValue } = useFirestore const user = useUser() const { showError, showSuccess } = useNotifications() - const projectRef = firestore.doc(`projects/${projectId}`) + const projectRef = firestore.doc(`${PROJECTS_COLLECTION}/${projectId}`) const project = useFirestoreDocData(projectRef) const openNewRole = () => changeRoleOpen(true) const closeNewRole = () => changeRoleOpen(false) @@ -97,7 +98,11 @@ function RolesTable({ projectId }) { projectId={projectId} currentRoles={project.roles} roleOptions={roleOptions} - updateRolesDisabled={!userHasPermission('update.roles')} + updateRolesDisabled={ + // TODO: Remove checking of ownership once update role is setup by default on project + project.createdBy !== user?.uid && + !userHasPermission('update.roles') + } initialValues={permissions} /> ))