Skip to content

Commit a96cb7b

Browse files
svenefftingeroboquat
authored andcommitted
[ws-classes] simplify workspace classes
simplified by - removing user-level setting - removing deprecation - removing ws-class inheritence between ws sessions
1 parent e5dd023 commit a96cb7b

File tree

15 files changed

+48
-658
lines changed

15 files changed

+48
-658
lines changed

components/dashboard/src/admin/ProjectDetail.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ export default function ProjectDetail(props: { project: Project; owner: string |
6363
<Property name="Incremental Prebuilds">
6464
{props.project.settings?.useIncrementalPrebuilds ? "Yes" : "No"}
6565
</Property>
66-
<Property name="Persistent Volume Claim">
67-
{props.project.settings?.usePersistentVolumeClaim ? "Yes" : "No"}
68-
</Property>
6966
<Property name="Marked Deleted">{props.project.markedDeleted ? "Yes" : "No"}</Property>
7067
</div>
7168
</div>

components/dashboard/src/service/service-mock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ const gitpodServiceMock = createServiceMock({
219219
displayName: "Standard",
220220
description: "Up to 4 vCPU, 8GB memory, 30GB disk",
221221
powerups: 1,
222-
isSelected: true,
222+
isDefault: true,
223223
},
224224
{
225225
id: "g1-large",
226226
category: "GENERAL PURPOSE",
227227
displayName: "Large",
228228
description: "Up to 8 vCPU, 16GB memory, 50GB disk",
229229
powerups: 2,
230-
isSelected: false,
230+
isDefault: false,
231231
},
232232
];
233233
},

components/dashboard/src/settings/Preferences.tsx

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ import { ThemeContext } from "../theme-context";
1111
import { UserContext } from "../user-context";
1212
import { trackEvent } from "../Analytics";
1313
import SelectIDE from "./SelectIDE";
14-
import SelectWorkspaceClass from "./selectClass";
1514
import { PageWithSettingsSubMenu } from "./PageWithSettingsSubMenu";
16-
import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode";
17-
import { WorkspaceClasses } from "@gitpod/gitpod-protocol";
1815

1916
type Theme = "light" | "dark" | "system";
2017

2118
export default function Preferences() {
22-
const { user, userBillingMode } = useContext(UserContext);
19+
const { user } = useContext(UserContext);
2320
const { setIsDark } = useContext(ThemeContext);
2421

2522
const [theme, setTheme] = useState<Theme>(localStorage.theme || "system");
@@ -50,30 +47,12 @@ export default function Preferences() {
5047
}
5148
};
5249

53-
const setWorkspaceClass = async (value: string) => {
54-
const additionalData = user?.additionalData || {};
55-
const prevWorkspaceClass = additionalData?.workspaceClasses?.regular;
56-
const workspaceClasses = (additionalData?.workspaceClasses || {}) as WorkspaceClasses;
57-
workspaceClasses.regular = value;
58-
workspaceClasses.prebuild = value;
59-
additionalData.workspaceClasses = workspaceClasses;
60-
if (value !== prevWorkspaceClass) {
61-
await getGitpodService().server.updateLoggedInUser({ additionalData });
62-
}
63-
return prevWorkspaceClass;
64-
};
65-
6650
return (
6751
<div>
6852
<PageWithSettingsSubMenu title="Preferences" subtitle="Configure user preferences.">
6953
<h3>Editor</h3>
7054
<p className="text-base text-gray-500 dark:text-gray-400">Choose the editor for opening workspaces.</p>
7155
<SelectIDE location="preferences" />
72-
<SelectWorkspaceClass
73-
workspaceClass={user?.additionalData?.workspaceClasses?.regular}
74-
enabled={BillingMode.canSetWorkspaceClass(userBillingMode)}
75-
setWorkspaceClass={setWorkspaceClass}
76-
/>
7756
<h3 className="mt-12">Theme</h3>
7857
<p className="text-base text-gray-500 dark:text-gray-400">Early bird or night owl? Choose your side.</p>
7958
<div className="mt-4 space-x-3 flex">

components/dashboard/src/settings/selectClass.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function SelectWorkspaceClass(props: SelectWorkspaceClassProps) {
3737
setSupportedClasses(classes);
3838

3939
if (!workspaceClass) {
40-
setWorkspaceClass(classes.find((c) => c.isSelected)?.id || "");
40+
setWorkspaceClass(classes.find((c) => c.isDefault)?.id || "");
4141
}
4242
};
4343

components/gitpod-protocol/src/teams-projects-protocol.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export interface ProjectConfig {
1515

1616
export interface ProjectSettings {
1717
useIncrementalPrebuilds?: boolean;
18-
usePersistentVolumeClaim?: boolean;
1918
keepOutdatedPrebuildsRunning?: boolean;
2019
// whether new workspaces can start on older prebuilds and incrementally update
2120
allowUsingPreviousPrebuilds?: boolean;

components/gitpod-protocol/src/workspace-class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export interface SupportedWorkspaceClass {
1010
displayName: string;
1111
description: string;
1212
powerups: number;
13-
isSelected: boolean;
13+
isDefault: boolean;
1414
}

components/server/src/config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import * as fs from "fs";
1616
import * as yaml from "js-yaml";
1717
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
1818
import { filePathTelepresenceAware } from "@gitpod/gitpod-protocol/lib/env";
19-
import { WorkspaceClasses, WorkspaceClassesConfig } from "./workspace/workspace-classes";
19+
import { WorkspaceClassesConfig } from "./workspace/workspace-classes";
2020
import { PrebuildRateLimiters } from "./workspace/prebuild-rate-limiter";
2121

2222
export const Config = Symbol("Config");
@@ -307,7 +307,12 @@ export namespace ConfigFile {
307307
}
308308
}
309309

310-
WorkspaceClasses.validate(config.workspaceClasses);
310+
if (config.workspaceClasses.filter((c) => c.isDefault).length !== 1) {
311+
log.error(
312+
"Exactly one default workspace class needs to be configured: " +
313+
JSON.stringify(config.workspaceClasses),
314+
);
315+
}
311316

312317
let patSigningKey = "";
313318
if (config.patSigningKeyFile) {

components/server/src/workspace/gitpod-server-impl.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ import { WorkspaceClusterImagebuilderClientProvider } from "./workspace-cluster-
174174
import { VerificationService } from "../auth/verification-service";
175175
import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode";
176176
import { EntitlementService } from "../billing/entitlement-service";
177-
import { WorkspaceClasses } from "./workspace-classes";
178177
import { formatPhoneNumber } from "../user/phone-numbers";
179178
import { IDEService } from "../ide-service";
180179
import { MessageBusIntegration } from "./messagebus-integration";
@@ -2947,25 +2946,15 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
29472946
}
29482947

29492948
async getSupportedWorkspaceClasses(ctx: TraceContext): Promise<SupportedWorkspaceClass[]> {
2950-
let user = this.checkAndBlockUser("getSupportedWorkspaceClasses");
2951-
let selectedClass = await WorkspaceClasses.getConfiguredOrUpgradeFromLegacy(
2952-
user,
2953-
undefined,
2954-
this.config.workspaceClasses,
2955-
this.entitlementService,
2956-
);
2957-
2958-
let classes = this.config.workspaceClasses
2959-
.filter((c) => !c.deprecated)
2960-
.map((c) => ({
2961-
id: c.id,
2962-
category: c.category,
2963-
displayName: c.displayName,
2964-
description: c.description,
2965-
powerups: c.powerups,
2966-
isSelected: selectedClass === c.id,
2967-
}));
2968-
2949+
this.checkAndBlockUser("getSupportedWorkspaceClasses");
2950+
const classes = this.config.workspaceClasses.map((c) => ({
2951+
id: c.id,
2952+
category: c.category,
2953+
displayName: c.displayName,
2954+
description: c.description,
2955+
powerups: c.powerups,
2956+
isDefault: c.isDefault,
2957+
}));
29692958
return classes;
29702959
}
29712960

components/server/src/workspace/workspace-classes.spec.ts

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)