Skip to content

Commit

Permalink
Add flag to hide language setting menu (#1128)
Browse files Browse the repository at this point in the history
We will use this when embedding inside micro:bit classroom to control
language at the top level.
  • Loading branch information
microbit-robert authored Sep 19, 2023
1 parent 596370d commit ba691aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
10 changes: 9 additions & 1 deletion src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -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<Flag, boolean>;
Expand Down
17 changes: 10 additions & 7 deletions src/settings/SettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -66,13 +67,15 @@ const SettingsMenu = ({ size, ...props }: SettingsMenuProps) => {
/>
<Portal>
<MenuList zIndex={zIndexAboveTerminal}>
<MenuItem
icon={<IoMdGlobe />}
onClick={languageDisclosure.onOpen}
data-testid="language"
>
<FormattedMessage id="language" />
</MenuItem>
{!flags.noLang && (
<MenuItem
icon={<IoMdGlobe />}
onClick={languageDisclosure.onOpen}
data-testid="language"
>
<FormattedMessage id="language" />
</MenuItem>
)}
<MenuItem
icon={<RiListSettingsLine />}
onClick={handleShowSettings}
Expand Down

0 comments on commit ba691aa

Please sign in to comment.