Skip to content

Commit fc9679b

Browse files
committed
T
1 parent ee22acb commit fc9679b

21 files changed

+198
-402
lines changed

.idea/gradle.xml

+10-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/ide/jetbrains/backend-plugin/gradle-latest.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ pluginUntilBuild=242.*
66
# See https://jb.gg/intellij-platform-builds-list for available build versions.
77
pluginVerifierIdeVersions=2024.2
88
# Version from "com.jetbrains.intellij.idea" which can be found at https://www.jetbrains.com/intellij-repository/snapshots
9-
platformVersion=242.19533-EAP-CANDIDATE-SNAPSHOT
9+
platformVersion=242.20224-EAP-CANDIDATE-SNAPSHOT

components/ide/jetbrains/toolbox/build.gradle.kts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright (c) 2024 Gitpod GmbH. All rights reserved.
2+
// Licensed under the GNU Affero General Public License (AGPL).
3+
// See License.AGPL.txt in the project root for license information.
4+
15
import com.github.jk1.license.filter.ExcludeTransitiveDependenciesFilter
26
import com.github.jk1.license.render.JsonReportRenderer
37
import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory
@@ -34,12 +38,12 @@ dependencies {
3438
implementation("com.connectrpc:connect-kotlin:0.6.0")
3539
// Java specific dependencies.
3640
implementation("com.connectrpc:connect-kotlin-google-java-ext:0.6.0")
37-
implementation("com.google.protobuf:protobuf-java:4.26.0")
41+
implementation("com.google.protobuf:protobuf-java:4.27.2")
3842
// WebSocket
3943
compileOnly("javax.websocket:javax.websocket-api:1.1")
4044
compileOnly("org.eclipse.jetty.websocket:websocket-api:9.4.54.v20240208")
4145
implementation("org.eclipse.jetty.websocket:javax-websocket-client-impl:9.4.54.v20240208")
42-
// RD-Core
46+
// RD-Core https://mvnrepository.com/artifact/com.jetbrains.rd/rd-core
4347
implementation("com.jetbrains.rd:rd-core:2024.1.1")
4448

4549
implementation(libs.gateway.api)

components/ide/jetbrains/toolbox/gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
gateway = "2.4.0.30948"
2+
gateway = "2.4.0.31544"
33
kotlin = "1.9.0"
44
coroutines = "1.7.3"
55
serialization = "1.5.0"

components/ide/jetbrains/toolbox/src/main/kotlin/io/gitpod/toolbox/auth/GitpodAuthManager.kt

+28-39
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,44 @@ class GitpodAuthManager {
6060
manager.addEventListener {
6161
when (it.type) {
6262
AuthEvent.Type.LOGIN -> {
63-
logger.info("account ${it.accountId} logged in")
63+
logger.debug("gitpod: user logged in ${it.accountId}")
64+
resetCurrentAccount(it.accountId)
6465
loginListeners.forEach { it() }
6566
}
67+
6668
AuthEvent.Type.LOGOUT -> {
67-
logger.info("account ${it.accountId} logged out")
69+
logger.debug("gitpod: user logged out ${it.accountId}")
70+
resetCurrentAccount(it.accountId)
6871
logoutListeners.forEach { it() }
6972
}
7073
}
7174
}
7275
}
7376

77+
private fun resetCurrentAccount(accountId: String) {
78+
val account = manager.accountsWithStatus.find { it.account.id == accountId }?.account ?: return
79+
logger.debug("reset settings for ${account.getHost()}")
80+
Utils.gitpodSettings.resetSettings(account.getHost())
81+
}
82+
7483
fun getCurrentAccount(): GitpodAccount? {
75-
return manager.accountsWithStatus.firstOrNull()?.account
84+
return manager.accountsWithStatus.find { it.account.getHost() == Utils.gitpodSettings.gitpodHost }?.account
85+
}
86+
87+
fun loginWithHost(host: String): Boolean {
88+
if (getCurrentAccount()?.getHost() == host) {
89+
// TODO: validate token is still available
90+
return true
91+
}
92+
val account = manager.accountsWithStatus.find { it.account.getHost() == host }?.account
93+
if (account != null) {
94+
Utils.gitpodSettings.gitpodHost = host
95+
loginListeners.forEach { it() }
96+
// TODO: validate token is still available
97+
return true
98+
}
99+
Utils.openUrl(this.getOAuthLoginUrl(host))
100+
return false
76101
}
77102

78103
fun logout() {
@@ -135,48 +160,12 @@ class GitpodAccount(
135160
private val name: String,
136161
private val host: String
137162
) : Account {
138-
private val orgSelectedListeners: MutableList<(String) -> Unit> = mutableListOf()
139-
private val logger = LoggerFactory.getLogger(javaClass)
140163

141164
override fun getId() = id
142165
override fun getFullName() = name
143166
fun getCredentials() = credentials
144167
fun getHost() = host
145168

146-
private fun getStoreKey(key: String) = "USER:${id}:${key}"
147-
148-
var organizationId: String?
149-
get() = Utils.settingStore[getStoreKey("ORG")]
150-
set(value){
151-
if (value == null) {
152-
return
153-
}
154-
Utils.settingStore[getStoreKey("ORG")] = value
155-
orgSelectedListeners.forEach { it(value) }
156-
}
157-
158-
var preferEditor: String?
159-
get() = Utils.settingStore[getStoreKey("EDITOR")]
160-
set(value){
161-
if (value == null) {
162-
return
163-
}
164-
Utils.settingStore[getStoreKey("EDITOR")] = value
165-
}
166-
167-
var preferWorkspaceClass: String?
168-
get() = Utils.settingStore[getStoreKey("WS_CLS")]
169-
set(value){
170-
if (value == null) {
171-
return
172-
}
173-
Utils.settingStore[getStoreKey("WS_CLS")] = value
174-
}
175-
176-
fun onOrgSelected(listener: (String) -> Unit) {
177-
orgSelectedListeners.add(listener)
178-
}
179-
180169
fun encode(): String {
181170
return Json.encodeToString(this)
182171
}

components/ide/jetbrains/toolbox/src/main/kotlin/io/gitpod/toolbox/auth/GitpodOrganizationPage.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class GitpodOrganizationPage(val authManager: GitpodAuthManager, val publicApi:
2929
val options = mutableListOf<AutocompleteItem>()
3030
options.addAll(organizations.map { org ->
3131
MenuItem(org.name, null, null) {
32-
authManager.getCurrentAccount()?.organizationId = org.id
32+
Utils.gitpodSettings.organizationId = org.id
3333
Utils.toolboxUi.hideUiPage(this)
3434
}
3535
})
36-
val orgName = organizations.find { it.id == authManager.getCurrentAccount()?.organizationId }?.name ?: ""
36+
val orgName = organizations.find { it.id == Utils.gitpodSettings.organizationId }?.name ?: ""
3737
AutocompleteTextField("Organization", orgName, options, 1.0f) {
3838
if (it.isNullOrEmpty()) {
3939
ValidationResult.Invalid("Organization is required")

components/ide/jetbrains/toolbox/src/main/kotlin/io/gitpod/toolbox/colima/ColimaTestEnvironment.kt

-70
This file was deleted.

components/ide/jetbrains/toolbox/src/main/kotlin/io/gitpod/toolbox/gateway/GitpodLogger.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
package io.gitpod.toolbox.gateway
66

77
import com.jetbrains.toolbox.gateway.deploy.DiagnosticInfoCollector
8+
import org.slf4j.Logger
89
import java.nio.file.Path
910
import java.util.concurrent.CompletableFuture
10-
import org.slf4j.Logger
1111

1212

1313
class GitpodLogger(private val logger:Logger) : DiagnosticInfoCollector {

components/ide/jetbrains/toolbox/src/main/kotlin/io/gitpod/toolbox/gateway/GitpodNewEnvironmentPage.kt

-110
This file was deleted.

0 commit comments

Comments
 (0)