Browse Source

fix: handle super user on project collaborator list

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6437/head
mertmit 1 year ago
parent
commit
de30cf3c31
  1. 17
      packages/nc-gui/components/project/AccessSettings.vue

17
packages/nc-gui/components/project/AccessSettings.vue

@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { OrgUserRoles, WorkspaceUserRoles } from 'nocodb-sdk'
import { OrderedProjectRoles, ProjectRoles, WorkspaceRolesToProjectRoles } from 'nocodb-sdk'
import type { WorkspaceUserRoles } from 'nocodb-sdk'
import { OrderedProjectRoles, OrgUserRoles, ProjectRoles, WorkspaceRolesToProjectRoles, extractRolesObj } from 'nocodb-sdk'
import InfiniteLoading from 'v3-infinite-loading'
import { isEeUI, storeToRefs, timeAgo } from '#imports'
@ -8,7 +8,9 @@ const basesStore = useBases()
const { getProjectUsers, createProjectUser, updateProjectUser, removeProjectUser } = basesStore
const { activeProjectId } = storeToRefs(basesStore)
const { baseRoles } = useRoles()
const { orgRoles, baseRoles } = useRoles()
const isSuper = computed(() => orgRoles.value?.[OrgUserRoles.SUPER_ADMIN])
interface Collaborators {
id: string
@ -44,8 +46,9 @@ const loadCollaborators = async () => {
...users.map((user: any) => ({
...user,
base_roles: user.roles,
roles:
user.roles ??
roles: extractRolesObj(user.main_roles)?.[OrgUserRoles.SUPER_ADMIN]
? OrgUserRoles.SUPER_ADMIN
: user.roles ??
(user.workspace_roles
? WorkspaceRolesToProjectRoles[user.workspace_roles as WorkspaceUserRoles] ?? ProjectRoles.NO_ACCESS
: ProjectRoles.NO_ACCESS),
@ -135,7 +138,9 @@ onMounted(async () => {
const currentRoleIndex = OrderedProjectRoles.findIndex(
(role) => baseRoles.value && Object.keys(baseRoles.value).includes(role),
)
if (currentRoleIndex !== -1) {
if (isSuper.value) {
accessibleRoles.value = OrderedProjectRoles.slice(1)
} else if (currentRoleIndex !== -1) {
accessibleRoles.value = OrderedProjectRoles.slice(currentRoleIndex + 1)
}
} catch (e: any) {

Loading…
Cancel
Save