Browse Source

fix: use permissions for workspace ops

pull/6378/head
mertmit 1 year ago
parent
commit
04bfbc97cb
  1. 6
      packages/nc-gui/components/dashboard/Sidebar/TopSection.vue
  2. 11
      packages/nc-gui/components/workspace/View.vue
  3. 19
      packages/nc-gui/store/workspace.ts

6
packages/nc-gui/components/dashboard/Sidebar/TopSection.vue

@ -2,9 +2,11 @@
const workspaceStore = useWorkspace() const workspaceStore = useWorkspace()
const projectStore = useProject() const projectStore = useProject()
const { isUIAllowed } = useRoles()
const { appInfo } = useGlobal() const { appInfo } = useGlobal()
const { isWorkspaceLoading, isWorkspaceOwnerOrCreator, isWorkspaceSettingsPageOpened } = storeToRefs(workspaceStore) const { isWorkspaceLoading, isWorkspaceSettingsPageOpened } = storeToRefs(workspaceStore)
const { navigateToWorkspaceSettings } = workspaceStore const { navigateToWorkspaceSettings } = workspaceStore
@ -45,7 +47,7 @@ const navigateToSettings = () => {
<DashboardSidebarTopSectionHeader /> <DashboardSidebarTopSectionHeader />
<NcButton <NcButton
v-if="isWorkspaceOwnerOrCreator" v-if="isUIAllowed('workspaceSettings')"
type="text" type="text"
size="small" size="small"
class="nc-sidebar-top-button" class="nc-sidebar-top-button"

11
packages/nc-gui/components/workspace/View.vue

@ -1,13 +1,14 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useTitle } from '@vueuse/core' import { useTitle } from '@vueuse/core'
import type { WorkspaceType } from 'nocodb-sdk' import type { WorkspaceType } from 'nocodb-sdk'
import { isEeUI } from '#imports'
const router = useRouter() const router = useRouter()
const route = router.currentRoute const route = router.currentRoute
const { isUIAllowed } = useRoles()
const workspaceStore = useWorkspace() const workspaceStore = useWorkspace()
const { isWorkspaceOwnerOrCreator, isWorkspaceOwner, activeWorkspace, workspaces } = storeToRefs(workspaceStore) const { activeWorkspace, workspaces } = storeToRefs(workspaceStore)
const { loadCollaborators } = workspaceStore const { loadCollaborators } = workspaceStore
const tab = computed({ const tab = computed({
@ -61,7 +62,7 @@ onMounted(() => {
</div> </div>
<NcTabs v-model:activeKey="tab"> <NcTabs v-model:activeKey="tab">
<template v-if="isWorkspaceOwnerOrCreator"> <template v-if="isUIAllowed('workspaceSettings')">
<a-tab-pane key="collaborators" class="w-full"> <a-tab-pane key="collaborators" class="w-full">
<template #tab> <template #tab>
<div class="flex flex-row items-center px-2 pb-1 gap-x-1.5"> <div class="flex flex-row items-center px-2 pb-1 gap-x-1.5">
@ -73,7 +74,7 @@ onMounted(() => {
</a-tab-pane> </a-tab-pane>
</template> </template>
<template v-if="isWorkspaceOwner && isEeUI"> <template v-if="isUIAllowed('workspaceBilling')">
<a-tab-pane key="billing" class="w-full"> <a-tab-pane key="billing" class="w-full">
<template #tab> <template #tab>
<div class="flex flex-row items-center px-2 pb-1 gap-x-1.5"> <div class="flex flex-row items-center px-2 pb-1 gap-x-1.5">
@ -84,7 +85,7 @@ onMounted(() => {
<WorkspaceBilling /> <WorkspaceBilling />
</a-tab-pane> </a-tab-pane>
</template> </template>
<template v-if="isWorkspaceOwner && isEeUI"> <template v-if="isUIAllowed('workspaceManage')">
<a-tab-pane key="settings" class="w-full"> <a-tab-pane key="settings" class="w-full">
<template #tab> <template #tab>
<div class="flex flex-row items-center px-2 pb-1 gap-x-1.5" data-testid="nc-workspace-settings-tab-settings"> <div class="flex flex-row items-center px-2 pb-1 gap-x-1.5" data-testid="nc-workspace-settings-tab-settings">

19
packages/nc-gui/store/workspace.ts

@ -64,22 +64,6 @@ export const useWorkspace = defineStore('workspaceStore', () => {
} }
}) })
/** getters */
const isWorkspaceCreator = computed(() => {
// todo: type correction
return orgRoles.value?.[OrgUserRoles.CREATOR]
})
const isWorkspaceOwner = computed(() => {
// todo: type correction
return orgRoles.value?.[OrgUserRoles.CREATOR]
})
const isWorkspaceOwnerOrCreator = computed(() => {
// todo: type correction
return orgRoles.value?.[OrgUserRoles.CREATOR]
})
/** actions */ /** actions */
const loadWorkspaces = async (_ignoreError = false) => {} const loadWorkspaces = async (_ignoreError = false) => {}
@ -239,8 +223,6 @@ export const useWorkspace = defineStore('workspaceStore', () => {
removeCollaborator, removeCollaborator,
updateCollaborator, updateCollaborator,
collaborators, collaborators,
isWorkspaceCreator,
isWorkspaceOwner,
isInvitingCollaborators, isInvitingCollaborators,
isCollaboratorsLoading, isCollaboratorsLoading,
addToFavourite, addToFavourite,
@ -257,7 +239,6 @@ export const useWorkspace = defineStore('workspaceStore', () => {
clearWorkspaces, clearWorkspaces,
upgradeActiveWorkspace, upgradeActiveWorkspace,
navigateToWorkspace, navigateToWorkspace,
isWorkspaceOwnerOrCreator,
setLoadingState, setLoadingState,
navigateToWorkspaceSettings, navigateToWorkspaceSettings,
lastPopulatedWorkspaceId, lastPopulatedWorkspaceId,

Loading…
Cancel
Save