Skip to content

Commit

Permalink
fix(ui): permission checks (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Nov 28, 2024
1 parent e05cae3 commit ebed36b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ui/src/pages/organization/organization-invitations-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '@koupr/ui'
import InvitationAPI, { SortBy, SortOrder } from '@/client/api/invitation'
import OrganizationAPI from '@/client/api/organization'
import { geEditorPermission } from '@/client/api/permission'
import { geOwnerPermission } from '@/client/api/permission'
import { swrConfig } from '@/client/options'
import OrganizationInviteMembers from '@/components/organization/organization-invite-members'
import OrganizationStatus from '@/components/organization/organization-status'
Expand Down Expand Up @@ -113,7 +113,7 @@ const OrganizationInvitationsPage = () => {
<SectionPlaceholder
text="There are no invitations."
content={
geEditorPermission(org.permission) ? (
geOwnerPermission(org.permission) ? (
<Button
leftIcon={<IconPersonAdd />}
onClick={() => {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/pages/organization/organization-members-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from '@koupr/ui'
import cx from 'classnames'
import OrganizationAPI from '@/client/api/organization'
import { geEditorPermission } from '@/client/api/permission'
import { geOwnerPermission } from '@/client/api/permission'
import UserAPI, { SortBy, SortOrder, User } from '@/client/api/user'
import { swrConfig } from '@/client/options'
import OrganizationInviteMembers from '@/components/organization/organization-invite-members'
Expand Down Expand Up @@ -107,7 +107,7 @@ const OrganizationMembersPage = () => {
<SectionPlaceholder
text="This organization has no members."
content={
geEditorPermission(org.permission) ? (
geOwnerPermission(org.permission) ? (
<Button
leftIcon={<IconPersonAdd />}
onClick={() => dispatch(inviteModalDidOpen())}
Expand Down
10 changes: 7 additions & 3 deletions ui/src/pages/workspace/workspace-settings-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
SectionSpinner,
} from '@koupr/ui'
import cx from 'classnames'
import { geEditorPermission } from '@/client/api/permission'
import { geEditorPermission, geOwnerPermission } from '@/client/api/permission'
import StorageAPI from '@/client/api/storage'
import WorkspaceAPI from '@/client/api/workspace'
import { swrConfig } from '@/client/options'
Expand Down Expand Up @@ -50,6 +50,10 @@ const WorkspaceSettingsPage = () => {
() => workspace && geEditorPermission(workspace.permission),
[workspace],
)
const hasOwnerPermission = useMemo(
() => workspace && geOwnerPermission(workspace.permission),
[workspace],
)
const [isNameModalOpen, setIsNameModalOpen] = useState(false)
const [isStorageCapacityModalOpen, setIsStorageCapacityModalOpen] =
useState(false)
Expand Down Expand Up @@ -121,7 +125,7 @@ const WorkspaceSettingsPage = () => {
<EditButton
title="Edit storage capacity"
aria-label="Edit storage capacity"
isDisabled={!hasEditPermission}
isDisabled={!hasOwnerPermission}
onClick={() => setIsStorageCapacityModalOpen(true)}
/>
</>
Expand Down Expand Up @@ -158,7 +162,7 @@ const WorkspaceSettingsPage = () => {
icon={<IconDelete />}
variant="solid"
colorScheme="red"
isDisabled={!hasEditPermission}
isDisabled={!hasOwnerPermission}
title="Delete workspace"
aria-label="Delete workspace"
onClick={() => setIsDeleteModalOpen(true)}
Expand Down

0 comments on commit ebed36b

Please sign in to comment.