Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions desktop/src/ui/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ export async function configurePlatform (onWorkbenchConnect?: () => Promise<void
setMetadata(presentation.metadata.HulylakeUrl, config.HULYLAKE_URL ?? '')
setMetadata(presentation.metadata.PulseUrl, config.PULSE_URL ?? '')

const disabledFeatures = (config.DISABLED_FEATURES ?? '').split(',').map(it => it.trim()).filter(it => it.length > 0)
setMetadata(presentation.metadata.DisabledFeatures, new Set(disabledFeatures))

setMetadata(textEditor.metadata.Collaborator, config.COLLABORATOR ?? '')

setMetadata(github.metadata.GithubApplication, config.GITHUB_APP ?? '')
Expand Down Expand Up @@ -451,6 +454,7 @@ export async function configurePlatform (onWorkbenchConnect?: () => Promise<void
addLocation(ratingId, async () => await import(/* webpackChunkName: "rating" */ '@hcengineering/rating-resources'))

setMetadata(client.metadata.FilterModel, 'ui')
setMetadata(client.metadata.ExtraFilter, disabledFeatures)
setMetadata(client.metadata.ExtraPlugins, ['preference' as Plugin])

// Use binary response transfer for faster performance and small transfer sizes.
Expand Down
1 change: 1 addition & 0 deletions desktop/src/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface Config {
PASSWORD_STRICTNESS?: 'very_strict' | 'strict' | 'normal' | 'none'
EXCLUDED_APPLICATIONS_FOR_ANONYMOUS?: string
HULYLAKE_URL?: string
DISABLED_FEATURES?: string
}

export interface Branding {
Expand Down
7 changes: 7 additions & 0 deletions dev/prod/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export interface Config {
EXCLUDED_APPLICATIONS_FOR_ANONYMOUS?: string
PULSE_URL?: string
HULYLAKE_URL?: string
DISABLED_FEATURES?: string
}

export interface Branding {
Expand Down Expand Up @@ -477,10 +478,15 @@ export async function configurePlatform () {
setMetadata(presentation.metadata.StatsUrl, config.STATS_URL)
setMetadata(presentation.metadata.LinkPreviewUrl, config.LINK_PREVIEW_URL)
setMetadata(presentation.metadata.MailUrl, config.MAIL_URL)

const disabledFeatures = (config.DISABLED_FEATURES ??'').split(',').map(it => it.trim()).filter(it => it.length > 0)
setMetadata(presentation.metadata.DisabledFeatures, new Set(disabledFeatures))

setMetadata(recorder.metadata.StreamUrl, config.STREAM_URL)
setMetadata(textEditor.metadata.Collaborator, config.COLLABORATOR)
setMetadata(communication.metadata.Enabled, config.COMMUNICATION_API_ENABLED === 'true')


if (config.MODEL_VERSION != null) {
console.log('Minimal Model version requirement', config.MODEL_VERSION)
setMetadata(presentation.metadata.ModelVersion, config.MODEL_VERSION)
Expand Down Expand Up @@ -691,6 +697,7 @@ export async function configurePlatform () {
)

setMetadata(client.metadata.FilterModel, 'ui')
setMetadata(client.metadata.ExtraFilter, disabledFeatures)
setMetadata(client.metadata.ExtraPlugins, ['preference' as Plugin])
setMetadata(login.metadata.TransactorOverride, config.TRANSACTOR_OVERRIDE)

Expand Down
28 changes: 28 additions & 0 deletions docs/disableFeatures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Overview

A configuration guide, for self-hosted users.

## Disable features
Installation could have force disabled one of unused features for all workspaces.

Please set a DISABLED_FEATURES environment variable for front service container, a comma separated list is supported.

- auto-translate - Will disable auto translate
- github - Will disable Github
- mailboxes - Will disable Huly Mail
- export - Will disable export
- integration - Will disable all integrations
- backup - Will disable backup UI
- invites - Will disable invites UI
- documents - Will disable Control Documents
- calendar - Will disable Calendar UI
- inventory - Will disable inventory
- survey - Will disable Surveys
- lead - Will disable leada
- products - Will disable products
- telegram - Will disable telegram
- recruit - Will disable Recruit
- training - Will disable trainings
- testManagement - Will disable test management
- process - Will disable process module
- cards - Will disable cards
1 change: 1 addition & 0 deletions models/billing/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function createModel (builder: Builder): void {
component: billing.component.Settings,
group: 'settings-editor',
role: AccountRole.Owner,
feature: 'billing',
order: 920
})

Expand Down
1 change: 1 addition & 0 deletions models/contact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,7 @@ export function createModel (builder: Builder): void {
component: contact.component.TranslationSettings,
group: 'settings-account',
role: AccountRole.Guest,
feature: 'auto-translate',
order: 1600
})
}
1 change: 1 addition & 0 deletions models/love/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ export function createModel (builder: Builder): void {
component: love.component.Settings,
group: 'settings-account',
role: AccountRole.Guest,
feature: 'love',
order: 1600
},
love.ids.Settings
Expand Down
5 changes: 5 additions & 0 deletions models/setting/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export function createModel (builder: Builder): void {
component: setting.component.Integrations,
group: 'settings-account',
role: AccountRole.User,
feature: 'integrations',
order: 1500
},
setting.ids.Integrations
Expand All @@ -229,6 +230,7 @@ export function createModel (builder: Builder): void {
icon: setting.icon.Mailbox,
component: setting.component.Mailboxes,
group: 'settings-account',
feature: 'mailboxes',
role: AccountRole.User,
order: 1700
},
Expand All @@ -255,6 +257,7 @@ export function createModel (builder: Builder): void {
label: setting.string.Backup,
icon: setting.icon.Setting,
component: setting.component.Backup,
feature: 'backup',
order: 950,
role: AccountRole.Owner
},
Expand Down Expand Up @@ -351,6 +354,7 @@ export function createModel (builder: Builder): void {
icon: setting.icon.InviteSettings,
component: setting.component.InviteSetting,
group: 'settings-editor',
feature: 'invites',
role: AccountRole.Maintainer,
order: 4700
},
Expand All @@ -365,6 +369,7 @@ export function createModel (builder: Builder): void {
icon: exportPlugin.icon.Export,
component: exportPlugin.component.ExportSettings,
group: 'settings-editor',
feature: 'export',
role: AccountRole.User,
order: 4800
},
Expand Down
1 change: 1 addition & 0 deletions models/templates/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export function createModel (builder: Builder): void {
icon: templates.icon.Templates,
component: templates.component.Templates,
group: 'settings-editor',
feature: 'templates',
role: AccountRole.User,
order: 3500
},
Expand Down
1 change: 1 addition & 0 deletions models/training/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ function defineSettings (builder: Builder): void {
icon: training.icon.Training,
component: training.component.Settings,
order: 1150,
feature: 'trainings',
role: AccountRole.Maintainer
},
training.setting.Trainings
Expand Down
1 change: 1 addition & 0 deletions packages/presentation/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export default plugin(presentationId, {
SessionId: '' as Metadata<string>,
StatsUrl: '' as Metadata<string>,
MailUrl: '' as Metadata<string>,
DisabledFeatures: '' as Metadata<Set<string>>,
PreviewUrl: '' as Metadata<string>,
PulseUrl: '' as Metadata<string>,
HulylakeUrl: '' as Metadata<string>,
Expand Down
7 changes: 7 additions & 0 deletions packages/presentation/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ export function getClient (): TxOperations & Client {
return clientProxy
}

export function isDisabled (feature?: string): boolean {
if (feature === undefined) {
return false
}
return getMetadata(plugin.metadata.DisabledFeatures)?.has(feature) ?? false
}

export type OnClientListener = (client: Client, account: Account) => void | Promise<void>
const onClientListeners: OnClientListener[] = []

Expand Down
11 changes: 9 additions & 2 deletions plugins/setting-resources/src/components/Configure.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
-->
<script lang="ts">
import { PluginConfiguration, systemAccountUuid } from '@hcengineering/core'
import { createQuery, getClient, pluginConfigurationStore, hasResource } from '@hcengineering/presentation'
import {
createQuery,
getClient,
pluginConfigurationStore,
hasResource,
isDisabled,
isAdminUser
} from '@hcengineering/presentation'
import ratingPlugin, { getRaiting, type PersonRating } from '@hcengineering/rating'
import { Breadcrumb, Button, Header, Icon, IconInfo, Label, Scroller } from '@hcengineering/ui'
import setting from '../plugin'
Expand Down Expand Up @@ -52,7 +59,7 @@
<Scroller align={'center'} padding={'var(--spacing-3)'} bottomPadding={'var(--spacing-3)'}>
<div class="flex-row-center flex-wrap gap-around-4">
{#each $pluginConfigurationStore.list as config}
{#if config.hidden !== true && config.system !== true}
{#if config.hidden !== true && config.system !== true && !isDisabled(config.pluginId)}
{@const pluginRating = getRaiting(totalVisible, sysRating, [config])}
<div class="cardBox flex-col clear-mins" class:enabled={config.enabled ?? true}>
<div class="flex-row-center">
Expand Down
6 changes: 3 additions & 3 deletions plugins/setting-resources/src/components/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script lang="ts">
import { AccountRole, getCurrentAccount, hasAccountRole } from '@hcengineering/core'
import login, { loginId } from '@hcengineering/login'
import { getClient, createQuery } from '@hcengineering/presentation'
import { getClient, createQuery, isDisabled } from '@hcengineering/presentation'
import settingPlg from '../plugin'
import setting, { SettingsCategory, SettingsEvents } from '@hcengineering/setting'
import {
Expand Down Expand Up @@ -65,7 +65,7 @@
setting.class.SettingsCategory,
{},
(res) => {
categories = res.filter((p) => hasAccountRole(account, p.role))
categories = res.filter((p) => hasAccountRole(account, p.role) && !isDisabled(p.feature))
category = findCategory(categoryId)
},
{ sort: { order: 1 } }
Expand Down Expand Up @@ -193,7 +193,7 @@
label={setting.string.SelectWorkspace}
on:click={selectWorkspace}
/>
{#if hasAccountRole(account, AccountRole.User)}
{#if hasAccountRole(account, AccountRole.User) && !isDisabled('invites')}
<NavItem
icon={setting.icon.InviteWorkspace}
label={setting.string.InviteWorkspace}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-->
<script lang="ts">
import { getCurrentAccount, hasAccountRole } from '@hcengineering/core'
import { createQuery, isAdminUser } from '@hcengineering/presentation'
import { createQuery, isAdminUser, isDisabled } from '@hcengineering/presentation'
import setting, { SettingsCategory } from '@hcengineering/setting'
import {
Component,
Expand Down Expand Up @@ -43,7 +43,7 @@
setting.class.WorkspaceSettingCategory,
{},
(res) => {
categories = res.filter((p) => hasAccountRole(account, p.role))
categories = res.filter((p) => hasAccountRole(account, p.role) && !isDisabled(p.feature ?? ''))
if (!admin) {
categories = categories.filter((p) => !(p.adminOnly ?? false))
}
Expand Down
3 changes: 3 additions & 0 deletions plugins/setting/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export interface SettingsCategory extends Doc {
order?: number
role: AccountRole

// A feature to be used with hides
feature?: string

expandable?: boolean
adminOnly?: boolean
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import core, { AccountRole, getCurrentAccount, hasAccountRole } from '@hcengineering/core'
import rating, { type PersonRating } from '@hcengineering/rating'
import login, { loginId } from '@hcengineering/login'
import { createQuery, getCurrentWorkspaceUrl, hasResource } from '@hcengineering/presentation'
import { createQuery, getCurrentWorkspaceUrl, hasResource, isDisabled } from '@hcengineering/presentation'
import setting, { settingId, SettingsCategory } from '@hcengineering/setting'
import {
Action,
Expand Down Expand Up @@ -126,7 +126,7 @@
})
}
actions.push(...getMenu(items, ['main']))
if (hasAccountRole(account, AccountRole.User)) {
if (hasAccountRole(account, AccountRole.User) && !isDisabled('invites')) {
actions.push({
icon: setting.icon.InviteWorkspace,
label: setting.string.InviteWorkspace,
Expand Down
3 changes: 2 additions & 1 deletion pods/front/src/__start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ startFront(metricsContext, {
EXPORT_URL: process.env.EXPORT_URL,
PULSE_URL: process.env.PULSE_URL,
COMMUNICATION_API_ENABLED: process.env.COMMUNICATION_API_ENABLED,
EXCLUDED_APPLICATIONS_FOR_ANONYMOUS: process.env.EXCLUDED_APPLICATIONS_FOR_ANONYMOUS
EXCLUDED_APPLICATIONS_FOR_ANONYMOUS: process.env.EXCLUDED_APPLICATIONS_FOR_ANONYMOUS,
DISABLED_FEATURES: process.env.DISABLED_FEATURES ?? ''
})