Skip to content

Commit 3dec626

Browse files
committed
[dashboard] Nudge users toward pay-as-you-go in workspace class preferences
1 parent d1072e1 commit 3dec626

File tree

3 files changed

+61
-38
lines changed

3 files changed

+61
-38
lines changed

components/dashboard/src/components/Alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const infoMap: Record<AlertType, AlertInfo> = {
6262
iconColor: "text-gray-400",
6363
},
6464
message: {
65-
bgCls: "bg-blue-50 dark:bg-blue-700",
65+
bgCls: "bg-blue-50 dark:bg-blue-800",
6666
txtCls: "text-blue-800 dark:text-blue-100",
6767
icon: <InfoSvg className="w-4 h-4"></InfoSvg>,
6868
iconColor: "text-blue-400",

components/dashboard/src/projects/ProjectSettings.tsx

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ 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";
19+
import { Link } from "react-router-dom";
1820

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

4951
export default function () {
5052
const { project, setProject } = useContext(ProjectContext);
51-
const [teamBillingMode, setTeamBillingMode] = useState<BillingMode | undefined>(undefined);
53+
const [billingMode, setBillingMode] = useState<BillingMode | undefined>(undefined);
5254
const { teams } = useContext(TeamsContext);
5355
const team = getCurrentTeam(useLocation(), teams);
5456
useEffect(() => {
5557
if (team) {
56-
getGitpodService().server.getBillingModeForTeam(team.id).then(setTeamBillingMode);
58+
getGitpodService().server.getBillingModeForTeam(team.id).then(setBillingMode);
59+
} else {
60+
getGitpodService().server.getBillingModeForUser().then(setBillingMode);
5761
}
5862
}, [team]);
5963

@@ -156,13 +160,43 @@ export default function () {
156160
</div>
157161
</div>
158162
</div>
159-
{BillingMode.canSetWorkspaceClass(teamBillingMode) && (
160-
<SelectWorkspaceClass
161-
workspaceClass={project.settings?.workspaceClasses?.regular}
162-
enabled={BillingMode.canSetWorkspaceClass(teamBillingMode)}
163-
setWorkspaceClass={setWorkspaceClass}
164-
/>
165-
)}
163+
<div>
164+
<h3 className="mt-12">Workspaces</h3>
165+
<p className="text-base text-gray-500 dark:text-gray-400">
166+
Choose the workspace machine type for your workspaces.
167+
</p>
168+
{BillingMode.canSetWorkspaceClass(billingMode) ? (
169+
<SelectWorkspaceClass
170+
workspaceClass={project.settings?.workspaceClasses?.regular}
171+
setWorkspaceClass={setWorkspaceClass}
172+
/>
173+
) : (
174+
<Alert type="message" className="mt-4">
175+
<div className="flex flex-col">
176+
<span>
177+
To access{" "}
178+
<a
179+
className="gp-link"
180+
href="https://www.gitpod.io/docs/configure/workspaces/workspace-classes"
181+
>
182+
large workspaces
183+
</a>{" "}
184+
and{" "}
185+
<a
186+
className="gp-link"
187+
href="https://www.gitpod.io/docs/configure/billing/pay-as-you-go"
188+
>
189+
pay-as-you-go
190+
</a>
191+
, first cancel your existing plan.
192+
</span>
193+
<Link className="mt-2" to={project.teamId ? "../billing" : "/plans"}>
194+
<button>Go to {project.teamId ? "Team" : "Personal"} Billing</button>
195+
</Link>
196+
</div>
197+
</Alert>
198+
)}
199+
</div>
166200
</ProjectSettingsPage>
167201
);
168202
}

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)