Skip to content

Commit 457202b

Browse files
committed
Add feature flag
1 parent f226ef4 commit 457202b

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

components/dashboard/src/components/SelectIDEComponent.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
*/
66

77
import { IDEOption, IDEOptions } from "@gitpod/gitpod-protocol/lib/ide-protocol";
8-
import { useCallback, useEffect, useState } from "react";
8+
import { useCallback, useContext, useEffect, useState } from "react";
99
import { getGitpodService } from "../service/service";
1010
import { DropDown2, DropDown2Element } from "./DropDown2";
1111
import Editor from "../icons/Editor.svg";
12+
import { FeatureFlagContext } from "../contexts/FeatureFlagContext";
1213

1314
interface SelectIDEComponentProps {
1415
selectedIdeOption?: string;
@@ -17,8 +18,16 @@ interface SelectIDEComponentProps {
1718
setError?: (error?: string) => void;
1819
}
1920

21+
function filteredIdeOptions(ideOptions: IDEOptions, experimentalTurnedOn: boolean) {
22+
return IDEOptions.asArray(ideOptions)
23+
.filter((x) => !x.hidden)
24+
.filter((x) => (x.experimental ? experimentalTurnedOn : true));
25+
}
26+
2027
export default function SelectIDEComponent(props: SelectIDEComponentProps) {
2128
const [ideOptions, setIdeOptions] = useState<IDEOptions>();
29+
const { experimentalIdes } = useContext(FeatureFlagContext);
30+
2231
useEffect(() => {
2332
getGitpodService().server.getIDEOptions().then(setIdeOptions);
2433
}, []);
@@ -27,7 +36,7 @@ export default function SelectIDEComponent(props: SelectIDEComponentProps) {
2736
if (!ideOptions) {
2837
return [];
2938
}
30-
const options = IDEOptions.asArray(ideOptions);
39+
const options = filteredIdeOptions(ideOptions, experimentalIdes);
3140
const result: DropDown2Element[] = [];
3241
for (const ide of options.filter((ide) =>
3342
`${ide.label}${ide.title}${ide.notes}${ide.id}`.toLowerCase().includes(search.toLowerCase()),

components/dashboard/src/contexts/FeatureFlagContext.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const defaultFeatureFlags = {
3131
userGitAuthProviders: false,
3232
switchToPAYG: false,
3333
newSignupFlow: false,
34+
experimentalIdes: false,
3435
};
3536

3637
const FeatureFlagContext = createContext<FeatureFlagsType>(defaultFeatureFlags);
@@ -51,6 +52,7 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
5152
const [userGitAuthProviders, setUserGitAuthProviders] = useState<boolean>(false);
5253
const [switchToPAYG, setSwitchToPAYG] = useState<boolean>(false);
5354
const [newSignupFlow, setNewSignupFlow] = useState<boolean>(false);
55+
const [experimentalIdes, setExperimentalIdes] = useState<boolean>(false);
5456

5557
useEffect(() => {
5658
if (!user) return;
@@ -71,6 +73,7 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
7173
userGitAuthProviders: { defaultValue: false, setter: setUserGitAuthProviders },
7274
switchToPAYG: { defaultValue: false, setter: setSwitchToPAYG },
7375
newSignupFlow: { defaultValue: false, setter: setNewSignupFlow },
76+
experimentalIdes: { defaultValue: false, setter: setExperimentalIdes },
7477
};
7578

7679
for (const [flagName, config] of Object.entries(featureFlags)) {
@@ -120,6 +123,7 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
120123
userGitAuthProviders,
121124
newSignupFlow,
122125
switchToPAYG,
126+
experimentalIdes,
123127
};
124128
}, [
125129
enablePersonalAccessTokens,
@@ -133,6 +137,7 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
133137
switchToPAYG,
134138
usePublicApiWorkspacesService,
135139
userGitAuthProviders,
140+
experimentalIdes,
136141
]);
137142

138143
return <FeatureFlagContext.Provider value={flags}>{children}</FeatureFlagContext.Provider>;

components/gitpod-protocol/src/ide-protocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ export interface IDEOption {
105105
*/
106106
hidden?: boolean;
107107

108+
/**
109+
* If `true` this IDE option is conditionally shown in the IDE preferences
110+
*/
111+
experimental?: boolean;
112+
108113
/**
109114
* The image ref to the IDE image.
110115
*/

components/ide-service-api/go/config/ideconfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ type IDEOption struct {
4444
Notes []string `json:"notes,omitempty"`
4545
// Hidden this IDE option is not visible in the IDE preferences.
4646
Hidden bool `json:"hidden,omitempty"`
47+
// Experimental this IDE option is to only be shown to some users
48+
Experimental bool `json:"experimental,omitempty"`
4749
// Image ref to the IDE image.
4850
Image string `json:"image"`
4951
// LatestImage ref to the IDE image, this image ref always resolve to digest.

install/installer/pkg/components/ide-service/ide_config_configmap.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ func ideConfigConfigmap(ctx *common.RenderContext) ([]runtime.Object, error) {
205205
Label: "Insiders",
206206
Image: ctx.ImageName(ctx.Config.Repository, ide.XtermIDEImage, "latest"),
207207
ResolveImageDigest: true,
208+
Experimental: true,
208209
},
209210
},
210211
DefaultIde: "code",

0 commit comments

Comments
 (0)