From 12a32bd6e98a44140a669dd0dd582227af047c78 Mon Sep 17 00:00:00 2001 From: Victor Nogueira Date: Tue, 31 May 2022 12:12:37 +0300 Subject: [PATCH] Properly handle the workspace list when the workspace context ref is undefined --- .../gitpodprotocol/api/entities/WorkspaceContext.java | 6 ++++-- components/gitpod-protocol/src/protocol.ts | 1 + .../io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/gitpod-protocol/java/src/main/java/io/gitpod/gitpodprotocol/api/entities/WorkspaceContext.java b/components/gitpod-protocol/java/src/main/java/io/gitpod/gitpodprotocol/api/entities/WorkspaceContext.java index 96c62a6a7c2db9..c677eac117a56d 100644 --- a/components/gitpod-protocol/java/src/main/java/io/gitpod/gitpodprotocol/api/entities/WorkspaceContext.java +++ b/components/gitpod-protocol/java/src/main/java/io/gitpod/gitpodprotocol/api/entities/WorkspaceContext.java @@ -4,6 +4,8 @@ package io.gitpod.gitpodprotocol.api.entities; +import java.util.Optional; + public class WorkspaceContext { private String normalizedContextURL; private String ref; @@ -16,8 +18,8 @@ public void setNormalizedContextURL(String normalizedContextURL) { this.normalizedContextURL = normalizedContextURL; } - public String getRef() { - return ref; + public Optional getRef() { + return Optional.ofNullable(ref); } public void setRef(String ref) { diff --git a/components/gitpod-protocol/src/protocol.ts b/components/gitpod-protocol/src/protocol.ts index 46330aac848762..c443046e729dea 100644 --- a/components/gitpod-protocol/src/protocol.ts +++ b/components/gitpod-protocol/src/protocol.ts @@ -878,6 +878,7 @@ export namespace ExternalImageConfigFile { export interface WorkspaceContext { title: string; + ref?: string; /** This contains the URL portion of the contextURL (which might contain other modifiers as well). It's optional because it's not set for older workspaces. */ normalizedContextURL?: string; forceCreateNewWorkspace?: boolean; diff --git a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt index b1588010169ab5..e50b3430fe50ed 100644 --- a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt +++ b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt @@ -283,7 +283,11 @@ class GitpodWorkspacesView( it.totalUncommitedFiles + it.totalUntrackedFiles + it.totalUnpushedCommits } ?: 0 row { - label(info.workspace.context.ref) + if (info.workspace.context.ref.isPresent()) { + label(info.workspace.context.ref.get()) + } else { + label("(detached)") + } }.rowComment( when { changes == 1 -> "$changes Change"