Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add persistent volume claim to prebuild settings #10539

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/dashboard/src/admin/ProjectDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export default function ProjectDetail(props: { project: Project; owner: string |
<Property name="Incremental Prebuilds">
{props.project.settings?.useIncrementalPrebuilds ? "Yes" : "No"}
</Property>
<Property name="Persistent Volume Claim">
{props.project.settings?.usePersistentVolumeClaim ? "Yes" : "No"}
</Property>
<Property name="Marked Deleted">{props.project.markedDeleted ? "Yes" : "No"}</Property>
</div>
</div>
Expand Down
57 changes: 56 additions & 1 deletion components/dashboard/src/projects/ProjectSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -50,17 +51,37 @@ 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<boolean>(true);
const [isIncrementalPrebuildsEnabled, setIsIncrementalPrebuildsEnabled] = useState<boolean>(false);
const [isPersistentVolumeClaimEnabled, setIsPersistentVolumeClaimEnabled] = useState<boolean>(false);
const [isShowPersistentVolumeClaim, setIsShowPersistentVolumeClaim] = useState<boolean>(false);

useEffect(() => {
if (!project) {
return;
}
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) {
Expand All @@ -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 (
<ProjectSettingsPage project={project}>
<h3>Incremental Prebuilds</h3>
Expand All @@ -106,6 +145,22 @@ export default function () {
disabled={isLoading}
onChange={toggleIncrementalPrebuilds}
/>
<br></br>
<h3>Persistent Volume Claim</h3>
<CheckBox
title={
<span>
Enable Persistent Volume Claim{" "}
<PillLabel type="warn" className="font-semibold mt-2 ml-2 py-0.5 px-2 self-center">
Experimental
</PillLabel>
</span>
}
desc={<span>Experimental feature that is still under development.</span>}
checked={isPersistentVolumeClaimEnabled}
disabled={isLoading || !isShowPersistentVolumeClaim}
onChange={togglePersistentVolumeClaim}
/>
</ProjectSettingsPage>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface ProjectConfig {

export interface ProjectSettings {
useIncrementalPrebuilds?: boolean;
usePersistentVolumeClaim?: boolean;
}

export interface Project {
Expand Down