Hide restricted widgets & settings for readonly role

Signed-off-by: Anton Alexeyev <alexeyev.anton@gmail.com>
This commit is contained in:
Anton Alexeyev 2025-05-23 10:25:48 +07:00
parent cc22bbfc0f
commit 7fbc6b88a2
5 changed files with 24 additions and 11 deletions

View File

@ -35,7 +35,8 @@ import {
type Markup,
type Ref,
type Timestamp,
type PersonId
type PersonId,
AccountRole
} from '@hcengineering/core'
import {
ArrOf,
@ -195,7 +196,8 @@ export function createModel (builder: Builder): void {
label: calendar.string.Calendar,
type: WidgetType.Fixed,
icon: calendar.icon.Calendar,
component: calendar.component.CalendarWidget
component: calendar.component.CalendarWidget,
accessLevel: AccountRole.DocGuest
},
calendar.ids.CalendarWidget
)

View File

@ -299,7 +299,8 @@ export function createModel (builder: Builder): void {
label: love.string.Office,
type: WidgetType.Fixed,
icon: love.icon.Love,
component: love.component.LoveWidget
component: love.component.LoveWidget,
accessLevel: AccountRole.DocGuest
},
love.ids.LoveWidget
)

View File

@ -112,13 +112,15 @@
let actions: Action[] = []
$: {
actions = []
actions.push({
icon: view.icon.Setting,
label: setting.string.Settings,
action: async () => {
selectCategory()
}
})
if (hasAccountRole(account, AccountRole.DocGuest)) {
actions.push({
icon: view.icon.Setting,
label: setting.string.Settings,
action: async () => {
selectCategory()
}
})
}
actions.push(...getMenu(items, ['main']))
if (hasAccountRole(account, AccountRole.User)) {
actions.push({

View File

@ -21,10 +21,16 @@
import { sidebarStore, SidebarVariant } from '../../sidebar'
import SidebarExpanded from './SidebarExpanded.svelte'
import SidebarMini from './SidebarMini.svelte'
import { isAppAllowed } from '../../utils'
import { getCurrentAccount } from '@hcengineering/core'
const account = getCurrentAccount()
const client = getClient()
const widgets = client.getModel().findAllSync(workbench.class.Widget, {})
const widgets = client
.getModel()
.findAllSync(workbench.class.Widget, {})
.filter((it) => isAppAllowed(it, account))
const preferencesQuery = createQuery()
let preferences: WidgetPreference[] = []

View File

@ -74,6 +74,8 @@ export interface Widget extends Doc {
closeIfNoTabs?: boolean
onTabClose?: Resource<(tab: WidgetTab) => Promise<void>>
accessLevel?: AccountRole
}
/** @public */