From 77f63f8f43c8842df9aa32b96d6780b6210aa5ed Mon Sep 17 00:00:00 2001
From: Pavel Tumik <18602811+sagor999@users.noreply.github.com>
Date: Wed, 8 Jun 2022 22:40:07 +0000
Subject: [PATCH] Add persistent volume claim to prebuild settings
---
.../dashboard/src/admin/ProjectDetail.tsx | 3 +
.../src/projects/ProjectSettings.tsx | 57 ++++++++++++++++++-
.../src/teams-projects-protocol.ts | 1 +
3 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/components/dashboard/src/admin/ProjectDetail.tsx b/components/dashboard/src/admin/ProjectDetail.tsx
index 9c2293d501ae5c..00bf6adc9fcae2 100644
--- a/components/dashboard/src/admin/ProjectDetail.tsx
+++ b/components/dashboard/src/admin/ProjectDetail.tsx
@@ -63,6 +63,9 @@ export default function ProjectDetail(props: { project: Project; owner: string |
{props.project.settings?.useIncrementalPrebuilds ? "Yes" : "No"}
+
+ {props.project.settings?.usePersistentVolumeClaim ? "Yes" : "No"}
+
{props.project.markedDeleted ? "Yes" : "No"}
diff --git a/components/dashboard/src/projects/ProjectSettings.tsx b/components/dashboard/src/projects/ProjectSettings.tsx
index 3a6362ee15056b..ed987d31d2827c 100644
--- a/components/dashboard/src/projects/ProjectSettings.tsx
+++ b/components/dashboard/src/projects/ProjectSettings.tsx
@@ -13,6 +13,7 @@ import { getCurrentTeam, TeamsContext } from "../teams/teams-context";
import { PageWithSubMenu } from "../components/PageWithSubMenu";
import PillLabel from "../components/PillLabel";
import { ProjectContext } from "./project-context";
+import { getExperimentsClient } from "./../experiments/client";
export function getProjectSettingsMenu(project?: Project, team?: Team) {
const teamOrUserSlug = !!team ? "t/" + team.slug : "projects";
@@ -50,9 +51,14 @@ export function ProjectSettingsPage(props: { project?: Project; children?: React
export default function () {
const { project } = useContext(ProjectContext);
+ const location = useLocation();
+ const { teams } = useContext(TeamsContext);
+ const team = getCurrentTeam(location, teams);
const [isLoading, setIsLoading] = useState(true);
const [isIncrementalPrebuildsEnabled, setIsIncrementalPrebuildsEnabled] = useState(false);
+ const [isPersistentVolumeClaimEnabled, setIsPersistentVolumeClaimEnabled] = useState(false);
+ const [isShowPersistentVolumeClaim, setIsShowPersistentVolumeClaim] = useState(false);
useEffect(() => {
if (!project) {
@@ -60,7 +66,22 @@ export default function () {
}
setIsLoading(false);
setIsIncrementalPrebuildsEnabled(!!project.settings?.useIncrementalPrebuilds);
- }, [project]);
+ setIsPersistentVolumeClaimEnabled(!!project.settings?.usePersistentVolumeClaim);
+
+ (async () => {
+ const showPersistentVolumeClaim = await getExperimentsClient().getValueAsync(
+ "persistent_volume_claim",
+ false,
+ {
+ projectId: project?.id,
+ teamId: team?.id,
+ teamName: team?.name,
+ teams,
+ },
+ );
+ setIsShowPersistentVolumeClaim(showPersistentVolumeClaim);
+ })();
+ }, [project, team, teams]);
const toggleIncrementalPrebuilds = async () => {
if (!project) {
@@ -80,6 +101,24 @@ export default function () {
}
};
+ const togglePersistentVolumeClaim = async () => {
+ if (!project) {
+ return;
+ }
+ setIsLoading(true);
+ try {
+ await getGitpodService().server.updateProjectPartial({
+ id: project.id,
+ settings: {
+ usePersistentVolumeClaim: !isPersistentVolumeClaimEnabled,
+ },
+ });
+ setIsPersistentVolumeClaimEnabled(!isPersistentVolumeClaimEnabled);
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
return (
Incremental Prebuilds
@@ -106,6 +145,22 @@ export default function () {
disabled={isLoading}
onChange={toggleIncrementalPrebuilds}
/>
+
+ Persistent Volume Claim
+
+ Enable Persistent Volume Claim{" "}
+
+ Experimental
+
+
+ }
+ desc={Experimental feature that is still under development.}
+ checked={isPersistentVolumeClaimEnabled}
+ disabled={isLoading || !isShowPersistentVolumeClaim}
+ onChange={togglePersistentVolumeClaim}
+ />
);
}
diff --git a/components/gitpod-protocol/src/teams-projects-protocol.ts b/components/gitpod-protocol/src/teams-projects-protocol.ts
index 67d9a83750084e..e5568e68644b2d 100644
--- a/components/gitpod-protocol/src/teams-projects-protocol.ts
+++ b/components/gitpod-protocol/src/teams-projects-protocol.ts
@@ -14,6 +14,7 @@ export interface ProjectConfig {
export interface ProjectSettings {
useIncrementalPrebuilds?: boolean;
+ usePersistentVolumeClaim?: boolean;
}
export interface Project {