Skip to content

Commit

Permalink
[dashboard] Select default class if nothing is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Furisto authored and roboquat committed Jul 25, 2022
1 parent 8067081 commit c7c7c05
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions components/dashboard/src/service/service-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,15 @@ const gitpodServiceMock = createServiceMock({
displayName: "Standard",
description: "Up to 4 vCPU, 8GB memory, 30GB disk",
powerups: 1,
isDefault: true,
},
{
id: "g1-large",
category: "GENERAL PURPOSE",
displayName: "Large",
description: "Up to 8 vCPU, 16GB memory, 50GB disk",
powerups: 2,
isDefault: false,
},
];
},
Expand Down
6 changes: 5 additions & 1 deletion components/dashboard/src/settings/selectClass.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ export default function SelectWorkspaceClass(props: SelectWorkspaceClassProps) {
const fetchClasses = async () => {
const classes = await getGitpodService().server.getSupportedWorkspaceClasses();
setSupportedClasses(classes);

if (!workspaceClass) {
setWorkspaceClass(supportedClasses.find((c) => c.isDefault)?.id || "");
}
};

fetchClasses().catch(console.error);
}, []);
});

if (!props.enabled) {
return <div></div>;
Expand Down
1 change: 1 addition & 0 deletions components/gitpod-protocol/src/workspace-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export interface SupportedWorkspaceClass {
displayName: string;
description: string;
powerups: number;
isDefault: boolean;
}
1 change: 1 addition & 0 deletions components/server/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3052,6 +3052,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
displayName: c.displayName,
description: c.description,
powerups: c.powerups,
isDefault: c.isDefault,
}));

return classes;
Expand Down

0 comments on commit c7c7c05

Please sign in to comment.