Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

impl: support for Toolbox 2.7#135

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
fioan89 wants to merge5 commits intomain
base:main
Choose a base branch
Loading
fromimpl-support-for-tbx-2.7
Draft
Show file tree
Hide file tree
Changes fromall 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
2 changes: 1 addition & 1 deletiongradle/libs.versions.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
[versions]
toolbox-plugin-api = "1.1.41749"
toolbox-plugin-api = "1.3.46097"
kotlin = "2.1.10"
coroutines = "1.10.1"
serialization = "1.8.0"
Expand Down
24 changes: 6 additions & 18 deletionssrc/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,7 @@ class CoderRemoteProvider(
// On the first load, automatically log in if we can.
private var firstRun = true
private val isInitialized: MutableStateFlow<Boolean> = MutableStateFlow(false)
privatevar coderHeaderPage = NewEnvironmentPage(context,context.i18n.pnotr(context.deploymentUrl.toString()))
privateval coderHeaderPage = NewEnvironmentPage(context.i18n.pnotr(context.deploymentUrl.toString()))
private val linkHandler = CoderProtocolHandler(context, dialogUi, isInitialized)

override val environments: MutableStateFlow<LoadableState<List<CoderRemoteEnvironment>>> = MutableStateFlow(
Expand DownExpand Up@@ -167,7 +167,7 @@ class CoderRemoteProvider(
close()
// force auto-login
firstRun = true
goToEnvironmentsPage()
context.envPageManager.showPluginEnvironmentsPage()
break
}
}
Expand DownExpand Up@@ -317,25 +317,13 @@ class CoderRemoteProvider(
close()
// start initialization with the new settings
this@CoderRemoteProvider.client = restClient
coderHeaderPage = NewEnvironmentPage(context,context.i18n.pnotr(restClient.url.toString()))
coderHeaderPage.setTitle(context.i18n.pnotr(restClient.url.toString()))

environments.showLoadingMessage()
pollJob = poll(restClient, cli)
}
}

/**
* Make Toolbox ask for the page again. Use any time we need to change the
* root page (for example, sign-in or the environment list).
*
* When moving between related pages, instead use ui.showUiPage() and
* ui.hideUiPage() which stacks and has built-in back navigation, rather
* than using multiple root pages.
*/
private fun goToEnvironmentsPage() {
context.envPageManager.showPluginEnvironmentsPage()
}

/**
* Return the sign-in page if we do not have a valid client.

Expand DownExpand Up@@ -377,7 +365,7 @@ class CoderRemoteProvider(

private fun shouldDoAutoSetup(): Boolean = firstRun && context.secrets.rememberMe == true

privatesuspendfun onConnect(client: CoderRestClient, cli: CoderCLIManager) {
private fun onConnect(client: CoderRestClient, cli: CoderCLIManager) {
// Store the URL and token for use next time.
context.secrets.lastDeploymentURL = client.url.toString()
context.secrets.lastToken = client.token ?: ""
Expand All@@ -387,9 +375,9 @@ class CoderRemoteProvider(
this.client = client
pollJob?.cancel()
environments.showLoadingMessage()
coderHeaderPage = NewEnvironmentPage(context,context.i18n.pnotr(client.url.toString()))
coderHeaderPage.setTitle(context.i18n.pnotr(client.url.toString()))
pollJob = poll(client, cli)
context.refreshMainPage()
context.envPageManager.showPluginEnvironmentsPage()
}

private fun MutableStateFlow<LoadableState<List<CoderRemoteEnvironment>>>.showLoadingMessage() {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ class CoderCliSetupWizardPage(
client: CoderRestClient,
cli: CoderCLIManager,
) -> Unit,
) : CoderPage(context.i18n.ptrl("Setting up Coder"), false) {
) : CoderPage(MutableStateFlow(context.i18n.ptrl("Setting up Coder")), false) {
private val shouldAutoSetup = MutableStateFlow(initialAutoSetup)
private val settingsAction = Action(context.i18n.ptrl("Settings"), actionBlock = {
context.ui.showUiPage(settingsPage)
Expand Down
11 changes: 9 additions & 2 deletionssrc/main/kotlin/com/coder/toolbox/views/CoderPage.kt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ import com.jetbrains.toolbox.api.localization.LocalizableString
import com.jetbrains.toolbox.api.ui.actions.RunnableActionDescription
import com.jetbrains.toolbox.api.ui.components.UiPage
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.update

/**
* Base page that handles the icon, displaying error notifications, and
Expand All@@ -19,9 +20,15 @@ import kotlinx.coroutines.flow.MutableStateFlow
* to use the mouse.
*/
abstract class CoderPage(
title:LocalizableString,
private val titleObservable: MutableStateFlow<LocalizableString>,
showIcon: Boolean = true,
) : UiPage(title) {
) : UiPage(titleObservable) {

fun setTitle(title: LocalizableString) {
titleObservable.update {
title
}
}

/**
* Return the icon, if showing one.
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ import kotlinx.coroutines.launch
* I have not been able to test this page.
*/
class CoderSettingsPage(context: CoderToolboxContext, triggerSshConfig: Channel<Boolean>) :
CoderPage(context.i18n.ptrl("Coder Settings"), false) {
CoderPage(MutableStateFlow(context.i18n.ptrl("Coder Settings")), false) {
private val settings = context.settingsStore.readOnly()

// TODO: Copy over the descriptions, holding until I can test this page.
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
package com.coder.toolbox.views

import com.coder.toolbox.CoderToolboxContext
import com.jetbrains.toolbox.api.localization.LocalizableString
import com.jetbrains.toolbox.api.ui.components.UiField
import kotlinx.coroutines.flow.MutableStateFlow
Expand All@@ -14,7 +13,7 @@ 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(deploymentURL) {
class NewEnvironmentPage(deploymentURL: LocalizableString) :
CoderPage(MutableStateFlow(deploymentURL)) {
override val fields: StateFlow<List<UiField>> = MutableStateFlow(emptyList())
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp