Skip to content

Impl: icons with support for light&dark themes #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
update and delete actions and also quick shortcuts to templates, web terminal and dashboard.
- support for light & dark themes
4 changes: 2 additions & 2 deletions src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CoderRemoteEnvironment(
}
}
},
Action(context.i18n.ptrl("Start"), enabled = { wsRawStatus.canStart() }) {
Action(context.i18n.ptrl("Start"), enabled = { wsRawStatus.canStart() && !workspace.outdated }) {
val build = client.startWorkspace(workspace)
workspace = workspace.copy(latestBuild = build)
update(workspace, agent)
Expand All @@ -78,7 +78,7 @@ class CoderRemoteEnvironment(
workspace = workspace.copy(latestBuild = build)
update(workspace, agent)
},
Action(context.i18n.ptrl("Update"), enabled = { workspace.outdated }) {
Action(context.i18n.ptrl("Update and start"), enabled = { workspace.outdated }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use "Update and restart" on the web dashboard if the workspace is already in a Running state.

image

And "Update and start" if the workspace is Stopped

image

So, we need to handle both cases separately.

Also, instead of disabling, can we just hide the unavailable actions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I think we can do both though I'm not sure how do I get to have a running workspace but outdated so that I can test and play with it.

In the meantime let me write two issues to capture the requests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: unavailable actions are now hidden:
Screenshot 2025-03-12 at 22 12 53
Screenshot 2025-03-12 at 22 13 56

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how do I get to have a running workspace but outdated so that I can test and play with it.

I can help provide one. If you are an admin, you can switch your workspace to a previous template version, and that makes it "Update and restart"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an admin, that would indeed simplify my testing.

val build = client.updateWorkspace(workspace)
workspace = workspace.copy(latestBuild = build)
update(workspace, agent)
Expand Down
11 changes: 9 additions & 2 deletions src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/main/kotlin/com/coder/toolbox/views/CoderPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/localization/defaultMessages.po
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ msgstr ""
msgid "Stop"
msgstr ""

msgid "Update"
msgid "Update and start"
msgstr ""

msgid "Settings"
Expand Down
Loading