Skip to content

Commit ec732e5

Browse files
committed
Fix build
1 parent 23f7b14 commit ec732e5

18 files changed

+924
-646
lines changed

components/dashboard/src/data/workspaces/toggle-workspace-pinned-mutation.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
88
import { getGitpodService } from "../../service/service";
99
import { getListWorkspacesQueryKey, ListWorkspacesQueryResult } from "./list-workspaces-query";
1010
import { useCurrentOrg } from "../organizations/orgs-query";
11-
import { Workspace } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
11+
import { Workspace, WorkspaceMetadata } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
1212

1313
type ToggleWorkspacePinnedArgs = {
1414
workspaceId: string;
@@ -33,7 +33,10 @@ export const useToggleWorkspacedPinnedMutation = () => {
3333
return info;
3434
}
3535
const workspace = new Workspace(info);
36-
workspace.pinned = !workspace.pinned;
36+
if (!workspace.metadata) {
37+
workspace.metadata = new WorkspaceMetadata();
38+
}
39+
workspace.metadata.pinned = !workspace.metadata.pinned;
3740
return workspace;
3841
});
3942
});

components/dashboard/src/data/workspaces/toggle-workspace-shared-mutation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
88
import { getGitpodService } from "../../service/service";
99
import { getListWorkspacesQueryKey, ListWorkspacesQueryResult } from "./list-workspaces-query";
1010
import { useCurrentOrg } from "../organizations/orgs-query";
11-
import { AdmissionLevel, Workspace } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
11+
import { AdmissionLevel, Workspace, WorkspaceSpec } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
1212

1313
type ToggleWorkspaceSharedArgs = {
1414
workspaceId: string;
@@ -44,9 +44,10 @@ export const useToggleWorkspaceSharedMutation = () => {
4444
}
4545

4646
const workspace = new Workspace(info);
47-
if (workspace.status) {
48-
workspace.status.admission = level;
47+
if (!workspace.spec) {
48+
workspace.spec = new WorkspaceSpec();
4949
}
50+
workspace.spec.admission = level;
5051
return workspace;
5152
});
5253
});

components/dashboard/src/data/workspaces/update-workspace-description-mutation.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
88
import { getGitpodService } from "../../service/service";
99
import { getListWorkspacesQueryKey, ListWorkspacesQueryResult } from "./list-workspaces-query";
1010
import { useCurrentOrg } from "../organizations/orgs-query";
11-
import { Workspace } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
11+
import { Workspace, WorkspaceMetadata } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
1212

1313
type UpdateWorkspaceDescriptionArgs = {
1414
workspaceId: string;
@@ -36,7 +36,10 @@ export const useUpdateWorkspaceDescriptionMutation = () => {
3636
// TODO: Once the update description response includes an updated record,
3737
// we can return that instead of having to know what to merge manually (same for other mutations)
3838
const workspace = new Workspace(info);
39-
workspace.name = newDescription;
39+
if (!workspace.metadata) {
40+
workspace.metadata = new WorkspaceMetadata();
41+
}
42+
workspace.metadata.name = newDescription;
4043
return workspace;
4144
});
4245
});

