Skip to content

Commit

Permalink
Show namespace name when there are DevWorkspaces from multiple OpenSh…
Browse files Browse the repository at this point in the history
…ift projects
  • Loading branch information
azatsarynnyy committed Jul 16, 2024
1 parent f9319d9 commit f657ff1
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class DevSpacesRemoteServerConnectionStepView(private var devSpacesContext: DevS
private var listDWDataModel = DefaultListModel<DevWorkspace>()
private var listDevWorkspaces = JBList(listDWDataModel)

// 'true' when there are DevWorkspaces come from multiple namespaces
private var multipleNamespaces = false

private lateinit var stopDevWorkspaceButton: JButton

override val component = panel {
Expand Down Expand Up @@ -125,17 +128,18 @@ class DevSpacesRemoteServerConnectionStepView(private var devSpacesContext: DevS

private fun doRefreshAllDevWorkspaces() {
val devWorkspaces = ArrayList<DevWorkspace>()
val projects = Projects(devSpacesContext.client).list()

multipleNamespaces = projects.size > 1

Projects(devSpacesContext.client)
.list()
projects
.onEach { project ->
(Utils.getValue(project, arrayOf("metadata", "name")) as String)
.also {
devWorkspaces.addAll(DevWorkspaces(devSpacesContext.client).list(it))
}
}


val selectedIndex = listDevWorkspaces.selectedIndex

listDWDataModel.apply {
Expand Down Expand Up @@ -257,8 +261,9 @@ class DevSpacesRemoteServerConnectionStepView(private var devSpacesContext: DevS
): Component {
return JBLabel(
String.format(
"[%s] %s",
"[%s] %s %s",
devWorkspace.status.phase,
if (!multipleNamespaces) "" else (devWorkspace.metadata.namespace + " /"),
devWorkspace.metadata.name
)
).also {
Expand All @@ -272,4 +277,4 @@ class DevSpacesRemoteServerConnectionStepView(private var devSpacesContext: DevS
refreshStopButton()
}
}
}
}

0 comments on commit f657ff1

Please sign in to comment.