Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jordigh committed Jul 8, 2024
1 parent a999b42 commit 2afddcd
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/client/ui/AdminPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ 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 features'),
value: dom.create(HidableToggle, this._supportGrist.getEnterpriseOptInObservable()),
expandedContent: this._supportGrist.buildEnterpriseSection(),
}),
this._buildUpdates(owner),
]),
dom.create(AdminSection, t('Self Checks'), [
Expand Down
66 changes: 65 additions & 1 deletion app/client/ui/SupportGristPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import {cssLink} from 'app/client/ui2018/links';
import {loadingSpinner} from 'app/client/ui2018/loaders';
import {commonUrls} from 'app/common/gristUrls';
import {TelemetryPrefsWithSources} from 'app/common/InstallAPI';
import {Computed, Disposable, dom, makeTestId, styled} from 'grainjs';
import {Computed, Disposable, Observable, dom, makeTestId, styled} from 'grainjs';

Check warning on line 11 in app/client/ui/SupportGristPage.ts

View workflow job for this annotation

GitHub Actions / build_and_test (3.9, 18.x, :lint:python:client:common:smoke:stubs:)

Member 'dom' of the import declaration should be sorted alphabetically

Check warning on line 11 in app/client/ui/SupportGristPage.ts

View workflow job for this annotation

GitHub Actions / build_and_test (:lint:python:client:common:smoke:, 18.x, 3.10)

Member 'dom' of the import declaration should be sorted alphabetically

Check warning on line 11 in app/client/ui/SupportGristPage.ts

View workflow job for this annotation

GitHub Actions / build_and_test (:lint:python:client:common:smoke:, 18.x, 3.11)

Member 'dom' of the import declaration should be sorted alphabetically

const testId = makeTestId('test-support-grist-page-');

const t = makeT('SupportGristPage');

export class SupportGristPage extends Disposable {
private _isEnterprise: Observable<boolean>;
private readonly _model: TelemetryModel = new TelemetryModelImpl(this._appModel);
private readonly _optInToTelemetry = Computed.create(this, this._model.prefs,
(_use, prefs) => {
Expand All @@ -29,6 +30,7 @@ export class SupportGristPage extends Disposable {

constructor(private _appModel: AppModel) {
super();
this._isEnterprise = Observable.create(this, false);
this._model.fetchTelemetryPrefs().catch(reportError);
}

Expand Down Expand Up @@ -109,6 +111,61 @@ export class SupportGristPage extends Disposable {
}
}

public getEnterpriseOptInObservable() {
return Computed.create(this, (use) => {
return use(this._isEnterprise);
})
.onWrite(async (optIn) => {
this._isEnterprise.set(optIn);
})

Check warning on line 120 in app/client/ui/SupportGristPage.ts

View workflow job for this annotation

GitHub Actions / build_and_test (3.9, 18.x, :lint:python:client:common:smoke:stubs:)

Missing semicolon

Check warning on line 120 in app/client/ui/SupportGristPage.ts

View workflow job for this annotation

GitHub Actions / build_and_test (:lint:python:client:common:smoke:, 18.x, 3.10)

Missing semicolon

Check warning on line 120 in app/client/ui/SupportGristPage.ts

View workflow job for this annotation

GitHub Actions / build_and_test (:lint:python:client:common:smoke:, 18.x, 3.11)

Missing semicolon
}

public buildEnterpriseSection() {
return cssSection(
dom.domComputed(this._isEnterprise, isEnterprise => {
if (isEnterprise === null) {
return cssSpinnerBox(loadingSpinner());
}
return [
cssParagraph(
t('Activation keys are used to run Grist Enterprise after a trial period ' +
'of 30 days has expired. Get an activation key by signing up for Grist ' +
'Enterprise. You do not need an activation key to run Grist Core.')
),
cssParagraph(t('Learn more in our {{link}}.', {
link: enterpriseHelpCenterLink(),
})),
this._buildEnterpriseSectionButtons(),
];
}),
testId('enterprise-opt-in-section'),
);
}

public _buildEnterpriseSectionButtons() {
return dom.domComputed(this._isEnterprise, (enterpriseEnabled) => {
if (enterpriseEnabled) {
return [
cssOptInOutMessage(
t('Grist Enterprise Edition is enabled.'),
testId('enterprise-opt-out-message'),
),
cssOptOutButton(t('Disable Grist Enterprise Edition'),
dom.on('click', () => this._isEnterprise.set(false)),
),
];
} else {
return [
cssOptInButton(t('Enable Grist Enterprise Edition'),
dom.on('click', () => this._isEnterprise.set(true)),
),
];
}
});
}



public buildSponsorshipSection() {
return cssSection(
cssParagraph(
Expand Down Expand Up @@ -151,6 +208,13 @@ function telemetryHelpCenterLink() {
);
}

function enterpriseHelpCenterLink() {
return cssLink(
t('Help Center'),
{href: commonUrls.helpEnterpriseOptIn, target: '_blank'},
);
}

function sponsorGristLink() {
return cssLink(
t('GitHub Sponsors page'),
Expand Down
6 changes: 6 additions & 0 deletions app/common/Install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import {TelemetryLevel} from 'app/common/Telemetry';

export interface InstallPrefs {
telemetry?: TelemetryPrefs;
enterprise?: EnterprisePrefs;
}

export interface TelemetryPrefs {
/** Defaults to "off". */
telemetryLevel?: TelemetryLevel;
}

export interface EnterprisePrefs {
/** Defaults to "off". */
enterpriseEnabled: boolean;
}
1 change: 1 addition & 0 deletions app/common/gristUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const commonUrls = {
helpTryingOutChanges: "https://support.getgrist.com/copying-docs/#trying-out-changes",
helpCustomWidgets: "https://support.getgrist.com/widget-custom",
helpTelemetryLimited: "https://support.getgrist.com/telemetry-limited",
helpEnterpriseOptIn: "https://support.getgrist.com/self-managed/#how-do-i-activate-grist-enterprise",
helpCalendarWidget: "https://support.getgrist.com/widget-calendar",
helpLinkKeys: "https://support.getgrist.com/examples/2021-04-link-keys",
helpFilteringReferenceChoices: "https://support.getgrist.com/col-refs/#filtering-reference-choices-in-dropdown",
Expand Down

0 comments on commit 2afddcd

Please sign in to comment.