components/dashboard/src/service/json-rpc-workspace-client.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import {
1818
WatchWorkspaceStatusResponse,
1919
ListWorkspacesRequest,
2020
ListWorkspacesResponse,
21+
ParseContextURLRequest,
22+
ParseContextURLResponse,
23+
UpdateWorkspaceRequest,
24+
UpdateWorkspaceResponse,
2125
} from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
2226
import { converter } from "./public-api";
2327
import { getGitpodService } from "./service";
@@ -121,22 +125,25 @@ export class JsonRpcWorkspaceClient implements PromiseClient<typeof WorkspaceSer
121125
if (request.source?.case !== "contextUrl") {
122126
throw new ApplicationError(ErrorCodes.UNIMPLEMENTED, "not implemented");
123127
}
124-
if (!request.organizationId || !uuidValidate(request.organizationId)) {
128+
if (!request.metadata || !request.metadata.organizationId || !uuidValidate(request.metadata.organizationId)) {
125129
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "organizationId is required");
126130
}
127131
if (!request.editor) {
128132
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "editor is required");
129133
}
130-
if (!request.source.value) {
134+
if (request.source.case !== "contextUrl") {
135+
throw new ApplicationError(ErrorCodes.UNIMPLEMENTED, "not implemented");
136+
}
137+
if (!request.source.value.url) {
131138
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "source is required");
132139
}
133140
const response = await getGitpodService().server.createWorkspace({
134-
organizationId: request.organizationId,
141+
organizationId: request.metadata.organizationId,
135142
ignoreRunningWorkspaceOnSameCommit: true,
136-
contextUrl: request.source.value,
143+
contextUrl: request.source.value.url,
137144
forceDefaultConfig: request.forceDefaultConfig,
138-
workspaceClass: request.workspaceClass,
139-
projectId: request.configurationId,
145+
workspaceClass: request.source.value.workspaceClass,
146+
projectId: request.metadata.configurationId,
140147
ideSettings: {
141148
defaultIde: request.editor.name,
142149
useLatestVersion: request.editor.version === "latest",
@@ -160,4 +167,18 @@ export class JsonRpcWorkspaceClient implements PromiseClient<typeof WorkspaceSer
160167
result.workspace = workspace.workspace;
161168
return result;
162169
}
170+
171+
async updateWorkspace(
172+
request: PartialMessage<UpdateWorkspaceRequest>,
173+
_options?: CallOptions | undefined,
174+
): Promise<UpdateWorkspaceResponse> {
175+
throw new ApplicationError(ErrorCodes.UNIMPLEMENTED, "not implemented");
176+
}
177+
178+
async parseContextURL(
179+
request: PartialMessage<ParseContextURLRequest>,
180+
_options?: CallOptions | undefined,
181+
): Promise<ParseContextURLResponse> {
182+
throw new ApplicationError(ErrorCodes.UNIMPLEMENTED, "not implemented");
183+
}
163184
}

components/dashboard/src/start/StartWorkspace.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ import Alert from "../components/Alert";
2222
import { workspaceClient, workspacesService } from "../service/public-api";
2323
import { watchWorkspaceStatus } from "../data/workspaces/listen-to-workspace-ws-messages";
2424
import { Button } from "@podkit/buttons/Button";
25-
import { GetWorkspaceRequest, StartWorkspaceRequest, StartWorkspaceResponse, Workspace, WorkspacePhase_Phase } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
25+
import {
26+
GetWorkspaceRequest,
27+
StartWorkspaceRequest,
28+
StartWorkspaceResponse,
29+
Workspace,
30+
WorkspacePhase_Phase,
31+
WorkspaceSpec_WorkspaceType,
32+
} from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
2633
import { PartialMessage } from "@bufbuild/protobuf";
2734

2835
const sessionId = v4();
@@ -163,7 +170,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
163170
componentDidUpdate(prevPros: StartWorkspaceProps, prevState: StartWorkspaceState) {
164171
const newPhase = this.state?.workspace?.status?.phase?.name;
165172
const oldPhase = prevState.workspace?.status?.phase?.name;
166-
const type = !!this.state.workspace?.prebuild ? "prebuild" : "regular";
173+
const type = this.state.workspace?.spec?.type === WorkspaceSpec_WorkspaceType.PREBUILD ? "prebuild" : "regular";
167174
if (newPhase !== oldPhase) {
168175
getGitpodService().server.trackEvent({
169176
event: "status_rendered",
@@ -367,10 +374,10 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
367374
if (
368375
!error &&
369376
workspace.status.phase?.name === WorkspacePhase_Phase.STOPPED &&
370-
!!this.state.workspace?.prebuild
377+
this.state.workspace?.spec?.type === WorkspaceSpec_WorkspaceType.PREBUILD
371378
) {
372379
// here we want to point to the original context, w/o any modifiers "workspace" was started with (as this might have been a manually triggered prebuild!)
373-
const contextURL = this.state.workspace.contextUrl;
380+
const contextURL = this.state.workspace.metadata?.originalContextUrl;
374381
if (contextURL) {
375382
this.redirectTo(gitpodHostUrl.withContext(contextURL.toString()).toString());
376383
} else {
@@ -451,15 +458,20 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
451458

452459
render() {
453460
const { error } = this.state;
454-
const isPrebuild = this.state.workspace?.prebuild;
455-
const withPrebuild = !!this.state.workspace?.prebuildId;
461+
const isPrebuild = this.state.workspace?.spec?.type === WorkspaceSpec_WorkspaceType.PREBUILD;
462+
let withPrebuild = false;
463+
for (const initializer of this.state.workspace?.spec?.initializer?.specs ?? []) {
464+
if (initializer.spec.case === "prebuild") {
465+
withPrebuild = !!initializer.spec.value.prebuildId;
466+
}
467+
}
456468
let phase: StartPhase | undefined = StartPhase.Preparing;
457469
let title = undefined;
458470
let isStoppingOrStoppedPhase = false;
459471
let isError = error ? true : false;
460472
let statusMessage = !!error ? undefined : <p className="text-base text-gray-400">Preparing workspace …</p>;
461-
const contextURL = this.state.workspace?.contextUrl;
462-
const useLatest = this.state.workspace?.editor?.version === "latest";
473+
const contextURL = this.state.workspace?.metadata?.originalContextUrl;
474+
const useLatest = this.state.workspace?.spec?.editor?.version === "latest";
463475

464476
switch (this.state?.workspace?.status?.phase?.name) {
465477
// unknown indicates an issue within the system in that it cannot determine the actual phase of

components/dashboard/src/workspaces/CreateWorkspacePage.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { SelectAccountModal } from "../user-settings/SelectAccountModal";
3737
import { settingsPathIntegrations } from "../user-settings/settings.routes";
3838
import { WorkspaceEntry } from "./WorkspaceEntry";
3939
import { AuthProviderType } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb";
40-
import { WorkspacePhase_Phase } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
40+
import { WorkspaceMetadata, WorkspacePhase_Phase } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
4141
import { Button } from "@podkit/buttons/Button";
4242
import { LoadingButton } from "@podkit/buttons/LoadingButton";
4343
import { CreateAndStartWorkspaceRequest } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
@@ -172,7 +172,14 @@ export function CreateWorkspacePage() {
172172
const [selectAccountError, setSelectAccountError] = useState<SelectAccountPayload | undefined>(undefined);
173173

174174
const createWorkspace = useCallback(
175-
async (options?: Omit<PartialMessage<CreateAndStartWorkspaceRequest>, "contextUrl" | "organizationId">) => {
175+
/**
176+
* options will omit
177+
* - source.url
178+
* - source.workspaceClass
179+
* - metadata.organizationId
180+
* - metadata.configurationId
181+
*/
182+
async (options?: PartialMessage<CreateAndStartWorkspaceRequest>) => {
176183
// add options from search params
177184
const opts = options || {};
178185

@@ -192,9 +199,6 @@ export function CreateWorkspacePage() {
192199
opts.forceDefaultConfig = true;
193200
}
194201

195-
if (!opts.workspaceClass) {
196-
opts.workspaceClass = selectedWsClass;
197-
}
198202
if (!opts.editor) {
199203
opts.editor = {
200204
name: selectedIde,
@@ -210,14 +214,21 @@ export function CreateWorkspacePage() {
210214
// we wait at least 5 secs
211215
const timeout = new Promise((resolve) => setTimeout(resolve, 5000));
212216

217+
if (!opts.metadata) {
218+
opts.metadata = new WorkspaceMetadata();
219+
}
220+
opts.metadata.organizationId = organizationId;
221+
opts.metadata.configurationId = selectedProjectID;
222+
213223
const result = await createWorkspaceMutation.createWorkspace({
214224
source: {
215225
case: "contextUrl",
216-
value: contextURL,
226+
value: {
227+
url: contextURL,
228+
workspaceClass: selectedWsClass,
229+
},
217230
},
218231
...opts,
219-
organizationId,
220-
configurationId: selectedProjectID,
221232
});
222233
await storeAutoStartOptions();
223234
await timeout;

components/dashboard/src/workspaces/DeleteWorkspaceModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const DeleteWorkspaceModal: FunctionComponent<Props> = ({ workspace, onCl
3333
areYouSureText="Are you sure you want to delete this workspace?"
3434
children={{
3535
name: workspace.id,
36-
description: workspace.name,
36+
description: workspace.metadata?.name,
3737
}}
3838
buttonText="Delete Workspace"
3939
warningText={deleteWorkspace.isError ? "There was a problem deleting your workspace." : undefined}

components/dashboard/src/workspaces/RenameWorkspaceModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Props = {
1616
};
1717
export const RenameWorkspaceModal: FunctionComponent<Props> = ({ workspace, onClose }) => {
1818
const [errorMessage, setErrorMessage] = useState("");
19-
const [description, setDescription] = useState(workspace.name || "");
19+
const [description, setDescription] = useState(workspace.metadata?.name || "");
2020
const updateDescription = useUpdateWorkspaceDescriptionMutation();
2121

2222
const updateWorkspaceDescription = useCallback(async () => {

components/dashboard/src/workspaces/WorkspaceEntry.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export const WorkspaceEntry: FunctionComponent<Props> = ({ info, shortVersion })
2727
const workspace = info;
2828
const currentBranch = gitStatus?.branch || "<unknown>";
2929
const project = getProjectPath(workspace);
30-
const normalizedContextUrl = workspace.contextUrl;
31-
const normalizedContextUrlDescription = workspace.contextUrl; // Instead of showing nothing, we prefer to show the raw content instead
30+
const normalizedContextUrl = workspace.metadata!.originalContextUrl;
31+
const normalizedContextUrlDescription = workspace.metadata!.originalContextUrl; // Instead of showing nothing, we prefer to show the raw content instead
3232

3333
const changeMenuState = (state: boolean) => {
3434
setMenuActive(state);
@@ -69,7 +69,7 @@ export const WorkspaceEntry: FunctionComponent<Props> = ({ info, shortVersion })
6969
<>
7070
<ItemField className="w-4/12 flex flex-col my-auto">
7171
<div className="text-gray-500 dark:text-gray-400 overflow-ellipsis truncate">
72-
{workspace.name}
72+
{workspace.metadata!.name}
7373
</div>
7474
<a href={normalizedContextUrl}>
7575
<div className="text-sm text-gray-400 dark:text-gray-500 overflow-ellipsis truncate hover:text-blue-600 dark:hover:text-blue-400">
@@ -105,5 +105,5 @@ export const WorkspaceEntry: FunctionComponent<Props> = ({ info, shortVersion })
105105

106106
export function getProjectPath(ws: Workspace) {
107107
// TODO: Remove and call papi ContextService
108-
return ws.contextUrl.replace("https://", "");
108+
return ws.metadata!.originalContextUrl.replace("https://", "");
109109
}

components/dashboard/src/workspaces/WorkspaceOverflowMenu.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,13 @@ export const WorkspaceEntryOverflowMenu: FunctionComponent<WorkspaceEntryOverflo
6060

6161
const toggleShared = useCallback(() => {
6262
const newLevel =
63-
workspace.status?.admission === AdmissionLevel.EVERYONE
64-
? AdmissionLevel.OWNER_ONLY
65-
: AdmissionLevel.EVERYONE;
63+
workspace.spec?.admission === AdmissionLevel.EVERYONE ? AdmissionLevel.OWNER_ONLY : AdmissionLevel.EVERYONE;
6664

6765
toggleWorkspaceShared.mutate({
6866
workspaceId: workspace.id,
6967
level: newLevel,
7068
});
71-
}, [toggleWorkspaceShared, workspace.id, workspace.status?.admission]);
69+
}, [toggleWorkspaceShared, workspace.id, workspace.spec?.admission]);
7270

7371
const togglePinned = useCallback(() => {
7472
toggleWorkspacePinned.mutate({
@@ -129,12 +127,12 @@ export const WorkspaceEntryOverflowMenu: FunctionComponent<WorkspaceEntryOverflo
129127
menuEntries.push(
130128
{
131129
title: "Share",
132-
active: workspace.status?.admission === AdmissionLevel.EVERYONE,
130+
active: workspace.spec?.admission === AdmissionLevel.EVERYONE,
133131
onClick: toggleShared,
134132
},
135133
{
136134
title: "Pin",
137-
active: !!workspace.pinned,
135+
active: !!workspace.metadata?.pinned,
138136
separator: true,
139137
onClick: togglePinned,
140138
},

components/dashboard/src/workspaces/Workspaces.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,18 @@ const WorkspacesPage: FunctionComponent = () => {
4747
const { filteredActiveWorkspaces, filteredInactiveWorkspaces } = useMemo(() => {
4848
const filteredActiveWorkspaces = activeWorkspaces.filter(
4949
(info) =>
50-
`${info.name}${info.id}${info.contextUrl}${info.status?.gitStatus?.cloneUrl}${info.status?.gitStatus?.branch}`
50+
`${info.metadata!.name}${info.id}${info.metadata!.originalContextUrl}${
51+
info.status?.gitStatus?.cloneUrl
52+
}${info.status?.gitStatus?.branch}`
5153
.toLowerCase()
5254
.indexOf(searchTerm.toLowerCase()) !== -1,
5355
);
5456

5557
const filteredInactiveWorkspaces = inactiveWorkspaces.filter(
5658
(info) =>
57-
`${info.name}${info.id}${info.contextUrl}${info.status?.gitStatus?.cloneUrl}${info.status?.gitStatus?.branch}`
59+
`${info.metadata!.name}${info.id}${info.metadata!.originalContextUrl}${
60+
info.status?.gitStatus?.cloneUrl
61+
}${info.status?.gitStatus?.branch}`
5862
.toLowerCase()
5963
.indexOf(searchTerm.toLowerCase()) !== -1,
6064
);
@@ -201,5 +205,5 @@ function isWorkspaceActive(info: Workspace): boolean {
201205
const twentyfourHoursAgo = hoursBefore(new Date().toISOString(), 24);
202206

203207
const isStopped = info.status?.phase?.name === WorkspacePhase_Phase.STOPPED;
204-
return info.pinned || !isStopped || isDateSmallerOrEqual(twentyfourHoursAgo, lastSessionStart);
208+
return info.metadata!.pinned || !isStopped || isDateSmallerOrEqual(twentyfourHoursAgo, lastSessionStart);
205209
}

components/public-api/gitpod/v1/workspace.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ message WorkspaceSpec {
249249
// log_url is the URL where we stream the workspace's logs to.
250250
// Can be changed when the workspace is PENDING or STOPPED.
251251
string log_url = 12;
252+
253+
EditorReference editor = 13;
252254
}
253255

254256
// WorkspaceStatus describes a workspace status

0 commit comments

Comments
 (0)