diff --git a/CHANGELOG.md b/CHANGELOG.md index 6867b6f..0bb2520 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,4 +5,5 @@ ### Added - initial support for JetBrains Toolbox 2.6.0.38311 with the possibility to manage the workspaces - i.e. start, stop, - update and delete actions and also quick shortcuts to templates, web terminal and dashboard. \ No newline at end of file + update and delete actions and also quick shortcuts to templates, web terminal and dashboard. +- support for light & dark themes \ No newline at end of file diff --git a/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt b/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt index 82256be..d9e7d95 100644 --- a/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt +++ b/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt @@ -45,44 +45,59 @@ class CoderRemoteEnvironment( override val actionsList: MutableStateFlow> = MutableStateFlow(getAvailableActions()) - private fun getAvailableActions(): List = listOf( - Action(context.i18n.ptrl("Open web terminal")) { - context.cs.launch { - BrowserUtil.browse(client.url.withPath("/${workspace.ownerName}/$name/terminal").toString()) { - context.ui.showErrorInfoPopup(it) + private fun getAvailableActions(): List { + val actions = mutableListOf( + Action(context.i18n.ptrl("Open web terminal")) { + context.cs.launch { + BrowserUtil.browse(client.url.withPath("/${workspace.ownerName}/$name/terminal").toString()) { + context.ui.showErrorInfoPopup(it) + } } - } - }, - Action(context.i18n.ptrl("Open in dashboard")) { - context.cs.launch { - BrowserUtil.browse(client.url.withPath("/@${workspace.ownerName}/${workspace.name}").toString()) { - context.ui.showErrorInfoPopup(it) + }, + Action(context.i18n.ptrl("Open in dashboard")) { + context.cs.launch { + BrowserUtil.browse(client.url.withPath("/@${workspace.ownerName}/${workspace.name}").toString()) { + context.ui.showErrorInfoPopup(it) + } } - } - }, + }, - Action(context.i18n.ptrl("View template")) { - context.cs.launch { - BrowserUtil.browse(client.url.withPath("/templates/${workspace.templateName}").toString()) { - context.ui.showErrorInfoPopup(it) + Action(context.i18n.ptrl("View template")) { + context.cs.launch { + BrowserUtil.browse(client.url.withPath("/templates/${workspace.templateName}").toString()) { + context.ui.showErrorInfoPopup(it) + } } + }) + + if (wsRawStatus.canStart()) { + if (workspace.outdated) { + actions.add(Action(context.i18n.ptrl("Update and start")) { + val build = client.updateWorkspace(workspace) + update(workspace.copy(latestBuild = build), agent) + }) + } else { + actions.add(Action(context.i18n.ptrl("Start")) { + val build = client.startWorkspace(workspace) + update(workspace.copy(latestBuild = build), agent) + }) } - }, - Action(context.i18n.ptrl("Start"), enabled = { wsRawStatus.canStart() }) { - val build = client.startWorkspace(workspace) - workspace = workspace.copy(latestBuild = build) - update(workspace, agent) - }, - Action(context.i18n.ptrl("Stop"), enabled = { wsRawStatus.canStop() }) { - val build = client.stopWorkspace(workspace) - workspace = workspace.copy(latestBuild = build) - update(workspace, agent) - }, - Action(context.i18n.ptrl("Update"), enabled = { workspace.outdated }) { - val build = client.updateWorkspace(workspace) - workspace = workspace.copy(latestBuild = build) - update(workspace, agent) - }) + } + if (wsRawStatus.canStop()) { + if (workspace.outdated) { + actions.add(Action(context.i18n.ptrl("Update and restart")) { + val build = client.updateWorkspace(workspace) + update(workspace.copy(latestBuild = build), agent) + }) + } else { + actions.add(Action(context.i18n.ptrl("Stop")) { + val build = client.stopWorkspace(workspace) + update(workspace.copy(latestBuild = build), agent) + }) + } + } + return actions + } /** * Update the workspace/agent status to the listeners, if it has changed. diff --git a/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt b/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt index a449c39..a30d3fb 100644 --- a/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt +++ b/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt @@ -17,6 +17,7 @@ import com.coder.toolbox.views.NewEnvironmentPage import com.coder.toolbox.views.SignInPage import com.coder.toolbox.views.TokenPage import com.jetbrains.toolbox.api.core.ui.icons.SvgIcon +import com.jetbrains.toolbox.api.core.ui.icons.SvgIcon.IconType import com.jetbrains.toolbox.api.core.util.LoadableState import com.jetbrains.toolbox.api.remoteDev.ProviderVisibilityState import com.jetbrains.toolbox.api.remoteDev.RemoteProvider @@ -181,10 +182,16 @@ class CoderRemoteProvider( } override val svgIcon: SvgIcon = - SvgIcon(this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf()) + SvgIcon( + this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf(), + type = IconType.Masked + ) override val noEnvironmentsSvgIcon: SvgIcon? = - SvgIcon(this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf()) + SvgIcon( + this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf(), + type = IconType.Masked + ) /** * TODO@JB: It would be nice to show "loading workspaces" at first but it diff --git a/src/main/kotlin/com/coder/toolbox/views/CoderPage.kt b/src/main/kotlin/com/coder/toolbox/views/CoderPage.kt index 6a1c4e3..53b55ea 100644 --- a/src/main/kotlin/com/coder/toolbox/views/CoderPage.kt +++ b/src/main/kotlin/com/coder/toolbox/views/CoderPage.kt @@ -2,6 +2,7 @@ package com.coder.toolbox.views import com.coder.toolbox.CoderToolboxContext import com.jetbrains.toolbox.api.core.ui.icons.SvgIcon +import com.jetbrains.toolbox.api.core.ui.icons.SvgIcon.IconType import com.jetbrains.toolbox.api.localization.LocalizableString import com.jetbrains.toolbox.api.ui.actions.RunnableActionDescription import com.jetbrains.toolbox.api.ui.components.UiField @@ -46,9 +47,12 @@ abstract class CoderPage( * This seems to only work on the first page. */ override val svgIcon: SvgIcon? = if (showIcon) { - SvgIcon(this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf()) + SvgIcon( + this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf(), + type = IconType.Masked + ) } else { - SvgIcon(byteArrayOf()) + SvgIcon(byteArrayOf(), type = IconType.Masked) } /** diff --git a/src/main/resources/localization/defaultMessages.po b/src/main/resources/localization/defaultMessages.po index 837e2a0..aa96e05 100644 --- a/src/main/resources/localization/defaultMessages.po +++ b/src/main/resources/localization/defaultMessages.po @@ -73,7 +73,10 @@ msgstr "" msgid "Stop" msgstr "" -msgid "Update" +msgid "Update and start" +msgstr "" + +msgid "Update and restart" msgstr "" msgid "Settings" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy