Skip to content

Commit 3a395e2

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

File tree

5 files changed

+69
-5
lines changed

5 files changed

+69
-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: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ 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";
1920

@@ -50,6 +51,25 @@ export default function Preferences() {
5051
}
5152
};
5253

54+
const [workspaceClass, setWorkspaceClass] = useState<string>(
55+
user?.additionalData?.workspaceClasses?.regular || "default",
56+
);
57+
const actuallySetWorkspaceClass = async (value: string) => {
58+
const additionalData = user?.additionalData || {};
59+
const prevWorkspaceClass = additionalData?.workspaceClasses?.regular || "";
60+
const workspaceClasses = (additionalData?.workspaceClasses || {}) as WorkspaceClasses;
61+
workspaceClasses.regular = value;
62+
workspaceClasses.prebuild = value;
63+
additionalData.workspaceClasses = workspaceClasses;
64+
await getGitpodService().server.updateLoggedInUser({ additionalData });
65+
if (value !== prevWorkspaceClass) {
66+
trackEvent("workspace_class_changed", {
67+
previous: prevWorkspaceClass,
68+
current: value,
69+
});
70+
}
71+
};
72+
5373
return (
5474
<div>
5575
<PageWithSubMenu
@@ -115,9 +135,7 @@ export default function Preferences() {
115135
</SelectableCardSolid>
116136
</div>
117137

118-
<h3 className="mt-12">
119-
Dotfiles{" "}
120-
</h3>
138+
<h3 className="mt-12">Dotfiles </h3>
121139
<p className="text-base text-gray-500 dark:text-gray-400">Customize workspaces using dotfiles.</p>
122140
<div className="mt-4 max-w-xl">
123141
<h4>Repository URL</h4>
@@ -141,6 +159,31 @@ export default function Preferences() {
141159
</p>
142160
</div>
143161
</div>
162+
163+
<h3 className="mt-12">Workspace Classes </h3>
164+
<p className="text-base text-gray-500 dark:text-gray-400">Set default workspace classes</p>
165+
<div className="mt-4 max-w-xl">
166+
<h4>Workspace class</h4>
167+
<span className="flex">
168+
<input
169+
type="text"
170+
value={workspaceClass}
171+
className="w-96 h-9"
172+
placeholder="e.g. XL"
173+
onChange={(e) => setWorkspaceClass(e.target.value)}
174+
/>
175+
<button className="secondary ml-2" onClick={() => actuallySetWorkspaceClass(dotfileRepo)}>
176+
Save Changes
177+
</button>
178+
</span>
179+
<div className="mt-1">
180+
<p className="text-gray-500 dark:text-gray-400">
181+
Add a repository URL that includes dotfiles. Gitpod will
182+
<br />
183+
clone and install your dotfiles for every new workspace.
184+
</p>
185+
</div>
186+
</div>
144187
</PageWithSubMenu>
145188
</div>
146189
);

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ 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+
158+
// preferred workspace classes
159+
workspaceClasses?: WorkspaceClasses;
157160
}
158161

159162
export interface EmailNotificationSettings {
@@ -172,6 +175,11 @@ export type IDESettings = {
172175
useLatestVersion?: boolean;
173176
};
174177

178+
export interface WorkspaceClasses {
179+
regular: string;
180+
prebuild: string;
181+
}
182+
175183
export interface UserPlatform {
176184
uid: string;
177185
userAgent: string;

0 commit comments

Comments
 (0)