Skip to content

Commit 12e7106

Browse files
committed
[dashboard] Nudge users toward pay-as-you-go in workspace class preferences
1 parent fcc42fe commit 12e7106

File tree

2 files changed

+54
-37
lines changed

2 files changed

+54
-37
lines changed

components/dashboard/src/projects/ProjectSettings.tsx

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import PillLabel from "../components/PillLabel";
1515
import { ProjectContext } from "./project-context";
1616
import SelectWorkspaceClass from "../settings/selectClass";
1717
import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode";
18+
import Alert from "../components/Alert";
1819

1920
export function getProjectSettingsMenu(project?: Project, team?: Team) {
2021
const teamOrUserSlug = !!team ? "t/" + team.slug : "projects";
@@ -48,12 +49,14 @@ export function ProjectSettingsPage(props: { project?: Project; children?: React
4849

4950
export default function () {
5051
const { project, setProject } = useContext(ProjectContext);
51-
const [teamBillingMode, setTeamBillingMode] = useState<BillingMode | undefined>(undefined);
52+
const [billingMode, setBillingMode] = useState<BillingMode | undefined>(undefined);
5253
const { teams } = useContext(TeamsContext);
5354
const team = getCurrentTeam(useLocation(), teams);
5455
useEffect(() => {
5556
if (team) {
56-
getGitpodService().server.getBillingModeForTeam(team.id).then(setTeamBillingMode);
57+
getGitpodService().server.getBillingModeForTeam(team.id).then(setBillingMode);
58+
} else {
59+
getGitpodService().server.getBillingModeForUser().then(setBillingMode);
5760
}
5861
}, [team]);
5962

@@ -156,13 +159,38 @@ export default function () {
156159
</div>
157160
</div>
158161
</div>
159-
{BillingMode.canSetWorkspaceClass(teamBillingMode) && (
160-
<SelectWorkspaceClass
161-
workspaceClass={project.settings?.workspaceClasses?.regular}
162-
enabled={BillingMode.canSetWorkspaceClass(teamBillingMode)}
163-
setWorkspaceClass={setWorkspaceClass}
164-
/>
165-
)}
162+
<div>
163+
<h3 className="mt-12">Workspaces</h3>
164+
<p className="text-base text-gray-500 dark:text-gray-400">
165+
Choose the workspace machine type for your workspaces.
166+
</p>
167+
{BillingMode.canSetWorkspaceClass(billingMode) ? (
168+
<SelectWorkspaceClass
169+
workspaceClass={project.settings?.workspaceClasses?.regular}
170+
setWorkspaceClass={setWorkspaceClass}
171+
/>
172+
) : (
173+
<Alert type="message" className="mt-4">
174+
<div className="flex flex-col">
175+
<span className="text-md font-semibold">
176+
Upgrade your {project.teamId ? "team" : "personal account"} to access larger workspaces
177+
</span>
178+
<span className="font-sm">
179+
Workspace classes allow you to select the resources available to your workspaces.{" "}
180+
<a
181+
className="gp-link"
182+
href="https://www.gitpod.io/docs/configure/workspaces/workspace-classes"
183+
>
184+
Learn more
185+
</a>
186+
</span>
187+
<a className="mt-4" href={project.teamId ? "../billing" : "/billing"}>
188+
<button>Upgrade {project.teamId ? "Team" : "Personal Account"}</button>
189+
</a>
190+
</div>
191+
</Alert>
192+
)}
193+
</div>
166194
</ProjectSettingsPage>
167195
);
168196
}

components/dashboard/src/settings/selectClass.tsx

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import WorkspaceClass from "../components/WorkspaceClass";
1111
import { SupportedWorkspaceClass } from "@gitpod/gitpod-protocol/lib/workspace-class";
1212

1313
interface SelectWorkspaceClassProps {
14-
enabled: boolean;
1514
workspaceClass?: string;
1615
setWorkspaceClass: (value: string) => Promise<string | undefined>;
1716
}
@@ -44,31 +43,21 @@ export default function SelectWorkspaceClass(props: SelectWorkspaceClassProps) {
4443
fetchClasses().catch(console.error);
4544
}, []);
4645

47-
if (!props.enabled) {
48-
return <div></div>;
49-
} else {
50-
return (
51-
<div>
52-
<h3 className="mt-12">Workspaces</h3>
53-
<p className="text-base text-gray-500 dark:text-gray-400">
54-
Choose the workspace machine type for your workspaces.
55-
</p>
56-
<div className="mt-4 space-x-3 flex">
57-
{supportedClasses.map((c) => {
58-
return (
59-
<WorkspaceClass
60-
additionalStyles="w-80 h-32"
61-
selected={workspaceClass === c.id}
62-
onClick={() => actuallySetWorkspaceClass(c.id)}
63-
category={c.category}
64-
friendlyName={c.displayName}
65-
description={c.description}
66-
powerUps={c.powerups}
67-
/>
68-
);
69-
})}
70-
</div>
71-
</div>
72-
);
73-
}
46+
return (
47+
<div className="mt-4 space-x-3 flex">
48+
{supportedClasses.map((c) => {
49+
return (
50+
<WorkspaceClass
51+
additionalStyles="w-80 h-32"
52+
selected={workspaceClass === c.id}
53+
onClick={() => actuallySetWorkspaceClass(c.id)}
54+
category={c.category}
55+
friendlyName={c.displayName}
56+
description={c.description}
57+
powerUps={c.powerups}
58+
/>
59+
);
60+
})}
61+
</div>
62+
);
7463
}

0 commit comments

Comments
 (0)