Fix guest settings (#5597)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2024-05-14 23:06:57 +07:00
committed by GitHub
parent 9c22b1732f
commit 7eb795f9b8
18 changed files with 68 additions and 95 deletions
@@ -15,7 +15,7 @@
<script lang="ts">
import { createEventDispatcher, onDestroy } from 'svelte'
import contact, { Employee, PersonAccount, combineName, getFirstName, getLastName } from '@hcengineering/contact'
import { ChannelsEditor, EditableAvatar, employeeByIdStore } from '@hcengineering/contact-resources'
import { ChannelsEditor, EditableAvatar, employeeByIdStore, personByIdStore } from '@hcengineering/contact-resources'
import { Ref, getCurrentAccount } from '@hcengineering/core'
import login from '@hcengineering/login'
import { getResource } from '@hcengineering/platform'
@@ -32,12 +32,12 @@
let avatarEditor: EditableAvatar
const account = getCurrentAccount() as PersonAccount
const employee = account !== undefined ? $employeeByIdStore.get(account.person as Ref<Employee>) : undefined
const employee = account !== undefined ? $personByIdStore.get(account.person) : undefined
let firstName = employee ? getFirstName(employee.name) : ''
let lastName = employee ? getLastName(employee.name) : ''
onDestroy(
employeeByIdStore.subscribe((p) => {
personByIdStore.subscribe((p) => {
const emp = p.get(account.person as Ref<Employee>)
if (emp !== undefined) {
firstName = getFirstName(emp.name)
@@ -57,7 +57,7 @@
setting.class.SettingsCategory,
{},
(res) => {
categories = hasAccountRole(account, AccountRole.Maintainer) ? res : res.filter((p) => !p.secured)
categories = res.filter((p) => hasAccountRole(account, p.role))
category = findCategory(categoryId)
},
{ sort: { order: 1 } }
@@ -167,11 +167,13 @@
label={setting.string.SelectWorkspace}
on:click={selectWorkspace}
/>
<NavItem
icon={setting.icon.InviteWorkspace}
label={setting.string.InviteWorkspace}
on:click={inviteWorkspace}
/>
{#if hasAccountRole(account, AccountRole.User)}
<NavItem
icon={setting.icon.InviteWorkspace}
label={setting.string.InviteWorkspace}
on:click={inviteWorkspace}
/>
{/if}
<NavItem icon={setting.icon.Signout} label={setting.string.Signout} on:click={signOut} />
</NavFooter>
</div>
@@ -45,7 +45,7 @@
setting.class.WorkspaceSettingCategory,
{},
(res) => {
categories = hasAccountRole(account, AccountRole.Maintainer) ? res : res.filter((p) => !p.secured)
categories = res.filter((p) => hasAccountRole(account, p.role))
if (!admin) {
categories = categories.filter((p) => !(p.adminOnly ?? false))
}