Skip to content

Commit 853b9e7

Browse files
felladrinroboquat
authored andcommitted
Refactor 'normalizedContextURL' from WorkspaceContext as Optional
Because it can come null from the server, as you can see on interface WorkspaceContext from `components/gitpod-protocol/src/protocol.ts`.
1 parent 8553668 commit 853b9e7

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

components/gitpod-protocol/java/src/main/java/io/gitpod/gitpodprotocol/api/entities/WorkspaceContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public class WorkspaceContext {
1010
private String normalizedContextURL;
1111
private String ref;
1212

13-
public String getNormalizedContextURL() {
14-
return normalizedContextURL;
13+
public Optional<String> getNormalizedContextURL() {
14+
return Optional.ofNullable(normalizedContextURL);
1515
}
1616

1717
public void setNormalizedContextURL(String normalizedContextURL) {

components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionProvider.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,9 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
124124
}
125125
}
126126
row {
127-
browserLink(
128-
workspace.context.normalizedContextURL,
129-
workspace.context.normalizedContextURL
130-
)
127+
workspace.context.normalizedContextURL.ifPresent {
128+
browserLink(it, it)
129+
}
131130
}
132131
}.horizontalAlign(HorizontalAlign.CENTER)
133132
row {

components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,12 @@ class GitpodWorkspacesView(
272272
}
273273
).gap(RightGap.SMALL)
274274
panel {
275-
row {
275+
val contextUrlRow = row {
276276
browserLink(info.workspace.id, info.latestInstance.ideUrl)
277-
}.rowComment("<a href='${info.workspace.context.normalizedContextURL}'>${info.workspace.context.normalizedContextURL}</a>")
277+
}
278+
info.workspace.context.normalizedContextURL.ifPresent {
279+
contextUrlRow.rowComment("<a href='${it}'>${it}</a>")
280+
}
278281
}
279282
label("").resizableColumn().horizontalAlign(HorizontalAlign.FILL)
280283
panel {
@@ -283,11 +286,7 @@ class GitpodWorkspacesView(
283286
it.totalUncommitedFiles + it.totalUntrackedFiles + it.totalUnpushedCommits
284287
} ?: 0
285288
row {
286-
if (info.workspace.context.ref.isPresent()) {
287-
label(info.workspace.context.ref.get())
288-
} else {
289-
label("(detached)")
290-
}
289+
info.workspace.context.ref.ifPresentOrElse({ label(it) },{ label("(detached)") })
291290
}.rowComment(
292291
when {
293292
changes == 1 -> "<b>$changes Change</b>"
@@ -345,4 +344,4 @@ class GitpodWorkspacesView(
345344
}
346345
updateLifetime.onTerminationOrNow { job.cancel() }
347346
}
348-
}
347+
}

0 commit comments

Comments
 (0)