Browse Source

Merge pull request #6437 from nocodb/fix/6434-super

fix: handle super user on project collaborator list
pull/6597/head
Raju Udava 1 year ago committed by GitHub
parent
commit
d22f00d218
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      packages/nc-gui/components/project/AccessSettings.vue

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

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

Loading…
Cancel
Save