Skip to content

Commit 1454544

Browse files
jankeromnesroboquat
authored andcommitted
[dashboard] Introduce showUseLastSuccessfulPrebuild feature flag
1 parent 5687600 commit 1454544

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

Diff for: components/dashboard/src/contexts/FeatureFlagContext.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ interface FeatureFlagConfig {
1818
const FeatureFlagContext = createContext<{
1919
showPersistentVolumeClaimUI: boolean;
2020
showUsageView: boolean;
21+
showUseLastSuccessfulPrebuild: boolean;
2122
}>({
2223
showPersistentVolumeClaimUI: false,
2324
showUsageView: false,
25+
showUseLastSuccessfulPrebuild: false,
2426
});
2527

2628
const FeatureFlagContextProvider: React.FC = ({ children }) => {
@@ -31,13 +33,15 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
3133
const team = getCurrentTeam(location, teams);
3234
const [showPersistentVolumeClaimUI, setShowPersistentVolumeClaimUI] = useState<boolean>(false);
3335
const [showUsageView, setShowUsageView] = useState<boolean>(false);
36+
const [showUseLastSuccessfulPrebuild, setShowUseLastSuccessfulPrebuild] = useState<boolean>(false);
3437

3538
useEffect(() => {
3639
if (!user) return;
3740
(async () => {
3841
const featureFlags: FeatureFlagConfig = {
3942
persistent_volume_claim: { defaultValue: true, setter: setShowPersistentVolumeClaimUI },
4043
usage_view: { defaultValue: false, setter: setShowUsageView },
44+
showUseLastSuccessfulPrebuild: { defaultValue: false, setter: setShowUseLastSuccessfulPrebuild },
4145
};
4246
for (const [flagName, config] of Object.entries(featureFlags)) {
4347
if (teams) {
@@ -69,7 +73,9 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
6973
}, [user, teams, team, project]);
7074

7175
return (
72-
<FeatureFlagContext.Provider value={{ showPersistentVolumeClaimUI, showUsageView }}>
76+
<FeatureFlagContext.Provider
77+
value={{ showPersistentVolumeClaimUI, showUsageView, showUseLastSuccessfulPrebuild }}
78+
>
7379
{children}
7480
</FeatureFlagContext.Provider>
7581
);

Diff for: components/dashboard/src/start/CreateWorkspace.tsx

+10-6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { BillingAccountSelector } from "../components/BillingAccountSelector";
2929
import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution";
3030
import { TeamsContext } from "../teams/teams-context";
3131
import Alert from "../components/Alert";
32+
import { FeatureFlagContext } from "../contexts/FeatureFlagContext";
3233

3334
export interface CreateWorkspaceProps {
3435
contextUrl: string;
@@ -541,6 +542,7 @@ interface RunningPrebuildViewProps {
541542

542543
function RunningPrebuildView(props: RunningPrebuildViewProps) {
543544
const workspaceId = props.runningPrebuild.workspaceID;
545+
const { showUseLastSuccessfulPrebuild } = useContext(FeatureFlagContext);
544546

545547
useEffect(() => {
546548
const disposables = new DisposableCollection();
@@ -569,12 +571,14 @@ function RunningPrebuildView(props: RunningPrebuildViewProps) {
569571
{/* TODO(gpl) Copied around in Start-/CreateWorkspace. This should properly go somewhere central. */}
570572
<div className="h-full mt-6 w-11/12 lg:w-3/5">
571573
<PrebuildLogs workspaceId={workspaceId} onIgnorePrebuild={props.onIgnorePrebuild}>
572-
<button
573-
className="secondary"
574-
onClick={() => props.onUseLastSuccessfulPrebuild && props.onUseLastSuccessfulPrebuild()}
575-
>
576-
Use Last Successful Prebuild
577-
</button>
574+
{showUseLastSuccessfulPrebuild && (
575+
<button
576+
className="secondary"
577+
onClick={() => props.onUseLastSuccessfulPrebuild && props.onUseLastSuccessfulPrebuild()}
578+
>
579+
Use Last Successful Prebuild
580+
</button>
581+
)}
578582
<button className="secondary" onClick={() => props.onIgnorePrebuild && props.onIgnorePrebuild()}>
579583
Skip Prebuild
580584
</button>

0 commit comments

Comments
 (0)