Skip to content

Commit a384241

Browse files
Move the beta notice to a flag. (#955)
Enable it for non-production stages. This removes livePreview. To get the same effect you need to do flag=none.
1 parent 9610c7c commit a384241

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
lines changed

src/environment.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
* SPDX-License-Identifier: MIT
55
*/
66
export const version = process.env.REACT_APP_VERSION || "local";
7-
export const stage = process.env.REACT_APP_STAGE || "local";
7+
8+
export type Stage = "local" | "REVIEW" | "STAGING" | "PRODUCTION";
9+
10+
export const stage = (process.env.REACT_APP_STAGE || "local") as Stage;

src/flags.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,21 @@
1010
* SPDX-License-Identifier: MIT
1111
*/
1212

13-
import { stage as stageFromEnvironment } from "./environment";
13+
import { Stage, stage as stageFromEnvironment } from "./environment";
1414

1515
/**
1616
* A union of the flag names (alphabetical order).
1717
*/
1818
export type Flag =
19-
/**
20-
* Enables a preview of SoundEffects via the audio-sound-effect MicroPython branch.
21-
*/
22-
| "audioSoundEffect"
23-
2419
/**
2520
* Enables verbose debug logging to the console of drag events.
2621
*/
2722
| "dndDebug"
2823

2924
/**
30-
* Flag to enable live-only features and hide beta only ones.
31-
*
32-
* We'll remove this when we go live.
25+
* Flag to add a beta notice. Enabled for staging site but not production stages.
3326
*/
34-
| "livePreview"
27+
| "betaNotice"
3528

3629
/**
3730
* Disables the pop-up welcome dialog.
@@ -42,22 +35,21 @@ export type Flag =
4235
| "noWelcome";
4336

4437
interface FlagMetadata {
45-
defaultOnStages: string[];
38+
defaultOnStages: Stage[];
4639
name: Flag;
4740
}
4841

4942
const allFlags: FlagMetadata[] = [
5043
// Alphabetical order.
51-
{ name: "audioSoundEffect", defaultOnStages: [] },
5244
{ name: "dndDebug", defaultOnStages: [] },
53-
{ name: "livePreview", defaultOnStages: ["local", "REVIEW"] },
45+
{ name: "betaNotice", defaultOnStages: ["local", "REVIEW", "STAGING"] },
5446
{ name: "noWelcome", defaultOnStages: ["local", "REVIEW"] },
5547
];
5648

5749
type Flags = Record<Flag, boolean>;
5850

5951
// Exposed for testing.
60-
export const flagsForParams = (stage: string, params: URLSearchParams) => {
52+
export const flagsForParams = (stage: Stage, params: URLSearchParams) => {
6153
const enableFlags = new Set(params.getAll("flag"));
6254
const allFlagsDefault = enableFlags.has("none")
6355
? false
@@ -74,7 +66,7 @@ export const flagsForParams = (stage: string, params: URLSearchParams) => {
7466

7567
const isEnabled = (
7668
f: FlagMetadata,
77-
stage: string,
69+
stage: Stage,
7870
allFlagsDefault: boolean | undefined,
7971
thisFlagOn: boolean
8072
): boolean => {

src/workbench/SideBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ const SideBar = ({
211211
<Flex height="100%" direction="column">
212212
<ErrorBoundary>
213213
{p.contents}
214-
{!flags.livePreview && (
214+
{flags.betaNotice && (
215215
<PreReleaseNotice onDialogChange={setReleaseDialog} />
216216
)}
217217
</ErrorBoundary>

src/workbench/flags.test.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@ describe("flags", () => {
1414
expect(flags.dndDebug).toEqual(false);
1515
});
1616

17-
for (const stage of ["STAGING", "PRODUCTION"]) {
18-
// This might change in future if we opt in to flags on staging once we have production.
19-
it("enables nothing in " + stage, () => {
20-
const params = new URLSearchParams([]);
17+
it("enables nothing in production", () => {
18+
const params = new URLSearchParams([]);
2119

22-
const flags = flagsForParams(stage, params);
20+
const flags = flagsForParams("PRODUCTION", params);
2321

24-
expect(Object.values(flags).every((x) => x)).toEqual(false);
25-
});
26-
}
22+
expect(Object.values(flags).every((x) => !x)).toEqual(true);
23+
});
2724

2825
it("enable specific flag", () => {
2926
const params = new URLSearchParams([["flag", "noWelcome"]]);

0 commit comments

Comments
 (0)