diff --git a/packages/nc-gui/components/smartsheet/sidebar/toolbar/Developer.vue b/packages/nc-gui/components/smartsheet/sidebar/toolbar/Developer.vue
index d4826b318a..c7154646f7 100644
--- a/packages/nc-gui/components/smartsheet/sidebar/toolbar/Developer.vue
+++ b/packages/nc-gui/components/smartsheet/sidebar/toolbar/Developer.vue
@@ -1,7 +1,7 @@
diff --git a/packages/nc-gui/store/projectsShortcuts.ts b/packages/nc-gui/store/projectsShortcuts.ts
index 4112270446..95ffce0801 100644
--- a/packages/nc-gui/store/projectsShortcuts.ts
+++ b/packages/nc-gui/store/projectsShortcuts.ts
@@ -3,7 +3,7 @@ import { isDrawerOrModalExist, useEventListener } from '#imports'
export const useProjectsShortcuts = defineStore('projectsShortcutsStore', () => {
const { $e } = useNuxtApp()
- const { isUIAllowed } = useUIPermission()
+ const { isUIAllowed } = useRoles()
const isMounted = ref(false)
@@ -38,7 +38,7 @@ export const useProjectsShortcuts = defineStore('projectsShortcutsStore', () =>
}
// 'ALT + ,'
case 188: {
- if (isUIAllowed('settings') && !isDrawerOrModalExist()) {
+ if (isUIAllowed('settingsPage') && !isDrawerOrModalExist()) {
$e('c:shortcut', { key: 'ALT + ,' })
const projectsStore = useProjects()
diff --git a/packages/nc-gui/store/share.ts b/packages/nc-gui/store/share.ts
index b29bf2b967..fd0c7211a8 100644
--- a/packages/nc-gui/store/share.ts
+++ b/packages/nc-gui/store/share.ts
@@ -1,4 +1,5 @@
import { acceptHMRUpdate, defineStore } from 'pinia'
+import { ProjectRoles } from 'nocodb-sdk'
import type { Users } from '#imports'
export const useShare = defineStore('share', () => {
@@ -28,7 +29,7 @@ export const useShare = defineStore('share', () => {
const showShareModal = ref(false)
- const invitationUsersData = ref({ emails: undefined, role: ProjectRole.Viewer, invitationToken: undefined })
+ const invitationUsersData = ref({ emails: undefined, role: ProjectRoles.VIEWER, invitationToken: undefined })
watch(
[isProjectPublic],
@@ -41,7 +42,7 @@ export const useShare = defineStore('share', () => {
const resetData = () => {
formStatus.value = 'project-collaborate'
invitationValid.value = false
- invitationUsersData.value = { emails: undefined, role: ProjectRole.Viewer, invitationToken: undefined }
+ invitationUsersData.value = { emails: undefined, role: ProjectRoles.VIEWER, invitationToken: undefined }
isInvitationLinkCopied.value = false
}
diff --git a/packages/nc-gui/store/workspace.ts b/packages/nc-gui/store/workspace.ts
index cd2a08c889..97a687d68f 100644
--- a/packages/nc-gui/store/workspace.ts
+++ b/packages/nc-gui/store/workspace.ts
@@ -1,3 +1,4 @@
+import { OrgUserRoles } from 'nocodb-sdk'
import type { ProjectType } from 'nocodb-sdk'
import { acceptHMRUpdate, defineStore } from 'pinia'
import { message } from 'ant-design-vue'
@@ -66,17 +67,17 @@ export const useWorkspace = defineStore('workspaceStore', () => {
/** getters */
const isWorkspaceCreator = computed(() => {
// todo: type correction
- return orgRoles.value?.[Role.OrgLevelCreator]
+ return orgRoles.value?.[OrgUserRoles.CREATOR]
})
const isWorkspaceOwner = computed(() => {
// todo: type correction
- return orgRoles.value?.[Role.OrgLevelCreator]
+ return orgRoles.value?.[OrgUserRoles.CREATOR]
})
const isWorkspaceOwnerOrCreator = computed(() => {
// todo: type correction
- return orgRoles.value?.[Role.OrgLevelCreator]
+ return orgRoles.value?.[OrgUserRoles.CREATOR]
})
/** actions */
diff --git a/packages/nc-gui/utils/index.ts b/packages/nc-gui/utils/index.ts
index 114faad3db..5dea127495 100644
--- a/packages/nc-gui/utils/index.ts
+++ b/packages/nc-gui/utils/index.ts
@@ -16,7 +16,6 @@ export * from './validation'
export * from './viewUtils'
export * from './currencyUtils'
export * from './dataUtils'
-export * from './userUtils'
export * from './stringUtils'
export * from './memStorage'
export * from './browserUtils'
diff --git a/packages/nc-gui/utils/userUtils.ts b/packages/nc-gui/utils/userUtils.ts
deleted file mode 100644
index aa0aea9e99..0000000000
--- a/packages/nc-gui/utils/userUtils.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { OrgUserRoles } from 'nocodb-sdk'
-import { ProjectRole } from '../lib/enums'
-
-export const projectRoleTagColors = {
- [ProjectRole.Owner]: '#cfdffe',
- [ProjectRole.Creator]: '#d0f1fd',
- [ProjectRole.Editor]: '#c2f5e8',
- [ProjectRole.Commenter]: '#ffdaf6',
- [ProjectRole.Viewer]: '#ffdce5',
- [OrgUserRoles.SUPER_ADMIN]: '#f5d7cb',
-}
-
-export const projectRoles = [ProjectRole.Creator, ProjectRole.Editor, ProjectRole.Commenter, ProjectRole.Viewer]
-
-export const docsProjectRoles = [ProjectRole.Editor, ProjectRole.Viewer]
diff --git a/packages/nocodb-sdk/src/lib/globals.ts b/packages/nocodb-sdk/src/lib/globals.ts
index 6b8348d31d..bf9066a528 100644
--- a/packages/nocodb-sdk/src/lib/globals.ts
+++ b/packages/nocodb-sdk/src/lib/globals.ts
@@ -1,3 +1,5 @@
+import { OrgUserRoles, ProjectRoles, WorkspaceUserRoles } from "./enums";
+
export enum ViewTypes {
FORM = 1,
GALLERY = 2,
@@ -120,3 +122,11 @@ export enum TiptapMarksTypes {
code = 'code',
underline = 'underline',
}
+
+type Roles = OrgUserRoles | ProjectRoles | WorkspaceUserRoles;
+
+type RolesObj = Partial>;
+
+type RolesType = RolesObj | string[] | string;
+
+export { Roles, RolesObj, RolesType };
diff --git a/packages/nocodb-sdk/src/lib/helperFunctions.ts b/packages/nocodb-sdk/src/lib/helperFunctions.ts
index ffb1a80e6e..3d05053702 100644
--- a/packages/nocodb-sdk/src/lib/helperFunctions.ts
+++ b/packages/nocodb-sdk/src/lib/helperFunctions.ts
@@ -1,5 +1,5 @@
import UITypes from './UITypes';
-import { OrgUserRoles, ProjectRoles, WorkspaceUserRoles } from './enums';
+import { RolesObj, RolesType } from './globals';
// import {RelationTypes} from "./globals";
@@ -22,12 +22,7 @@ const isSystemColumn = (col): boolean =>
(col.pk && col.meta && col.meta.ag) ||
col.system);
-type Roles = Record<
- OrgUserRoles | ProjectRoles | WorkspaceUserRoles | string,
- boolean
->;
-
-const extractRolesObj = (roles: Roles | string[] | string): Roles => {
+const extractRolesObj = (roles: RolesType): RolesObj => {
if (!roles) return null;
if (typeof roles === 'object' && !Array.isArray(roles)) return roles;
@@ -44,7 +39,8 @@ const extractRolesObj = (roles: Roles | string[] | string): Roles => {
}, {});
};
-const stringifyRolesObj = (roles: Roles): string => {
+const stringifyRolesObj = (roles?: RolesObj | null): string => {
+ if (!roles) return '';
const rolesArr = Object.keys(roles).filter((r) => roles[r]);
return rolesArr.join(',');
};