Skip to content

Commit

Permalink
v0.9.3
Browse files Browse the repository at this point in the history
* fix(app): add createdBy editing of roles and environments (will be removed when projects are created with correct roles by default)
  • Loading branch information
prescottprue committed May 28, 2020
1 parent f24623c commit 71f025e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className={classes.container}>
<Typography className={classes.pageHeader}>Actions</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useFirestore,
useFirestoreCollectionData
} from 'reactfire'
import * as Sentry from '@sentry/browser'
import {
ACTION_RUNNER_REQUESTS_PATH,
PROJECTS_COLLECTION
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 }))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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}
/>
))
Expand Down

0 comments on commit 71f025e

Please sign in to comment.