mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Allow configuring (mostly hiding) various little bits of UI
Summary: Adds two new env vars GRIST_HIDE_UI_ELEMENTS and GRIST_PAGE_TITLE_SUFFIX which translate to values in GristLoadConfig that the server sends the client when loading. For checkin task https://gristlabs.getgrist.com/doc/check-ins/p/5#a1.s9.r1882.c19 Test Plan: Tested manually Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3449
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {GristLoadConfig} from 'app/common/gristUrls';
|
||||
import {getPageTitleSuffix, GristLoadConfig, HideableUiElements, IHideableUiElement} from 'app/common/gristUrls';
|
||||
import {getTagManagerSnippet} from 'app/common/tagManager';
|
||||
import {isAnonymousUser, RequestWithLogin} from 'app/server/lib/Authorizer';
|
||||
import {RequestWithOrg} from 'app/server/lib/extractOrg';
|
||||
@@ -38,6 +38,8 @@ export function makeGristConfig(homeUrl: string|null, extra: Partial<GristLoadCo
|
||||
pathOnly,
|
||||
supportAnon: shouldSupportAnon(),
|
||||
supportEngines: getSupportedEngineChoices(),
|
||||
hideUiElements: getHiddenUiElements(),
|
||||
pageTitleSuffix: configuredPageTitleSuffix(),
|
||||
pluginUrl,
|
||||
stripeAPIKey: process.env.STRIPE_PUBLIC_API_KEY,
|
||||
googleClientId: process.env.GOOGLE_CLIENT_ID,
|
||||
@@ -110,6 +112,7 @@ export function makeSendAppPage(opts: {
|
||||
// Temporary changes end.
|
||||
const content = fileContent
|
||||
.replace("<!-- INSERT WARNING -->", warning)
|
||||
.replace("<!-- INSERT TITLE SUFFIX -->", getPageTitleSuffix(server?.getGristConfig()))
|
||||
.replace("<!-- INSERT BASE -->", `<base href="${staticBaseUrl}">` + tagManagerSnippet)
|
||||
.replace("<!-- INSERT CUSTOM -->", customHeadHtmlSnippet)
|
||||
.replace("<!-- INSERT CONFIG -->", `<script>window.gristConfig = ${JSON.stringify(config)};</script>`);
|
||||
@@ -121,3 +124,16 @@ function shouldSupportAnon() {
|
||||
// Enable UI for anonymous access if a flag is explicitly set in the environment
|
||||
return process.env.GRIST_SUPPORT_ANON === "true";
|
||||
}
|
||||
|
||||
function getHiddenUiElements(): IHideableUiElement[] {
|
||||
const str = process.env.GRIST_HIDE_UI_ELEMENTS;
|
||||
if (!str) {
|
||||
return [];
|
||||
}
|
||||
return HideableUiElements.checkAll(str.split(","));
|
||||
}
|
||||
|
||||
function configuredPageTitleSuffix() {
|
||||
const result = process.env.GRIST_PAGE_TITLE_SUFFIX;
|
||||
return result === "_blank" ? "" : result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user