Browse Source

feat(gui): show app store only for super admin user

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3796/head
Pranav C 2 years ago
parent
commit
ace5f0a06d
  1. 56
      packages/nc-gui/components/dashboard/settings/Modal.vue
  2. 9
      packages/nc-gui/composables/useUIPermission/index.ts
  3. 54
      packages/nc-gui/composables/useUIPermission/rolePermissions.ts

56
packages/nc-gui/components/dashboard/settings/Modal.vue

@ -56,41 +56,43 @@ const tabsInfo: TabGroup = {
subTabs: {
...(isUIAllowed('userMgmtTab')
? {
usersManagement: {
// Users Management
title: t('title.userMgmt'),
body: UserManagement,
},
}
usersManagement: {
// Users Management
title: t('title.userMgmt'),
body: UserManagement,
},
}
: {}),
...(isUIAllowed('apiTokenTab')
? {
apiTokenManagement: {
// API Tokens Management
title: t('title.apiTokenMgmt'),
body: ApiTokenManagement,
},
}
apiTokenManagement: {
// API Tokens Management
title: t('title.apiTokenMgmt'),
body: ApiTokenManagement,
},
}
: {}),
},
onClick: () => {
$e('c:settings:team-auth')
},
},
appStore: {
// App Store
title: t('title.appStore'),
icon: StoreFrontOutline,
subTabs: {
new: {
title: 'Apps',
body: AppStore,
},
},
onClick: () => {
$e('c:settings:appstore')
},
},
}, ...(isUIAllowed('appStore')
? {
appStore: {
// App Store
title: t('title.appStore'),
icon: StoreFrontOutline,
subTabs: {
new: {
title: 'Apps',
body: AppStore,
},
},
onClick: () => {
$e('c:settings:appstore')
},
}
: {}),
projMetaData: {
// Project Metadata
title: t('title.projMeta'),

9
packages/nc-gui/composables/useUIPermission/index.ts

@ -11,6 +11,15 @@ const hasPermission = (role: Role | ProjectRole, hasRole: boolean, permission: P
if (isString(rolePermission) && rolePermission === '*') return true
// todo: type correction
if('include' in rolePermission[permission as keyof typeof rolePermission]){
return rolePermission[permission as keyof typeof rolePermission].include[permission]
}
if('exclude' in rolePermission[permission as keyof typeof rolePermission]){
return !rolePermission[permission as keyof typeof rolePermission].exclude[permission]
}
return rolePermission[permission as keyof typeof rolePermission]
}

54
packages/nc-gui/composables/useUIPermission/rolePermissions.ts

@ -8,43 +8,55 @@ const rolePermissions = {
[Role.Admin]: {},
[Role.Guest]: {},
[Role.User]: {
projectCreate: true,
projectActions: true,
projectSettings: true,
include: {
projectCreate: true,
projectActions: true,
projectSettings: true,
}
},
// Project role permissions
[ProjectRole.Creator]: '*',
[ProjectRole.Owner]: '*',
[ProjectRole.Creator]: {
exclude: ["appStore"]
},
[ProjectRole.Owner]: {
exclude: ["appStore"]
},
[ProjectRole.Editor]: {
smartSheet: true,
xcDatatableEditable: true,
column: true,
tableAttachment: true,
tableRowUpdate: true,
dataInsert: true,
rowComments: true,
gridViewOptions: true,
sortSync: true,
fieldsSync: true,
gridColUpdate: true,
filterSync: true,
csvImport: true,
apiDocs: true,
projectSettings: true,
newUser: false,
include: {
smartSheet: true,
xcDatatableEditable: true,
column: true,
tableAttachment: true,
tableRowUpdate: true,
dataInsert: true,
rowComments: true,
gridViewOptions: true,
sortSync: true,
fieldsSync: true,
gridColUpdate: true,
filterSync: true,
csvImport: true,
apiDocs: true,
projectSettings: true,
newUser: false,
}
},
[ProjectRole.Commenter]: {
include: {
smartSheet: true,
column: true,
rowComments: true,
projectSettings: true,
},
},
[ProjectRole.Viewer]: {
include: {
smartSheet: true,
column: true,
projectSettings: true,
},
},
} as const
type RolePermissions = Omit<typeof rolePermissions, 'creator' | 'owner' | 'guest' | 'admin'>

Loading…
Cancel
Save