diff --git a/packages/nc-gui/components/nc/Badge.vue b/packages/nc-gui/components/nc/Badge.vue index 53d55c040e..c4a392a41d 100644 --- a/packages/nc-gui/components/nc/Badge.vue +++ b/packages/nc-gui/components/nc/Badge.vue @@ -13,6 +13,7 @@ const props = defineProps<{ 'border-green-500 bg-green-100': props.color === 'green', 'border-orange-500 bg-orange-100': props.color === 'orange', 'border-yellow-500 bg-yellow-100': props.color === 'yellow', + 'border-red-500 bg-red-100': props.color === 'red', 'border-gray-300': !props.color, }" > diff --git a/packages/nc-gui/components/project/AccessSettings.vue b/packages/nc-gui/components/project/AccessSettings.vue index d9dd0c43f2..8512b3adbf 100644 --- a/packages/nc-gui/components/project/AccessSettings.vue +++ b/packages/nc-gui/components/project/AccessSettings.vue @@ -1,15 +1,25 @@ + + + + + + + + {{ roleProperties.label }} + + + + + Current Workspace Role + + + {{ roleProperties.descriptionText }} + + + + diff --git a/packages/nc-gui/components/roles/Selector.vue b/packages/nc-gui/components/roles/Selector.vue new file mode 100644 index 0000000000..274a6c01a3 --- /dev/null +++ b/packages/nc-gui/components/roles/Selector.vue @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + diff --git a/packages/nc-gui/utils/iconUtils.ts b/packages/nc-gui/utils/iconUtils.ts index ea282a3501..ec6987cfee 100644 --- a/packages/nc-gui/utils/iconUtils.ts +++ b/packages/nc-gui/utils/iconUtils.ts @@ -76,6 +76,13 @@ import Up from '~icons/material-symbols/keyboard-arrow-up-rounded' import Down from '~icons/material-symbols/keyboard-arrow-down-rounded' import PhTriangleFill from '~icons/ph/triangle-fill' +// Roles +import MaterialSymbolsManageAccountsOutline from '~icons/material-symbols/manage-accounts-outline' +// account +import MdiCommentAccountOutline from '~icons/mdi/comment-account-outline' +import MaterialSymbolsPersonSearchOutline from '~icons/material-symbols/person-search-outline' +import MaterialSymbolsBlock from '~icons/material-symbols/block' + // keep it for reference // todo: remove it after all icons are migrated /* export const iconMapOld = { @@ -400,6 +407,12 @@ export const iconMap = { magic1: MdiMagicStaff, workspace: h('span', { class: 'material-symbols' }, 'dataset'), notification: NcNotification, + role_owner: MaterialSymbolsManageAccountsOutline, + role_creator: MaterialSymbolsManageAccountsOutline, + role_editor: h('span', { class: 'material-symbols' }, 'person'), + role_commenter: MdiCommentAccountOutline, + role_viewer: MaterialSymbolsPersonSearchOutline, + role_no_access: MaterialSymbolsBlock, } export const getMdiIcon = (type: string): any => { diff --git a/packages/nocodb-sdk/src/lib/enums.ts b/packages/nocodb-sdk/src/lib/enums.ts index 2b497708f8..316b2fc9e8 100644 --- a/packages/nocodb-sdk/src/lib/enums.ts +++ b/packages/nocodb-sdk/src/lib/enums.ts @@ -194,6 +194,40 @@ export const RoleColors = { [OrgUserRoles.VIEWER]: 'yellow', }; +export const RoleDescriptions = { + [WorkspaceUserRoles.OWNER]: 'Full access to workspace', + [WorkspaceUserRoles.CREATOR]: 'Can create projects, sync tables, views, setup web-hooks and more', + [WorkspaceUserRoles.EDITOR]: 'Can edit data in workspace projects', + [WorkspaceUserRoles.COMMENTER]: 'Can view and comment data in workspace projects', + [WorkspaceUserRoles.VIEWER]: 'Can view data in workspace projects', + [ProjectRoles.OWNER]: 'Full access to project', + [ProjectRoles.CREATOR]: 'Can create tables, views, setup web-hooks and more', + [ProjectRoles.EDITOR]: 'Can only edit data in project', + [ProjectRoles.COMMENTER]: 'Can only view and comment on data in project', + [ProjectRoles.VIEWER]: 'Can only view data in project', + [ProjectRoles.NO_ACCESS]: 'User cannot view project', + [OrgUserRoles.SUPER_ADMIN]: 'Full access to all', + [OrgUserRoles.CREATOR]: 'Can create projects, sync tables, views, setup web-hooks and more', + [OrgUserRoles.VIEWER]: 'Can only view projects', +}; + +export const RoleIcons = { + [WorkspaceUserRoles.OWNER]: 'role_owner', + [WorkspaceUserRoles.CREATOR]: 'role_creator', + [WorkspaceUserRoles.EDITOR]: 'role_editor', + [WorkspaceUserRoles.COMMENTER]: 'role_commenter', + [WorkspaceUserRoles.VIEWER]: 'role_viewer', + [ProjectRoles.OWNER]: 'role_owner', + [ProjectRoles.CREATOR]: 'role_creator', + [ProjectRoles.EDITOR]: 'role_editor', + [ProjectRoles.COMMENTER]: 'role_commenter', + [ProjectRoles.VIEWER]: 'role_viewer', + [ProjectRoles.NO_ACCESS]: 'role_no_access', + [OrgUserRoles.SUPER_ADMIN]: 'role_owner', + [OrgUserRoles.CREATOR]: 'role_creator', + [OrgUserRoles.VIEWER]: 'role_viewer', +}; + export const WorkspaceRolesToProjectRoles = { [WorkspaceUserRoles.OWNER]: ProjectRoles.OWNER, [WorkspaceUserRoles.CREATOR]: ProjectRoles.CREATOR, diff --git a/packages/nocodb/src/guards/global/global.guard.ts b/packages/nocodb/src/guards/global/global.guard.ts index 0d335daae3..c0dc6e8ce2 100644 --- a/packages/nocodb/src/guards/global/global.guard.ts +++ b/packages/nocodb/src/guards/global/global.guard.ts @@ -51,7 +51,7 @@ export class GlobalGuard extends AuthGuard(['jwt']) { return this.authenticate(req, { ...req.user, isAuthorized: true, - roles: req.user.roles === 'owner' ? 'owner,creator' : req.user.roles, + roles: req.user.roles, }); } } else if (req.headers['xc-shared-base-id']) { diff --git a/packages/nocodb/src/models/User.ts b/packages/nocodb/src/models/User.ts index c4f608972f..2d384ab77e 100644 --- a/packages/nocodb/src/models/User.ts +++ b/packages/nocodb/src/models/User.ts @@ -263,8 +263,7 @@ export default class User implements UserType { const projectRoles = await new Promise((resolve) => { if (args.projectId) { ProjectUser.get(args.projectId, user.id).then(async (projectUser) => { - let roles = projectUser?.roles; - roles = roles === 'owner' ? 'owner,creator' : roles; + const roles = projectUser?.roles; // + (user.roles ? `,${user.roles}` : ''); if (roles) { resolve(extractRolesObj(roles)); diff --git a/packages/nocodb/src/strategies/google.strategy/google.strategy.ts b/packages/nocodb/src/strategies/google.strategy/google.strategy.ts index fcc35c060a..489daeb920 100644 --- a/packages/nocodb/src/strategies/google.strategy/google.strategy.ts +++ b/packages/nocodb/src/strategies/google.strategy/google.strategy.ts @@ -36,8 +36,6 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { ProjectUser.get(req.ncProjectId, user.id) .then(async (projectUser) => { user.roles = projectUser?.roles || user.roles; - user.roles = - user.roles === 'owner' ? 'owner,creator' : user.roles; // + (user.roles ? `,${user.roles}` : ''); done(null, sanitiseUserObj(user));