Skip to content

Commit 999ade3

Browse files
authored
[JetBrains] display workspace name on the navbar (#20544)
* [JetBrains] display workspace name on the remote navbar * Use workspace name
1 parent 9b574a9 commit 999ade3

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

components/dashboard/src/workspaces/RenameWorkspaceModal.tsx

Lines changed: 3 additions & 10 deletions
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

Lines changed: 14 additions & 0 deletions
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/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGatewayClientCustomizationProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class GitpodGatewayClientCustomizationProvider : GatewayClientCustomizationProvi
1717

1818
override val controlCenter: GatewayControlCenterProvider = object : GatewayControlCenterProvider {
1919
override fun getHostnameDisplayKind() = GatewayHostnameDisplayKind.ShowHostnameOnNavbar
20-
override fun getHostnameShort() = title
20+
override fun getHostnameShort() = System.getenv("GITPOD_WORKSPACE_NAME") ?: title
2121
override fun getHostnameLong() = title
2222
}
2323
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,14 @@ export class WorkspaceStarter {
15881588
sysEnvvars.push(isSetJavaXmx);
15891589
sysEnvvars.push(isSetJavaProcessorCount);
15901590
sysEnvvars.push(disableJetBrainsLocalPortForwarding);
1591+
1592+
const workspaceName = Workspace.fromWorkspaceName(workspace.description);
1593+
if (workspaceName && workspaceName.length > 0) {
1594+
const workspaceNameEnv = new EnvironmentVariable();
1595+
workspaceNameEnv.setName("GITPOD_WORKSPACE_NAME");
1596+
workspaceNameEnv.setValue(workspaceName);
1597+
sysEnvvars.push(workspaceNameEnv);
1598+
}
15911599
const spec = new StartWorkspaceSpec();
15921600
await createGitpodTokenPromise;
15931601
spec.setEnvvarsList(envvars);

0 commit comments

Comments
 (0)