diff --git a/CHANGELOG.md b/CHANGELOG.md index da6e3d7..39a4b54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ ### Fixed -- after log out, user is redirected back to the initial log in screen +- after log out, user is redirected back to the initial log in screen +- url on the main page is now refreshed when switching between multiple deployments (via logout/login or URI handling) ## 0.1.1 - 2025-04-03 diff --git a/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt b/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt index ccdf622..d51bf0d 100644 --- a/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt +++ b/src/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt @@ -177,7 +177,7 @@ class CoderRemoteEnvironment( while (context.cs.isActive && workspaceStillExists) { if (wsRawStatus == WorkspaceAndAgentStatus.DELETING || wsRawStatus == WorkspaceAndAgentStatus.DELETED) { workspaceStillExists = false - context.envPageManager.showPluginEnvironmentsPage() + context.envPageManager.showMainPageWithUrlVisible() } else { delay(1.seconds) } diff --git a/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt b/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt index 6c30d5b..df39b7a 100644 --- a/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt +++ b/src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt @@ -67,7 +67,8 @@ class CoderRemoteProvider( // On the first load, automatically log in if we can. private var firstRun = true private val isInitialized: MutableStateFlow = MutableStateFlow(false) - private var coderHeaderPage = NewEnvironmentPage(context, context.i18n.pnotr(getDeploymentURL()?.first ?: "")) + private var coderHeaderPage = + NewEnvironmentPage(context, context.i18n.pnotr("Coder"), getDeploymentURL()?.first ?: "") private val linkHandler = CoderProtocolHandler(context, dialogUi, isInitialized) override val environments: MutableStateFlow>> = MutableStateFlow( LoadableState.Value(emptyList()) @@ -243,7 +244,7 @@ class CoderRemoteProvider( * this changes it would be nice to have a new spot to show the * URL. */ - override val canCreateNewEnvironments: Boolean = false + override val canCreateNewEnvironments: Boolean = true /** * Just displays the deployment URL at the moment, but we could use this as @@ -273,7 +274,7 @@ class CoderRemoteProvider( close() // start initialization with the new settings this@CoderRemoteProvider.client = restClient - coderHeaderPage = NewEnvironmentPage(context, context.i18n.pnotr(restClient.url.toString())) + coderHeaderPage.refreshUrl(restClient.url.toString()) pollJob = poll(restClient, cli) } } @@ -287,7 +288,7 @@ class CoderRemoteProvider( * than using multiple root pages. */ private fun goToEnvironmentsPage() { - context.envPageManager.showPluginEnvironmentsPage() + context.envPageManager.showMainPageWithUrlVisible() } /** @@ -359,6 +360,7 @@ class CoderRemoteProvider( pollError = null pollJob?.cancel() pollJob = poll(client, cli) + coderHeaderPage.refreshUrl(getDeploymentURL()?.first ?: "") goToEnvironmentsPage() } diff --git a/src/main/kotlin/com/coder/toolbox/EnvironmentUiPageManagerExtensions.kt b/src/main/kotlin/com/coder/toolbox/EnvironmentUiPageManagerExtensions.kt new file mode 100644 index 0000000..056467d --- /dev/null +++ b/src/main/kotlin/com/coder/toolbox/EnvironmentUiPageManagerExtensions.kt @@ -0,0 +1,7 @@ +package com.coder.toolbox + +import com.jetbrains.toolbox.api.remoteDev.ui.EnvironmentUiPageManager + +fun EnvironmentUiPageManager.showMainPageWithUrlVisible() { + showPluginEnvironmentsPage(true) +} \ No newline at end of file diff --git a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt index c8b8e51..21a919e 100644 --- a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt +++ b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt @@ -9,6 +9,7 @@ import com.coder.toolbox.sdk.CoderRestClient import com.coder.toolbox.sdk.v2.models.Workspace import com.coder.toolbox.sdk.v2.models.WorkspaceAgent import com.coder.toolbox.sdk.v2.models.WorkspaceStatus +import com.coder.toolbox.showMainPageWithUrlVisible import com.jetbrains.toolbox.api.localization.LocalizableString import kotlinx.coroutines.TimeoutCancellationException import kotlinx.coroutines.delay @@ -322,7 +323,7 @@ private suspend fun CoderToolboxContext.showInfoPopup( private fun CoderToolboxContext.popupPluginMainPage() { this.ui.showWindow() - this.envPageManager.showPluginEnvironmentsPage(true) + this.envPageManager.showMainPageWithUrlVisible() } /** diff --git a/src/main/kotlin/com/coder/toolbox/views/NewEnvironmentPage.kt b/src/main/kotlin/com/coder/toolbox/views/NewEnvironmentPage.kt index 56b2910..0f541ae 100644 --- a/src/main/kotlin/com/coder/toolbox/views/NewEnvironmentPage.kt +++ b/src/main/kotlin/com/coder/toolbox/views/NewEnvironmentPage.kt @@ -2,9 +2,10 @@ package com.coder.toolbox.views import com.coder.toolbox.CoderToolboxContext import com.jetbrains.toolbox.api.localization.LocalizableString +import com.jetbrains.toolbox.api.ui.components.LinkField import com.jetbrains.toolbox.api.ui.components.UiField import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.update /** @@ -14,7 +15,14 @@ import kotlinx.coroutines.flow.StateFlow * For now we just use this to display the deployment URL since we do not * support creating environments from the plugin. */ -class NewEnvironmentPage(context: CoderToolboxContext, deploymentURL: LocalizableString) : - CoderPage(context, deploymentURL) { - override val fields: StateFlow> = MutableStateFlow(emptyList()) +class NewEnvironmentPage(private val context: CoderToolboxContext, title: LocalizableString, initialUrl: String) : + CoderPage(context, title) { + override val fields: MutableStateFlow> = + MutableStateFlow(listOf(LinkField(context.i18n.pnotr(initialUrl), initialUrl))) + + fun refreshUrl(url: String) { + fields.update { + listOf(LinkField(context.i18n.pnotr(url), url)) + } + } } 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