File tree Expand file tree Collapse file tree 4 files changed +26
-11
lines changed
ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote Expand file tree Collapse file tree 4 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -10,21 +10,14 @@ import { Button } from "@podkit/buttons/Button";
1010import { Workspace } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb" ;
1111import { useUpdateWorkspaceMutation } from "../data/workspaces/update-workspace-mutation" ;
1212import { LoadingButton } from "@podkit/buttons/LoadingButton" ;
13+ import { Workspace as WorkspaceProtocol } from "@gitpod/gitpod-protocol" ;
1314
14- export const NAME_PREFIX = "named:" ;
1515export 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
2319export 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
3023type Props = {
Original file line number Diff line number Diff 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
771785export interface GuessGitTokenScopesParams {
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments