Skip to content

Commit 1cccea4

Browse files
committed
Use workspace name
1 parent 20a18fa commit 1cccea4

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

components/dashboard/src/workspaces/RenameWorkspaceModal.tsx

+3-10
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,14 @@ import { Button } from "@podkit/buttons/Button";
1010
import { Workspace } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
1111
import { useUpdateWorkspaceMutation } from "../data/workspaces/update-workspace-mutation";
1212
import { LoadingButton } from "@podkit/buttons/LoadingButton";
13+
import { Workspace as WorkspaceProtocol } from "@gitpod/gitpod-protocol";
1314

14-
export const NAME_PREFIX = "named:";
1515
export function toWorkspaceName(name: string): string {
16-
// unsetting the name
17-
if (name.trim().length === 0) {
18-
return "no-name";
19-
}
20-
return `${NAME_PREFIX}${name}`;
16+
return WorkspaceProtocol.toWorkspaceName(name);
2117
}
2218

2319
export function fromWorkspaceName(workspace?: Workspace): string | undefined {
24-
if (workspace?.metadata?.name?.startsWith(NAME_PREFIX)) {
25-
return workspace.metadata.name.slice(NAME_PREFIX.length);
26-
}
27-
return undefined;
20+
return WorkspaceProtocol.fromWorkspaceName(workspace?.metadata?.name);
2821
}
2922

3023
type Props = {

components/gitpod-protocol/src/protocol.ts

+14
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,20 @@ export namespace Workspace {
766766
}
767767
return undefined;
768768
}
769+
770+
const NAME_PREFIX = "named:";
771+
export function fromWorkspaceName(name?: Workspace["description"]): string | undefined {
772+
if (name?.startsWith(NAME_PREFIX)) {
773+
return name.slice(NAME_PREFIX.length);
774+
}
775+
return undefined;
776+
}
777+
export function toWorkspaceName(name?: Workspace["description"]): string {
778+
if (!name || name?.trim().length === 0) {
779+
return "no-name";
780+
}
781+
return `${NAME_PREFIX}${name}`;
782+
}
769783
}
770784

771785
export interface GuessGitTokenScopesParams {

components/server/src/workspace/workspace-starter.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1587,10 +1587,12 @@ export class WorkspaceStarter {
15871587
sysEnvvars.push(isSetJavaXmx);
15881588
sysEnvvars.push(isSetJavaProcessorCount);
15891589
sysEnvvars.push(disableJetBrainsLocalPortForwarding);
1590-
if (workspace.context.title) {
1590+
1591+
const workspaceName = Workspace.fromWorkspaceName(workspace.description);
1592+
if (workspaceName && workspaceName.length > 0) {
15911593
const workspaceNameEnv = new EnvironmentVariable();
15921594
workspaceNameEnv.setName("GITPOD_WORKSPACE_NAME");
1593-
workspaceNameEnv.setValue(workspace.context.title);
1595+
workspaceNameEnv.setValue(workspaceName);
15941596
sysEnvvars.push(workspaceNameEnv);
15951597
}
15961598
const spec = new StartWorkspaceSpec();

0 commit comments

Comments
 (0)