|
|
|
@ -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,11 +46,12 @@ const loadCollaborators = async () => {
|
|
|
|
|
...users.map((user: any) => ({ |
|
|
|
|
...user, |
|
|
|
|
base_roles: user.roles, |
|
|
|
|
roles: |
|
|
|
|
user.roles ?? |
|
|
|
|
(user.workspace_roles |
|
|
|
|
? WorkspaceRolesToProjectRoles[user.workspace_roles as WorkspaceUserRoles] ?? ProjectRoles.NO_ACCESS |
|
|
|
|
: ProjectRoles.NO_ACCESS), |
|
|
|
|
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), |
|
|
|
|
})), |
|
|
|
|
] |
|
|
|
|
} catch (e: any) { |
|
|
|
@ -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) { |
|
|
|
|