diff --git a/packages/nc-gui/components/cell/User.vue b/packages/nc-gui/components/cell/User.vue index 8a6c1e1bb3..93fc307cec 100644 --- a/packages/nc-gui/components/cell/User.vue +++ b/packages/nc-gui/components/cell/User.vue @@ -32,8 +32,12 @@ const activeCell = inject(ActiveCellInj, ref(false)) const basesStore = useBases() +const baseStore = useBase() + const { basesUser } = storeToRefs(basesStore) +const { idUserMap } = storeToRefs(baseStore) + const baseUsers = computed(() => (meta.value.base_id ? basesUser.value.get(meta.value.base_id) || [] : [])) // use both ActiveCellInj or EditModeInj to determine the active state @@ -303,6 +307,11 @@ const filterOption = (input: string, option: any) => { return searchVal.toLowerCase().includes(input.toLowerCase()) } } + +// check if user is part of the base +const isCollaborator = (userIdOrEmail) => { + return !idUserMap.value?.[userIdOrEmail]?.deleted +} diff --git a/packages/nc-gui/components/general/UserIcon.vue b/packages/nc-gui/components/general/UserIcon.vue index 61d9232e73..8ce6118caa 100644 --- a/packages/nc-gui/components/general/UserIcon.vue +++ b/packages/nc-gui/components/general/UserIcon.vue @@ -6,11 +6,13 @@ const props = withDefaults( size?: 'small' | 'medium' | 'base' | 'large' | 'xlarge' | 'auto' name?: string email?: string + disabled?: boolean }>(), { size: 'medium', name: '', email: '', + disabled: false, }, ) @@ -19,11 +21,19 @@ const { size, email } = toRefs(props) const displayName = computed(() => props.name?.trim() || '') const backgroundColor = computed(() => { + if (props.disabled) { + return '#bbbbbb' + } + // in comments we need to generate user icon from email return displayName.value ? stringToColor(displayName.value) : email.value ? stringToColor(email.value) : '#FFFFFF' }) const usernameInitials = computed(() => { + if (props.disabled) { + return '' + } + const displayNameSplit = displayName.value?.split(' ').filter((name) => name) ?? [] if (displayNameSplit.length > 0) { diff --git a/packages/nc-gui/components/workspace/CollaboratorsList.vue b/packages/nc-gui/components/workspace/CollaboratorsList.vue index a2ed3d6822..02415befe1 100644 --- a/packages/nc-gui/components/workspace/CollaboratorsList.vue +++ b/packages/nc-gui/components/workspace/CollaboratorsList.vue @@ -7,6 +7,8 @@ const props = defineProps<{ const { workspaceRoles } = useRoles() +const { user } = useGlobal() + const workspaceStore = useWorkspace() const { removeCollaborator, updateCollaborator: _updateCollaborator, loadWorkspace } = workspaceStore @@ -35,8 +37,6 @@ const isOnlyOneOwner = computed(() => { return collaborators.value?.filter((collab) => collab.roles === WorkspaceUserRoles.OWNER).length === 1 }) -const { isUIAllowed } = useRoles() - const { t } = useI18n() const inviteDlg = ref(false) @@ -289,25 +289,20 @@ const isDeleteOrUpdateAllowed = (user) => { - - - {{ $t('labels.assignAs') }} - - - - - - Remove user - + + + + + {{ record.id === user.id ? 'Leave workspace' : 'Remove user' }} + + diff --git a/packages/nc-gui/store/base.ts b/packages/nc-gui/store/base.ts index 9f88f00463..e31419705a 100644 --- a/packages/nc-gui/store/base.ts +++ b/packages/nc-gui/store/base.ts @@ -26,6 +26,14 @@ export const useBase = defineStore('baseStore', () => { const tablesStore = useTablesStore() + const idUserMap = computed(() => { + return (basesStore.basesUser.get(baseId.value) || []).reduce((acc, user) => { + acc[user.id] = user + acc[user.email] = user + return acc + }, {} as Record) + }) + // todo: refactor const sharedProject = ref() @@ -297,6 +305,7 @@ export const useBase = defineStore('baseStore', () => { baseUrl, getBaseType, navigateToProjectPage, + idUserMap, } })