Skip to content

Commit ba691aa

Browse files
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.
1 parent 596370d commit ba691aa

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/flags.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ export type Flag =
3232
* Added to support user-testing and has the nice side-effect of disabling
3333
* the dialog for local development so is worth keeping for that use alone.
3434
*/
35-
| "noWelcome";
35+
| "noWelcome"
36+
/**
37+
* Disables language selection from the settings menu.
38+
*
39+
* Added so we can embed the editor in micro:bit classroom without competing language
40+
* options. The language selected in classroom is passed through via query param.
41+
*/
42+
| "noLang";
3643

3744
interface FlagMetadata {
3845
defaultOnStages: Stage[];
@@ -44,6 +51,7 @@ const allFlags: FlagMetadata[] = [
4451
{ name: "dndDebug", defaultOnStages: [] },
4552
{ name: "betaNotice", defaultOnStages: ["local", "REVIEW", "STAGING"] },
4653
{ name: "noWelcome", defaultOnStages: ["local", "REVIEW"] },
54+
{ name: "noLang", defaultOnStages: [] },
4755
];
4856

4957
type Flags = Record<Flag, boolean>;

src/settings/SettingsMenu.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { RiListSettingsLine, RiSettings2Line } from "react-icons/ri";
2020
import { FormattedMessage, useIntl } from "react-intl";
2121
import { useDialogs } from "../common/use-dialogs";
2222
import { zIndexAboveTerminal } from "../common/zIndex";
23+
import { flags } from "../flags";
2324
import { LanguageDialog } from "./LanguageDialog";
2425
import { SettingsDialog } from "./SettingsDialog";
2526

@@ -66,13 +67,15 @@ const SettingsMenu = ({ size, ...props }: SettingsMenuProps) => {
6667
/>
6768
<Portal>
6869
<MenuList zIndex={zIndexAboveTerminal}>
69-
<MenuItem
70-
icon={<IoMdGlobe />}
71-
onClick={languageDisclosure.onOpen}
72-
data-testid="language"
73-
>
74-
<FormattedMessage id="language" />
75-
</MenuItem>
70+
{!flags.noLang && (
71+
<MenuItem
72+
icon={<IoMdGlobe />}
73+
onClick={languageDisclosure.onOpen}
74+
data-testid="language"
75+
>
76+
<FormattedMessage id="language" />
77+
</MenuItem>
78+
)}
7679
<MenuItem
7780
icon={<RiListSettingsLine />}
7881
onClick={handleShowSettings}

0 commit comments

Comments
 (0)