Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb93225

Browse files
committed
impl: use the new API to set titles on UI pages
1 parent a8d04bb commit eb93225

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class CoderRemoteProvider(
6363
// On the first load, automatically log in if we can.
6464
private var firstRun = true
6565
private val isInitialized: MutableStateFlow<Boolean> = MutableStateFlow(false)
66-
private var coderHeaderPage = NewEnvironmentPage(context, context.i18n.pnotr(context.deploymentUrl.toString()))
66+
private var coderHeaderPage = NewEnvironmentPage(context.i18n.pnotr(context.deploymentUrl.toString()))
6767
private val linkHandler = CoderProtocolHandler(context, dialogUi, isInitialized)
6868

6969
override val environments: MutableStateFlow<LoadableState<List<CoderRemoteEnvironment>>> = MutableStateFlow(
@@ -317,7 +317,7 @@ class CoderRemoteProvider(
317317
close()
318318
// start initialization with the new settings
319319
this@CoderRemoteProvider.client = restClient
320-
coderHeaderPage = NewEnvironmentPage(context, context.i18n.pnotr(restClient.url.toString()))
320+
coderHeaderPage = NewEnvironmentPage(context.i18n.pnotr(restClient.url.toString()))
321321

322322
environments.showLoadingMessage()
323323
pollJob = poll(restClient, cli)
@@ -387,7 +387,7 @@ class CoderRemoteProvider(
387387
this.client = client
388388
pollJob?.cancel()
389389
environments.showLoadingMessage()
390-
coderHeaderPage = NewEnvironmentPage(context, context.i18n.pnotr(client.url.toString()))
390+
coderHeaderPage = NewEnvironmentPage(context.i18n.pnotr(client.url.toString()))
391391
pollJob = poll(client, cli)
392392
context.refreshMainPage()
393393
}

src/main/kotlin/com/coder/toolbox/views/CoderCliSetupWizardPage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CoderCliSetupWizardPage(
2525
client: CoderRestClient,
2626
cli: CoderCLIManager,
2727
) -> Unit,
28-
) : CoderPage(context.i18n.ptrl("Setting up Coder"), false) {
28+
) : CoderPage(MutableStateFlow(context.i18n.ptrl("Setting up Coder")), false) {
2929
private val shouldAutoSetup = MutableStateFlow(initialAutoSetup)
3030
private val settingsAction = Action(context.i18n.ptrl("Settings"), actionBlock = {
3131
context.ui.showUiPage(settingsPage)

src/main/kotlin/com/coder/toolbox/views/CoderPage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import kotlinx.coroutines.flow.MutableStateFlow
1919
* to use the mouse.
2020
*/
2121
abstract class CoderPage(
22-
title: LocalizableString,
22+
private val titleObservable: MutableStateFlow<LocalizableString>,
2323
showIcon: Boolean = true,
24-
) : UiPage(title) {
24+
) : UiPage(titleObservable) {
2525

2626
/**
2727
* Return the icon, if showing one.

src/main/kotlin/com/coder/toolbox/views/CoderSettingsPage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import kotlinx.coroutines.launch
2020
* I have not been able to test this page.
2121
*/
2222
class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<Boolean>) :
23-
CoderPage(context.i18n.ptrl("Coder Settings"), false) {
23+
CoderPage(MutableStateFlow(context.i18n.ptrl("Coder Settings")), false) {
2424
private val settings = context.settingsStore.readOnly()
2525

2626
// TODO: Copy over the descriptions, holding until I can test this page.

src/main/kotlin/com/coder/toolbox/views/NewEnvironmentPage.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.coder.toolbox.views
22

3-
import com.coder.toolbox.CoderToolboxContext
43
import com.jetbrains.toolbox.api.localization.LocalizableString
54
import com.jetbrains.toolbox.api.ui.components.UiField
65
import kotlinx.coroutines.flow.MutableStateFlow
@@ -14,7 +13,7 @@ import kotlinx.coroutines.flow.StateFlow
1413
* For now we just use this to display the deployment URL since we do not
1514
* support creating environments from the plugin.
1615
*/
17-
class NewEnvironmentPage(context: CoderToolboxContext, deploymentURL: LocalizableString) :
18-
CoderPage(deploymentURL) {
16+
class NewEnvironmentPage(deploymentURL: LocalizableString) :
17+
CoderPage(MutableStateFlow(deploymentURL)) {
1918
override val fields: StateFlow<List<UiField>> = MutableStateFlow(emptyList())
2019
}

0 commit comments

Comments
 (0)