Skip to content

Commit 49d3b8b

Browse files
committed
impl: bump plugin API version to o.6
1 parent 102fdab commit 49d3b8b

File tree

7 files changed

+22
-48
lines changed

7 files changed

+22
-48
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
toolbox-plugin-api = "0.2"
2+
toolbox-plugin-api = "0.6.2.6.0.37447"
33
kotlin = "2.0.10"
44
coroutines = "1.7.3"
55
serialization = "1.5.0"

src/main/kotlin/com/coder/gateway/CoderGatewayExtension.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import com.jetbrains.toolbox.api.remoteDev.RemoteDevExtension
77
import com.jetbrains.toolbox.api.remoteDev.RemoteEnvironmentConsumer
88
import com.jetbrains.toolbox.api.remoteDev.RemoteProvider
99
import com.jetbrains.toolbox.api.ui.ToolboxUi
10-
import com.jetbrains.toolbox.api.ui.observables.ObservablePropertiesFactory
1110
import kotlinx.coroutines.CoroutineScope
1211
import okhttp3.OkHttpClient
1312

@@ -16,13 +15,14 @@ import okhttp3.OkHttpClient
1615
*/
1716
class CoderGatewayExtension : RemoteDevExtension {
1817
// All services must be passed in here and threaded as necessary.
19-
override fun createRemoteProviderPluginInstance(serviceLocator: ServiceLocator): RemoteProvider = CoderRemoteProvider(
20-
serviceLocator.getService(OkHttpClient::class.java),
21-
serviceLocator.getService(RemoteEnvironmentConsumer::class.java),
22-
serviceLocator.getService(CoroutineScope::class.java),
23-
serviceLocator.getService(ToolboxUi::class.java),
24-
serviceLocator.getService(PluginSettingsStore::class.java),
25-
serviceLocator.getService(PluginSecretStore::class.java),
26-
serviceLocator.getService(ObservablePropertiesFactory::class.java),
27-
)
18+
override fun createRemoteProviderPluginInstance(serviceLocator: ServiceLocator): RemoteProvider {
19+
return CoderRemoteProvider(
20+
serviceLocator.getService(OkHttpClient::class.java),
21+
serviceLocator.getService(RemoteEnvironmentConsumer::class.java),
22+
serviceLocator.getService(CoroutineScope::class.java),
23+
serviceLocator.getService(ToolboxUi::class.java),
24+
serviceLocator.getService(PluginSettingsStore::class.java),
25+
serviceLocator.getService(PluginSecretStore::class.java),
26+
)
27+
}
2828
}

src/main/kotlin/com/coder/gateway/CoderRemoteEnvironment.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import com.jetbrains.toolbox.api.remoteDev.EnvironmentVisibilityState
1111
import com.jetbrains.toolbox.api.remoteDev.environments.EnvironmentContentsView
1212
import com.jetbrains.toolbox.api.remoteDev.states.EnvironmentStateConsumer
1313
import com.jetbrains.toolbox.api.ui.ToolboxUi
14-
import com.jetbrains.toolbox.api.ui.observables.ObservablePropertiesFactory
1514
import java.util.concurrent.CompletableFuture
1615

1716
/**
@@ -24,8 +23,7 @@ class CoderRemoteEnvironment(
2423
private var workspace: Workspace,
2524
private var agent: WorkspaceAgent,
2625
private val ui: ToolboxUi,
27-
observablePropertiesFactory: ObservablePropertiesFactory,
28-
) : AbstractRemoteProviderEnvironment(observablePropertiesFactory) {
26+
) : AbstractRemoteProviderEnvironment() {
2927
override fun getId(): String = "${workspace.name}.${agent.name}"
3028
override fun getName(): String = "${workspace.name}.${agent.name}"
3129
private var status = WorkspaceAndAgentStatus.from(workspace, agent)

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import com.jetbrains.toolbox.api.ui.ToolboxUi
2626
import com.jetbrains.toolbox.api.ui.actions.RunnableActionDescription
2727
import com.jetbrains.toolbox.api.ui.components.AccountDropdownField
2828
import com.jetbrains.toolbox.api.ui.components.UiPage
29-
import com.jetbrains.toolbox.api.ui.observables.ObservablePropertiesFactory
3029
import kotlinx.coroutines.CoroutineScope
3130
import kotlinx.coroutines.Job
3231
import kotlinx.coroutines.delay
@@ -46,7 +45,6 @@ class CoderRemoteProvider(
4645
private val ui: ToolboxUi,
4746
settingsStore: PluginSettingsStore,
4847
secretsStore: PluginSecretStore,
49-
private val observablePropertiesFactory: ObservablePropertiesFactory,
5048
) : RemoteProvider {
5149
private val logger = LoggerFactory.getLogger(javaClass)
5250

@@ -98,7 +96,7 @@ class CoderRemoteProvider(
9896
it.name
9997
}?.map { agent ->
10098
// If we have an environment already, update that.
101-
val env = CoderRemoteEnvironment(client, ws, agent, ui, observablePropertiesFactory)
99+
val env = CoderRemoteEnvironment(client, ws, agent, ui)
102100
lastEnvironments?.firstOrNull { it == env }?.let {
103101
it.update(ws, agent)
104102
it
@@ -122,7 +120,7 @@ class CoderRemoteProvider(
122120
cli.configSsh(newEnvironments.map { it.name }.toSet())
123121
}
124122

125-
consumer.consumeEnvironments(environments)
123+
consumer.consumeEnvironments(environments, true)
126124

127125
lastEnvironments = environments
128126
} catch (_: CancellationException) {
@@ -157,9 +155,7 @@ class CoderRemoteProvider(
157155
override fun getAccountDropDown(): AccountDropdownField? {
158156
val username = client?.me?.username
159157
if (username != null) {
160-
return AccountDropdownField(username) {
161-
logout()
162-
}
158+
return AccountDropdownField(username, Runnable { logout() })
163159
}
164160
return null
165161
}
@@ -183,7 +179,7 @@ class CoderRemoteProvider(
183179
pollJob?.cancel()
184180
client = null
185181
lastEnvironments = null
186-
consumer.consumeEnvironments(emptyList())
182+
consumer.consumeEnvironments(emptyList(), true)
187183
}
188184

189185
override fun getName(): String = "Coder Gateway"

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ abstract class CoderPage(
3333
/** Toolbox uses this to show notifications on the page. */
3434
private var notifier: Consumer<Throwable>? = null
3535

36-
/** Used to get field values. */
37-
private var stateAccessor: UiPage.UiFieldStateAccessor? = null
38-
3936
/** Let Toolbox know the fields should be updated. */
4037
protected var listener: Consumer<UiField?>? = null
4138

@@ -71,19 +68,9 @@ abstract class CoderPage(
7168
* to be able to do `myField.value`.
7269
*/
7370
fun get(field: UiField): Any? {
74-
return stateAccessor?.get(field)
75-
}
76-
77-
/**
78-
* Used to update fields when they change (like validation fields).
79-
*/
80-
override fun setPageChangedListener(listener: Consumer<UiField?>) {
81-
this.listener = listener
82-
}
83-
84-
85-
override fun setStateAccessor(stateAccessor: UiPage.UiFieldStateAccessor?) {
86-
this.stateAccessor = stateAccessor
71+
//return stateAccessor?.get(field)
72+
// TODO - check this later
73+
return null
8774
}
8875

8976
/**

src/main/resources/dependencies.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
3-
"name": "com.jetbrains.toolbox.gateway:gateway-api",
4-
"version": "2.5.0.32871",
3+
"name": "Toolbox App plugin API",
4+
"version": "2.1.0.16946",
55
"url": "https://jetbrains.com/toolbox-app/",
66
"license": "The Apache Software License, Version 2.0",
77
"licenseUrl": "https://www.apache.org/licenses/LICENSE-2.0.txt"
@@ -27,13 +27,6 @@
2727
"license": "The Apache Software License, Version 2.0",
2828
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.txt"
2929
},
30-
{
31-
"name": "org.jetbrains.kotlin:kotlin-stdlib-jdk8",
32-
"version": "1.9.10",
33-
"url": "https://kotlinlang.org/",
34-
"license": "The Apache License, Version 2.0",
35-
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.txt"
36-
},
3730
{
3831
"name": "org.jetbrains.kotlinx:kotlinx-coroutines-core",
3932
"version": "1.7.3",

src/main/resources/extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"vendor": "Coder",
88
"url": "https://github.com/coder/jetbrains-coder"
99
},
10-
"apiVersion": "0.1.0",
10+
"apiVersion": "0.3.0",
1111
"compatibleVersionRange": {
1212
"from": "2.6.0.0",
1313
"to": "2.6.0.99999"

0 commit comments

Comments
 (0)
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