From 17981940fd659a49489dcd8245f0867e4d988a63 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 20 Nov 2025 01:05:35 +0700 Subject: [PATCH 1/3] Feat: Allow to disable any plugin and few extra stuff Signed-off-by: Andrey Sobolev --- dev/prod/src/platform.ts | 7 +++++ docs/disableFeatures.md | 28 +++++++++++++++++++ models/billing/src/index.ts | 1 + models/contact/src/index.ts | 1 + models/love/src/index.ts | 1 + models/setting/src/index.ts | 5 ++++ models/templates/src/index.ts | 1 + models/training/src/index.ts | 1 + packages/presentation/src/plugin.ts | 1 + packages/presentation/src/utils.ts | 7 +++++ .../src/components/Configure.svelte | 11 ++++++-- .../src/components/Settings.svelte | 10 +++++-- .../src/components/WorkspaceSettings.svelte | 4 +-- plugins/setting/src/index.ts | 3 ++ .../src/components/AccountPopup.svelte | 4 +-- pods/front/src/__start.ts | 3 +- 16 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 docs/disableFeatures.md diff --git a/dev/prod/src/platform.ts b/dev/prod/src/platform.ts index 06e39598a76..2ce2aab0638 100644 --- a/dev/prod/src/platform.ts +++ b/dev/prod/src/platform.ts @@ -205,6 +205,7 @@ export interface Config { EXCLUDED_APPLICATIONS_FOR_ANONYMOUS?: string PULSE_URL?: string HULYLAKE_URL?: string + DISABLED_FEATURES?: string } export interface Branding { @@ -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) @@ -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) diff --git a/docs/disableFeatures.md b/docs/disableFeatures.md new file mode 100644 index 00000000000..be16cd915a6 --- /dev/null +++ b/docs/disableFeatures.md @@ -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 diff --git a/models/billing/src/index.ts b/models/billing/src/index.ts index b94a3e65d63..54d65f6c675 100644 --- a/models/billing/src/index.ts +++ b/models/billing/src/index.ts @@ -48,6 +48,7 @@ export function createModel (builder: Builder): void { component: billing.component.Settings, group: 'settings-editor', role: AccountRole.Owner, + feature: 'billing', order: 920 }) diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 1fd543efe22..cc639f0501f 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -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 }) } diff --git a/models/love/src/index.ts b/models/love/src/index.ts index cb7139738f9..97abdabe059 100644 --- a/models/love/src/index.ts +++ b/models/love/src/index.ts @@ -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 diff --git a/models/setting/src/index.ts b/models/setting/src/index.ts index 5fd1b7675aa..4a9e817d12a 100644 --- a/models/setting/src/index.ts +++ b/models/setting/src/index.ts @@ -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 @@ -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 }, @@ -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 }, @@ -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 }, @@ -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 }, diff --git a/models/templates/src/index.ts b/models/templates/src/index.ts index 36ade62388a..0073a90c50c 100644 --- a/models/templates/src/index.ts +++ b/models/templates/src/index.ts @@ -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 }, diff --git a/models/training/src/index.ts b/models/training/src/index.ts index edaf0c0cbdc..b91f8686cd8 100644 --- a/models/training/src/index.ts +++ b/models/training/src/index.ts @@ -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 diff --git a/packages/presentation/src/plugin.ts b/packages/presentation/src/plugin.ts index 67e40485076..e750e99d756 100644 --- a/packages/presentation/src/plugin.ts +++ b/packages/presentation/src/plugin.ts @@ -183,6 +183,7 @@ export default plugin(presentationId, { SessionId: '' as Metadata, StatsUrl: '' as Metadata, MailUrl: '' as Metadata, + DisabledFeatures: '' as Metadata>, PreviewUrl: '' as Metadata, PulseUrl: '' as Metadata, HulylakeUrl: '' as Metadata, diff --git a/packages/presentation/src/utils.ts b/packages/presentation/src/utils.ts index 2e2a9ae58d5..43b320c19e9 100644 --- a/packages/presentation/src/utils.ts +++ b/packages/presentation/src/utils.ts @@ -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 const onClientListeners: OnClientListener[] = [] diff --git a/plugins/setting-resources/src/components/Configure.svelte b/plugins/setting-resources/src/components/Configure.svelte index 2640d3865ed..8e03c0e6bf6 100644 --- a/plugins/setting-resources/src/components/Configure.svelte +++ b/plugins/setting-resources/src/components/Configure.svelte @@ -14,7 +14,14 @@ -->