From bcb5916434b45e788b7c23ce48de2dc916d0371e Mon Sep 17 00:00:00 2001 From: Vinschni Date: Sat, 15 Apr 2023 22:22:56 +0200 Subject: [PATCH] make sendToDrive hidable (#493) Make "sendToDrive" button from share menu hidable. --- README.md | 2 +- app/client/ui/ShareMenu.ts | 6 +++--- app/common/gristUrls.ts | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2904b13d..60c49f98 100644 --- a/README.md +++ b/README.md @@ -260,7 +260,7 @@ GRIST_DEFAULT_PRODUCT | if set, this controls enabled features and limits of ne GRIST_DEFAULT_LOCALE | Locale to use as fallback when Grist cannot honour the browser locale. GRIST_DOMAIN | in hosted Grist, Grist is served from subdomains of this domain. Defaults to "getgrist.com". GRIST_EXPERIMENTAL_PLUGINS | enables experimental plugins -GRIST_HIDE_UI_ELEMENTS | comma-separated list of parts of the UI to hide. Allowed names of parts: `helpCenter,billing,templates,multiSite,multiAccounts` +GRIST_HIDE_UI_ELEMENTS | comma-separated list of parts of the UI to hide. Allowed names of parts: `helpCenter,billing,templates,multiSite,multiAccounts,sendToDrive` GRIST_HOME_INCLUDE_STATIC | if set, home server also serves static resources GRIST_HOST | hostname to use when listening on a port. GRIST_ID_PREFIX | for subdomains of form o-*, expect or produce o-${GRIST_ID_PREFIX}*. diff --git a/app/client/ui/ShareMenu.ts b/app/client/ui/ShareMenu.ts index bf253560..14ff2ea1 100644 --- a/app/client/ui/ShareMenu.ts +++ b/app/client/ui/ShareMenu.ts @@ -11,7 +11,7 @@ import {primaryButton} from 'app/client/ui2018/buttons'; import {mediaXSmall, testId, theme} from 'app/client/ui2018/cssVars'; import {icon} from 'app/client/ui2018/icons'; import {menu, menuAnnotate, menuDivider, menuIcon, menuItem, menuItemLink, menuText} from 'app/client/ui2018/menus'; -import {buildUrlId, parseUrlId} from 'app/common/gristUrls'; +import {buildUrlId, parseUrlId, shouldHideUiElement} from 'app/common/gristUrls'; import * as roles from 'app/common/roles'; import {Document} from 'app/common/UserAPI'; import {dom, DomContents, styled} from 'grainjs'; @@ -244,8 +244,8 @@ function menuExports(doc: Document, pageModel: DocPageModel) { href: pageModel.appModel.api.getDocAPI(doc.id).getDownloadXlsxUrl(), target: '_blank', download: '' }, menuIcon('Download'), t("Export XLSX"), testId('tb-share-option')), - menuItem(() => sendToDrive(doc, pageModel), - menuIcon('Download'), t("Send to Google Drive"), testId('tb-share-option')), + (shouldHideUiElement("sendToDrive") ? null : menuItem(() => sendToDrive(doc, pageModel), + menuIcon('Download'), t("Send to Google Drive"), testId('tb-share-option'))), ]; } diff --git a/app/common/gristUrls.ts b/app/common/gristUrls.ts index a954dbf5..4315f065 100644 --- a/app/common/gristUrls.ts +++ b/app/common/gristUrls.ts @@ -614,7 +614,8 @@ export interface GristLoadConfig { userLocale?: string; } -export const HideableUiElements = StringUnion("helpCenter", "billing", "templates", "multiSite", "multiAccounts"); +export const HideableUiElements = StringUnion("helpCenter", "billing", "templates", "multiSite", "multiAccounts", +"sendToDrive"); export type IHideableUiElement = typeof HideableUiElements.type; export function shouldHideUiElement(elem: IHideableUiElement): boolean {