diff --git a/packages/nc-gui/components/dashboard/settings/AppStore.vue b/packages/nc-gui/components/dashboard/settings/AppStore.vue index ccba837656..ec6278c5bc 100644 --- a/packages/nc-gui/components/dashboard/settings/AppStore.vue +++ b/packages/nc-gui/components/dashboard/settings/AppStore.vue @@ -115,7 +115,7 @@ onMounted(async () => { :body-style="{ width: '100%' }" >
- +
Edit diff --git a/packages/nc-gui/composables/useUIPermission/index.ts b/packages/nc-gui/composables/useUIPermission/index.ts index 96a82f19b1..cc2681e7aa 100644 --- a/packages/nc-gui/composables/useUIPermission/index.ts +++ b/packages/nc-gui/composables/useUIPermission/index.ts @@ -11,12 +11,12 @@ const hasPermission = (role: Role | ProjectRole, hasRole: boolean, permission: P if (isString(rolePermission) && rolePermission === '*') return true - // todo: type correction if ('include' in rolePermission && rolePermission.include) { - return rolePermission.include[permission] + return !!rolePermission.include[permission as keyof typeof rolePermission.include] } + if ('exclude' in rolePermission && rolePermission.exclude) { - return !rolePermission.exclude[permission] + return !rolePermission.exclude[permission as keyof typeof rolePermission.exclude] } return rolePermission[permission as keyof typeof rolePermission] diff --git a/packages/nc-gui/composables/useUIPermission/rolePermissions.ts b/packages/nc-gui/composables/useUIPermission/rolePermissions.ts index 63df6a1de0..7178a1ff2c 100644 --- a/packages/nc-gui/composables/useUIPermission/rolePermissions.ts +++ b/packages/nc-gui/composables/useUIPermission/rolePermissions.ts @@ -1,7 +1,16 @@ import { ProjectRole, Role } from '~/lib' -const rolePermissions: Record>>> = { +const rolePermissions = { // general role permissions + + /** + * Each permission value means the following + * `*` - which is wildcard, means all permissions are allowed + * `include` - which is an object, means only the permissions listed in the object are allowed + * `exclude` - which is an object, means all permissions are allowed except the ones listed in the object + * `undefined` or `{}` - which is the default value, means no permissions are allowed + * */ + /** todo: enable wildcard permission * limited permission due to unexpected behaviour in shared base if opened in same window */ [Role.Super]: '*', @@ -63,11 +72,11 @@ const rolePermissions: Record +type RolePermissions = Omit -type GetKeys = T extends Record ? keyof T : never +type GetKeys = T extends Record> ? Key : never -export type Permission = RolePermissions[K] extends Record +export type Permission = RolePermissions[K] extends Record ? GetKeys : never