Skip to content

Commit dbffbaf

Browse files
committed
[dashboard] Allow user to set workspace class
1 parent 5800e3c commit dbffbaf

File tree

5 files changed

+87
-5
lines changed

5 files changed

+87
-5
lines changed

components/dashboard/src/Analytics.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import Cookies from "js-cookie";
1010
import { v4 } from "uuid";
1111
import { Experiment } from "./experiments";
1212

13-
export type Event = "invite_url_requested" | "organisation_authorised" | "dotfile_repo_changed" | "feedback_submitted";
13+
export type Event =
14+
| "invite_url_requested"
15+
| "organisation_authorised"
16+
| "dotfile_repo_changed"
17+
| "feedback_submitted"
18+
| "workspace_class_changed";
1419
type InternalEvent = Event | "path_changed" | "dashboard_clicked";
1520

1621
export type EventProperties = TrackOrgAuthorised | TrackInviteUrlRequested | TrackDotfileRepo | TrackFeedback;

components/dashboard/src/settings/Preferences.tsx

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import getSettingsMenu from "./settings-menu";
1414
import { trackEvent } from "../Analytics";
1515
import { PaymentContext } from "../payment-context";
1616
import SelectIDE from "./SelectIDE";
17+
import { WorkspaceClasses } from "@gitpod/gitpod-protocol";
1718

1819
type Theme = "light" | "dark" | "system";
20+
type WorkspaceClass = "standard" | "XL";
1921

2022
export default function Preferences() {
2123
const { user } = useContext(UserContext);
@@ -50,6 +52,26 @@ export default function Preferences() {
5052
}
5153
};
5254

55+
const [workspaceClass, setWorkspaceClass] = useState<WorkspaceClass>(
56+
user?.additionalData?.workspaceClasses?.regular || "standard",
57+
);
58+
const actuallySetWorkspaceClass = async (value: string) => {
59+
const additionalData = user?.additionalData || {};
60+
const prevWorkspaceClass = additionalData?.workspaceClasses?.regular || "standard";
61+
const workspaceClasses = (additionalData?.workspaceClasses || {}) as WorkspaceClasses;
62+
workspaceClasses.regular = value;
63+
workspaceClasses.prebuild = value;
64+
additionalData.workspaceClasses = workspaceClasses;
65+
if (value !== prevWorkspaceClass) {
66+
await getGitpodService().server.updateLoggedInUser({ additionalData });
67+
trackEvent("workspace_class_changed", {
68+
previous: prevWorkspaceClass,
69+
current: value,
70+
});
71+
setWorkspaceClass(value);
72+
}
73+
};
74+
5375
return (
5476
<div>
5577
<PageWithSubMenu
@@ -115,9 +137,7 @@ export default function Preferences() {
115137
</SelectableCardSolid>
116138
</div>
117139

118-
<h3 className="mt-12">
119-
Dotfiles{" "}
120-
</h3>
140+
<h3 className="mt-12">Dotfiles </h3>
121141
<p className="text-base text-gray-500 dark:text-gray-400">Customize workspaces using dotfiles.</p>
122142
<div className="mt-4 max-w-xl">
123143
<h4>Repository URL</h4>
@@ -141,6 +161,48 @@ export default function Preferences() {
141161
</p>
142162
</div>
143163
</div>
164+
165+
<h3 className="mt-12">Workspaces</h3>
166+
<p className="text-base text-gray-500 dark:text-gray-400">
167+
Choose the workspace machine type for your workspaces.
168+
</p>
169+
<div className="mt-4 space-x-3 flex">
170+
<SelectableCardSolid
171+
className="w-36 h-32"
172+
title="Standard"
173+
selected={workspaceClass === "standard"}
174+
onClick={() => actuallySetWorkspaceClass("standard")}
175+
>
176+
<div className="flex-grow flex items-end p-1">
177+
<svg width="112" height="64" fill="none" xmlns="http://www.w3.org/2000/svg">
178+
<path
179+
d="M0 8a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8ZM0 32a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8ZM0 56a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8ZM40 6a6 6 0 0 1 6-6h60a6 6 0 0 1 6 6v28a6 6 0 0 1-6 6H46a6 6 0 0 1-6-6V6Z"
180+
fill="#D6D3D1"
181+
/>
182+
</svg>
183+
</div>
184+
</SelectableCardSolid>
185+
<SelectableCardSolid
186+
className="w-36 h-32"
187+
title="XL"
188+
selected={workspaceClass === "XL"}
189+
onClick={() => actuallySetWorkspaceClass("XL")}
190+
>
191+
<div className="flex-grow flex items-end p-1">
192+
<svg width="112" height="64" fill="none" xmlns="http://www.w3.org/2000/svg">
193+
<path
194+
d="M0 8a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8ZM40 6a6 6 0 0 1 6-6h60a6 6 0 0 1 6 6v28a6 6 0 0 1-6 6H46a6 6 0 0 1-6-6V6Z"
195+
fill="#D9D9D9"
196+
/>
197+
<path
198+
d="M84 0h22a6 6 0 0 1 6 6v28a6 6 0 0 1-6 6H68L84 0ZM0 32a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8Z"
199+
fill="#78716C"
200+
/>
201+
<path d="M0 56a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8Z" fill="#D9D9D9" />
202+
</svg>
203+
</div>
204+
</SelectableCardSolid>
205+
</div>
144206
</PageWithSubMenu>
145207
</div>
146208
);

components/ee/payment-endpoint/src/accounting/account-service.spec.db.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ const end = new Date(Date.UTC(2000, 2, 1)).toISOString();
7777
emailNotificationSettings: {
7878
allowsChangelogMail: true,
7979
allowsDevXMail: true
80-
}
80+
},
81+
workspaceClasses: {
82+
regular: "default",
83+
prebuild: "default,"
84+
},
8185
}
8286
});
8387
await this.workspaceDb.store({

components/gitpod-db/src/typeorm/user-db-impl.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ export class TypeORMUserDBImpl implements UserDB {
109109
allowsDevXMail: true,
110110
allowsOnboardingMail: true,
111111
},
112+
workspaceClasses: {
113+
regular: "default",
114+
prebuild: "default",
115+
},
112116
},
113117
};
114118
await this.storeUser(user);

components/gitpod-protocol/src/protocol.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ export interface AdditionalUserData {
154154
dotfileRepo?: string;
155155
// Identifies an explicit team or user ID to which all the user's workspace usage should be attributed to (e.g. for billing purposes)
156156
usageAttributionId?: string;
157+
// preferred workspace classes
158+
workspaceClasses?: WorkspaceClasses;
157159
}
158160

159161
export interface EmailNotificationSettings {
@@ -172,6 +174,11 @@ export type IDESettings = {
172174
useLatestVersion?: boolean;
173175
};
174176

177+
export interface WorkspaceClasses {
178+
regular: string;
179+
prebuild: string;
180+
}
181+
175182
export interface UserPlatform {
176183
uid: string;
177184
userAgent: string;

0 commit comments

Comments
 (0)