mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 04:08:19 +00:00
UBERF-5781 (#4809)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
42ded3093d
commit
bdebc4f8a9
@ -59,6 +59,7 @@ export class TSettingsCategory extends TDoc implements SettingsCategory {
|
||||
icon!: Asset
|
||||
component!: AnyComponent
|
||||
secured!: boolean
|
||||
adminOnly?: boolean
|
||||
}
|
||||
|
||||
@Model(setting.class.WorkspaceSettingCategory, core.class.Doc, DOMAIN_MODEL)
|
||||
@ -199,7 +200,8 @@ export function createModel (builder: Builder): void {
|
||||
icon: setting.icon.Setting,
|
||||
component: setting.component.Configure,
|
||||
order: 1001,
|
||||
secured: true
|
||||
secured: true,
|
||||
adminOnly: true
|
||||
},
|
||||
setting.ids.Configure
|
||||
)
|
||||
|
@ -524,3 +524,18 @@ export function getFiltredKeys (
|
||||
export function isCollectionAttr (hierarchy: Hierarchy, key: KeyedAttribute): boolean {
|
||||
return hierarchy.isDerived(key.attr.type._class, core.class.Collection)
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function decodeTokenPayload (token: string): any {
|
||||
const parts = token.split('.')
|
||||
|
||||
const payload = parts[1]
|
||||
|
||||
const decodedPayload = atob(payload)
|
||||
|
||||
const parsedPayload = JSON.parse(decodedPayload)
|
||||
|
||||
return parsedPayload
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
import { Analytics } from '@hcengineering/analytics'
|
||||
import core, { Class, Doc, Ref, Space } from '@hcengineering/core'
|
||||
import { getMetadata, getResource } from '@hcengineering/platform'
|
||||
import { ActionContext, getClient } from '@hcengineering/presentation'
|
||||
import { ActionContext, decodeTokenPayload, getClient } from '@hcengineering/presentation'
|
||||
import {
|
||||
AnyComponent,
|
||||
Component,
|
||||
@ -41,7 +41,6 @@
|
||||
import workbench, { Application, NavigatorModel, SpecialNavModel, ViewConfiguration } from '@hcengineering/workbench'
|
||||
import { buildNavModel, SpaceView } from '@hcengineering/workbench-resources'
|
||||
import guest from '../plugin'
|
||||
import { decodeTokenPayload } from '../utils'
|
||||
|
||||
const excludedApps = getMetadata(workbench.metadata.ExcludedApplications) ?? []
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
export function decodeTokenPayload (token: string): any {
|
||||
const parts = token.split('.')
|
||||
|
||||
const payload = parts[1]
|
||||
|
||||
const decodedPayload = atob(payload)
|
||||
|
||||
const parsedPayload = JSON.parse(decodedPayload)
|
||||
|
||||
return parsedPayload
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
<script lang="ts">
|
||||
import { PersonAccount } from '@hcengineering/contact'
|
||||
import { AccountRole, getCurrentAccount, roleOrder } from '@hcengineering/core'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import presentation, { createQuery, decodeTokenPayload } from '@hcengineering/presentation'
|
||||
import setting, { SettingsCategory } from '@hcengineering/setting'
|
||||
import {
|
||||
Component,
|
||||
@ -27,6 +27,7 @@
|
||||
} from '@hcengineering/ui'
|
||||
import { onDestroy } from 'svelte'
|
||||
import { clearSettingsStore } from '../store'
|
||||
import { getMetadata } from '@hcengineering/platform'
|
||||
|
||||
export let kind: 'navigation' | 'content' | undefined
|
||||
export let categoryName: string
|
||||
@ -38,12 +39,17 @@
|
||||
let categories: SettingsCategory[] = []
|
||||
const account = getCurrentAccount() as PersonAccount
|
||||
|
||||
const admin = decodeTokenPayload(getMetadata(presentation.metadata.Token) ?? '').admin === 'true'
|
||||
|
||||
const settingsQuery = createQuery()
|
||||
settingsQuery.query(
|
||||
setting.class.WorkspaceSettingCategory,
|
||||
{},
|
||||
(res) => {
|
||||
categories = roleOrder[account.role] > roleOrder[AccountRole.User] ? res : res.filter((p) => !p.secured)
|
||||
if (!admin) {
|
||||
categories = categories.filter((p) => !p.adminOnly)
|
||||
}
|
||||
category = findCategory(categoryId)
|
||||
},
|
||||
{ sort: { order: 1 } }
|
||||
|
@ -85,6 +85,7 @@ export interface SettingsCategory extends Doc {
|
||||
secured: boolean
|
||||
|
||||
expandable?: boolean
|
||||
adminOnly?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user