Browse Source

fix: no-access role

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6307/head
mertmit 1 year ago
parent
commit
64b812621b
  1. 9
      packages/nc-gui/components/project/AccessSettings.vue
  2. 6
      packages/nocodb/src/models/ProjectUser.ts

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

@ -1,6 +1,6 @@
<script lang="ts" setup>
import { OrderedProjectRoles, RoleColors, RoleLabels } from 'nocodb-sdk'
import type { ProjectRoles, WorkspaceUserType } from 'nocodb-sdk'
import type { WorkspaceUserType } from 'nocodb-sdk'
import { OrderedProjectRoles, ProjectRoles, RoleColors, RoleLabels } from 'nocodb-sdk'
import InfiniteLoading from 'v3-infinite-loading'
import { isEeUI, storeToRefs, stringToColour, timeAgo, useGlobal } from '#imports'
@ -35,7 +35,7 @@ const loadCollaborators = async () => {
...user,
projectRoles: user.roles,
// TODO: Remove this hack and make the values consistent with the backend
roles: user.roles ?? (RoleLabels[user.workspace_roles as string] as string)?.toLowerCase(),
roles: user.roles ?? (RoleLabels[user.workspace_roles as string] as string)?.toLowerCase() ?? ProjectRoles.NO_ACCESS,
})),
]
} catch (e: any) {
@ -74,7 +74,7 @@ onMounted(async () => {
const updateCollaborator = async (collab, roles) => {
try {
if (!roles || roles === 'inherit') {
if (!roles || roles === 'inherit' || (roles === ProjectRoles.NO_ACCESS && !isEeUI)) {
await removeProjectUser(activeProjectId.value!, collab)
collab.projectRoles = null
} else if (collab.projectRoles) {
@ -188,7 +188,6 @@ const accessibleRoles = computed<(typeof ProjectRoles)[keyof typeof ProjectRoles
:virtual="true"
:placeholder="$t('labels.noAccess')"
:disabled="collab.id === user?.id || (collab.roles && !accessibleRoles.includes(collab.roles))"
:allow-clear="!isEeUI"
@change="(value) => updateCollaborator(collab, value)"
>
<template #suffixIcon>

6
packages/nocodb/src/models/ProjectUser.ts

@ -337,6 +337,12 @@ export default class ProjectUser {
this.where(`${MetaTable.PROJECT}.deleted`, false).orWhereNull(
`${MetaTable.PROJECT}.deleted`,
);
})
.where(function () {
this.whereNull(`${MetaTable.PROJECT_USERS}.roles`).orWhereNot(
`${MetaTable.PROJECT_USERS}.roles`,
ProjectRoles.NO_ACCESS,
);
});
// filter starred projects

Loading…
Cancel
Save