Skip to content

Commit 28f48ac

Browse files
sagor999roboquat
authored andcommitted
Add persistent volume claim to prebuild settings
1 parent 18cf092 commit 28f48ac

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

components/dashboard/src/admin/ProjectDetail.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ export default function ProjectDetail(props: { project: Project; owner: string |
6363
<Property name="Incremental Prebuilds">
6464
{props.project.settings?.useIncrementalPrebuilds ? "Yes" : "No"}
6565
</Property>
66+
<Property name="Persistent Volume Claim">
67+
{props.project.settings?.usePersistentVolumeClaim ? "Yes" : "No"}
68+
</Property>
6669
<Property name="Marked Deleted">{props.project.markedDeleted ? "Yes" : "No"}</Property>
6770
</div>
6871
</div>

components/dashboard/src/projects/ProjectSettings.tsx

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { getCurrentTeam, TeamsContext } from "../teams/teams-context";
1313
import { PageWithSubMenu } from "../components/PageWithSubMenu";
1414
import PillLabel from "../components/PillLabel";
1515
import { ProjectContext } from "./project-context";
16+
import { getExperimentsClient } from "./../experiments/client";
1617

1718
export function getProjectSettingsMenu(project?: Project, team?: Team) {
1819
const teamOrUserSlug = !!team ? "t/" + team.slug : "projects";
@@ -50,17 +51,37 @@ export function ProjectSettingsPage(props: { project?: Project; children?: React
5051

5152
export default function () {
5253
const { project } = useContext(ProjectContext);
54+
const location = useLocation();
55+
const { teams } = useContext(TeamsContext);
56+
const team = getCurrentTeam(location, teams);
5357

5458
const [isLoading, setIsLoading] = useState<boolean>(true);
5559
const [isIncrementalPrebuildsEnabled, setIsIncrementalPrebuildsEnabled] = useState<boolean>(false);
60+
const [isPersistentVolumeClaimEnabled, setIsPersistentVolumeClaimEnabled] = useState<boolean>(false);
61+
const [isShowPersistentVolumeClaim, setIsShowPersistentVolumeClaim] = useState<boolean>(false);
5662

5763
useEffect(() => {
5864
if (!project) {
5965
return;
6066
}
6167
setIsLoading(false);
6268
setIsIncrementalPrebuildsEnabled(!!project.settings?.useIncrementalPrebuilds);
63-
}, [project]);
69+
setIsPersistentVolumeClaimEnabled(!!project.settings?.usePersistentVolumeClaim);
70+
71+
(async () => {
72+
const showPersistentVolumeClaim = await getExperimentsClient().getValueAsync(
73+
"persistent_volume_claim",
74+
false,
75+
{
76+
projectId: project?.id,
77+
teamId: team?.id,
78+
teamName: team?.name,
79+
teams,
80+
},
81+
);
82+
setIsShowPersistentVolumeClaim(showPersistentVolumeClaim);
83+
})();
84+
}, [project, team, teams]);
6485

6586
const toggleIncrementalPrebuilds = async () => {
6687
if (!project) {
@@ -80,6 +101,24 @@ export default function () {
80101
}
81102
};
82103

104+
const togglePersistentVolumeClaim = async () => {
105+
if (!project) {
106+
return;
107+
}
108+
setIsLoading(true);
109+
try {
110+
await getGitpodService().server.updateProjectPartial({
111+
id: project.id,
112+
settings: {
113+
usePersistentVolumeClaim: !isPersistentVolumeClaimEnabled,
114+
},
115+
});
116+
setIsPersistentVolumeClaimEnabled(!isPersistentVolumeClaimEnabled);
117+
} finally {
118+
setIsLoading(false);
119+
}
120+
};
121+
83122
return (
84123
<ProjectSettingsPage project={project}>
85124
<h3>Incremental Prebuilds</h3>
@@ -106,6 +145,22 @@ export default function () {
106145
disabled={isLoading}
107146
onChange={toggleIncrementalPrebuilds}
108147
/>
148+
<br></br>
149+
<h3>Persistent Volume Claim</h3>
150+
<CheckBox
151+
title={
152+
<span>
153+
Enable Persistent Volume Claim{" "}
154+
<PillLabel type="warn" className="font-semibold mt-2 ml-2 py-0.5 px-2 self-center">
155+
Experimental
156+
</PillLabel>
157+
</span>
158+
}
159+
desc={<span>Experimental feature that is still under development.</span>}
160+
checked={isPersistentVolumeClaimEnabled}
161+
disabled={isLoading || !isShowPersistentVolumeClaim}
162+
onChange={togglePersistentVolumeClaim}
163+
/>
109164
</ProjectSettingsPage>
110165
);
111166
}

components/gitpod-protocol/src/teams-projects-protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ProjectConfig {
1414

1515
export interface ProjectSettings {
1616
useIncrementalPrebuilds?: boolean;
17+
usePersistentVolumeClaim?: boolean;
1718
}
1819

1920
export interface Project {

0 commit comments

Comments
 (0)