Skip to content

Commit ec3aa78

Browse files
yaohui-wyhfelladrin
authored andcommitted
[jb-gw]: disable new workspace button when url is blank
Co-authored-by: Victor Nogueira <felladrin@gmail.com>
1 parent 74af645 commit ec3aa78

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.intellij.ui.dsl.builder.TopGap
1515
import com.intellij.ui.dsl.builder.panel
1616
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
1717
import com.intellij.ui.layout.ComponentPredicate
18+
import com.intellij.ui.layout.enteredTextSatisfies
1819
import com.intellij.util.EventDispatcher
1920
import com.jetbrains.rd.util.concurrentMapOf
2021
import com.jetbrains.rd.util.lifetime.Lifetime
@@ -72,20 +73,14 @@ class GitpodStartWorkspaceView(
7273
this.text = "https://github.com/gitpod-io/spring-petclinic"
7374
}
7475
button("New Workspace") {
75-
// TODO(ak) disable button if blank
7676
if (contextUrl.component.text.isNotBlank()) {
77-
val backend = backendsModel.selectedItem
78-
val selectedBackendId = if (backend != null) {
79-
backendToId[backend]
80-
} else null
81-
val backendParam = if (selectedBackendId != null) {
82-
":$selectedBackendId"
83-
} else {
84-
""
77+
backendsModel.selectedItem?.let {
78+
backendToId[it]?.let { backend ->
79+
BrowserUtil.browse("https://${settings.gitpodHost}#referrer:jetbrains-gateway:${backend}/${contextUrl.component.text}")
80+
}
8581
}
86-
BrowserUtil.browse("https://${settings.gitpodHost}#referrer:jetbrains-gateway$backendParam/${contextUrl.component.text}")
8782
}
88-
}
83+
}.enabledIf(contextUrl.component.enteredTextSatisfies { it.isNotBlank() })
8984
cell()
9085
}.topGap(TopGap.NONE)
9186
.rowComment(

0 commit comments

Comments
 (0)