(core) AdminPanel: hide the enterprise toggle in core and grist-ee images

Summary:
In the pure OSS `grist-oss` image, the `ActivationPage` module from
stubs is used, as the `ext` code is completely missing. We can easily
just always return `false` here.

In the case when the `ext` directory exists, this may mean we're in
the standard `grist` image or the `grist-ee` image. The latter is
distinguished by having `GRIST_FORCE_ENABLE_ENTERPRISE` so we check if
that's on, and hide the toggle accordingly if so.

Test Plan:
Use these changes to build the three Docker images
(`grist-oss`, `grist`, and `grist-ee`) and verify that only `grist`
shows the toggle.

Reviewers: jarek

Reviewed By: jarek

Subscribers: jarek

Differential Revision: https://phab.getgrist.com/D4321
This commit is contained in:
Jordi Gutiérrez Hermoso
2024-08-14 16:14:13 -04:00
parent 0a78cdbaab
commit 54502280de
4 changed files with 24 additions and 7 deletions

View File

@@ -26,6 +26,7 @@ import {Computed, Disposable, dom, IDisposable,
IDisposableOwner, MultiHolder, Observable, styled} from 'grainjs';
import {AdminSection, AdminSectionItem, HidableToggle} from 'app/client/ui/AdminPanelCss';
import {getAdminPanelName} from 'app/client/ui/AdminPanelName';
import {showEnterpriseToggle} from 'app/client/ui/ActivationPage';
const t = makeT('AdminPanel');
@@ -158,13 +159,7 @@ Please log in as an administrator.`)),
description: t('Current version of Grist'),
value: cssValueLabel(`Version ${version.version}`),
}),
dom.create(AdminSectionItem, {
id: 'enterprise',
name: t('Enterprise'),
description: t('Enable Grist Enterprise'),
value: dom.create(HidableToggle, this._toggleEnterprise.getEnterpriseToggleObservable()),
expandedContent: this._toggleEnterprise.buildEnterpriseSection(),
}),
this._maybeAddEnterpriseToggle(),
this._buildUpdates(owner),
]),
dom.create(AdminSection, t('Self Checks'), [
@@ -186,6 +181,19 @@ Please log in as an administrator.`)),
];
}
private _maybeAddEnterpriseToggle() {
if (!showEnterpriseToggle()) {
return null;
}
return dom.create(AdminSectionItem, {
id: 'enterprise',
name: t('Enterprise'),
description: t('Enable Grist Enterprise'),
value: dom.create(HidableToggle, this._toggleEnterprise.getEnterpriseToggleObservable()),
expandedContent: this._toggleEnterprise.buildEnterpriseSection(),
});
}
private _buildSandboxingDisplay(owner: IDisposableOwner) {
return dom.domComputed(
use => {