From ba691aa2b2c1cae21545bbb19ade35d9e5565895 Mon Sep 17 00:00:00 2001 From: Robert Knight <95928279+microbit-robert@users.noreply.github.com> Date: Tue, 19 Sep 2023 09:45:13 +0100 Subject: [PATCH] Add flag to hide language setting menu (#1128) We will use this when embedding inside micro:bit classroom to control language at the top level. --- src/flags.ts | 10 +++++++++- src/settings/SettingsMenu.tsx | 17 ++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/flags.ts b/src/flags.ts index 8802177c7..272a115f6 100644 --- a/src/flags.ts +++ b/src/flags.ts @@ -32,7 +32,14 @@ export type Flag = * Added to support user-testing and has the nice side-effect of disabling * the dialog for local development so is worth keeping for that use alone. */ - | "noWelcome"; + | "noWelcome" + /** + * Disables language selection from the settings menu. + * + * Added so we can embed the editor in micro:bit classroom without competing language + * options. The language selected in classroom is passed through via query param. + */ + | "noLang"; interface FlagMetadata { defaultOnStages: Stage[]; @@ -44,6 +51,7 @@ const allFlags: FlagMetadata[] = [ { name: "dndDebug", defaultOnStages: [] }, { name: "betaNotice", defaultOnStages: ["local", "REVIEW", "STAGING"] }, { name: "noWelcome", defaultOnStages: ["local", "REVIEW"] }, + { name: "noLang", defaultOnStages: [] }, ]; type Flags = Record; diff --git a/src/settings/SettingsMenu.tsx b/src/settings/SettingsMenu.tsx index 212c0b1ca..33497c7f4 100644 --- a/src/settings/SettingsMenu.tsx +++ b/src/settings/SettingsMenu.tsx @@ -20,6 +20,7 @@ import { RiListSettingsLine, RiSettings2Line } from "react-icons/ri"; import { FormattedMessage, useIntl } from "react-intl"; import { useDialogs } from "../common/use-dialogs"; import { zIndexAboveTerminal } from "../common/zIndex"; +import { flags } from "../flags"; import { LanguageDialog } from "./LanguageDialog"; import { SettingsDialog } from "./SettingsDialog"; @@ -66,13 +67,15 @@ const SettingsMenu = ({ size, ...props }: SettingsMenuProps) => { /> - } - onClick={languageDisclosure.onOpen} - data-testid="language" - > - - + {!flags.noLang && ( + } + onClick={languageDisclosure.onOpen} + data-testid="language" + > + + + )} } onClick={handleShowSettings}