Browse Source

chore(nc-gui): add generic to narrow roles type

pull/3703/head
braks 2 years ago
parent
commit
be0b641f36
  1. 4
      packages/nc-gui/composables/useProject.ts
  2. 2
      packages/nc-gui/composables/useUIPermission/index.ts
  3. 2
      packages/nc-gui/lib/types.ts

4
packages/nc-gui/composables/useProject.ts

@ -16,7 +16,7 @@ import {
useTheme,
watch,
} from '#imports'
import type { ProjectMetaInfo, Roles } from '~/lib'
import type { ProjectMetaInfo, ProjectRole, Roles } from '~/lib'
import type { ThemeConfig } from '@/composables/useTheme'
const [setup, use] = useInjectionState((_projectId?: MaybeRef<string>) => {
@ -36,7 +36,7 @@ const [setup, use] = useInjectionState((_projectId?: MaybeRef<string>) => {
const tables = ref<TableType[]>([])
const projectRoles = useState<Roles>(USER_PROJECT_ROLES, () => ({}))
const projectRoles = useState<Roles<ProjectRole>>(USER_PROJECT_ROLES, () => ({}))
const projectMetaInfo = ref<ProjectMetaInfo | undefined>()

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

@ -7,7 +7,7 @@ import type { ProjectRole, Role, Roles } from '~/lib'
export function useUIPermission() {
const { user, previewAs } = useGlobal()
const projectRoles = useState<Roles>(USER_PROJECT_ROLES, () => ({}))
const projectRoles = useState<Roles<ProjectRole>>(USER_PROJECT_ROLES, () => ({}))
const baseRoles = computed<Roles>(() => {
let userRoles = user.value?.roles

2
packages/nc-gui/lib/types.ts

@ -31,7 +31,7 @@ export interface Field {
system?: boolean
}
export type Roles = Record<Role | ProjectRole | string, boolean>
export type Roles<T extends Role | ProjectRole = Role | ProjectRole> = Record<T | string, boolean>
export type Filter = FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string; readOnly?: boolean }

Loading…
Cancel
Save