Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,16 @@ storage paths. The options can be configured from the plugin's main Workspaces p
- `Header command` command that outputs additional HTTP headers. Each line of output must be in the format key=value.
The environment variable CODER_URL will be available to the command process.

- `lastDeploymentURL` the last Coder deployment URL that Coder Toolbox successfully authenticated to.

- `workspaceViewUrl` specifies the dashboard page full URL where users can view details about a workspace.
Helpful for customers that have their own in-house dashboards. Defaults to the Coder deployment workspace page.
This setting supports `$workspaceOwner` and `$workspaceName` as placeholders.

- `workspaceCreateUrl` specifies the dashboard page full URL where users can create new workspaces.
Helpful for customers that have their own in-house dashboards. Defaults to the Coder deployment templates page.
This setting supports `$workspaceOwner` as placeholder with the replacing value being the username that logged in.

### TLS settings

The following options control the secure communication behavior of the plugin with Coder deployment and its available
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=0.7.1
version=0.7.3
group=com.coder.toolbox
name=coder-toolbox
7 changes: 6 additions & 1 deletion src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ class CoderRemoteEnvironment(
}
actions.add(
Action(context, "Open in dashboard") {
val urlTemplate = context.settingsStore.workspaceViewUrl
?: client.url.withPath("/@${workspace.ownerName}/${workspace.name}").toString()
val url = urlTemplate
.replace("\$workspaceOwner", "${workspace.ownerName}")
.replace("\$workspaceName", workspace.name)
context.desktop.browse(
client.url.withPath("/@${workspace.ownerName}/${workspace.name}").toString()
url
) {
context.ui.showErrorInfoPopup(it)
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ class CoderRemoteProvider(
override val additionalPluginActions: StateFlow<List<ActionDescription>> = MutableStateFlow(
listOf(
Action(context, "Create workspace") {
context.desktop.browse(client?.url?.withPath("/templates").toString()) {
val url = context.settingsStore.workspaceCreateUrl ?: client?.url?.withPath("/templates").toString()
context.desktop.browse(
url
.replace("\$workspaceOwner", client?.me()?.username ?: "")
) {
context.ui.showErrorInfoPopup(it)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ interface ReadOnlyCoderSettings {
*/
val sshConfigOptions: String?

/**
* A custom full URL to the dashboard page used for viewing details about a workspace.
* Supports `$workspaceOwner` and `$workspaceName` as placeholders.
*/
val workspaceViewUrl: String?

/**
* A custom full URL to the dashboard page used for creating workspaces.
* Supports `$workspaceOwner` as placeholder.
*/
val workspaceCreateUrl: String?

/**
* The path where network information for SSH hosts are stored
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/com/coder/toolbox/store/CoderSettingsStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class CoderSettingsStore(
.normalize()
.toString()

override val workspaceViewUrl: String?
get() = store[WORKSPACE_VIEW_URL]
override val workspaceCreateUrl: String?
get() = store[WORKSPACE_CREATE_URL]

/**
* Where the specified deployment should put its data.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/com/coder/toolbox/store/StoreKeys.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ internal const val SSH_CONFIG_OPTIONS = "sshConfigOptions"

internal const val NETWORK_INFO_DIR = "networkInfoDir"

internal const val WORKSPACE_VIEW_URL = "workspaceViewUrl"
internal const val WORKSPACE_CREATE_URL = "workspaceCreateUrl"

internal const val SSH_AUTO_CONNECT_PREFIX = "ssh_auto_connect_"

12 changes: 6 additions & 6 deletions src/test/kotlin/com/coder/toolbox/util/URLExtensionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ internal class URLExtensionsTest {
@Test
fun testToURL() {
assertEquals(
URL("https", "localhost", 8080, "/path"),
"https://localhost:8080/path".toURL(),
expected = URI.create("https://localhost:8080/path").toURL(),
actual = "https://localhost:8080/path".toURL(),
)
}

@Test
fun testWithPath() {
assertEquals(
URL("https", "localhost", 8080, "/foo/bar"),
URL("https", "localhost", 8080, "/").withPath("/foo/bar"),
expected = "https://localhost:8080/foo/bar".toURL(),
actual = "https://localhost:8080/".toURL().withPath("/foo/bar"),
)

assertEquals(
URL("https", "localhost", 8080, "/foo/bar"),
URL("https", "localhost", 8080, "/old/path").withPath("/foo/bar"),
expected = "https://localhost:8080/foo/bar".toURL(),
actual = "https://localhost:8080/old/path".toURL().withPath("/foo/bar"),
)
}

Expand Down
Loading