Skip to content

Commit

Permalink
T
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Jul 23, 2024
1 parent ee22acb commit fc9679b
Show file tree
Hide file tree
Showing 21 changed files with 198 additions and 402 deletions.
16 changes: 10 additions & 6 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pluginUntilBuild=242.*
# See https://jb.gg/intellij-platform-builds-list for available build versions.
pluginVerifierIdeVersions=2024.2
# Version from "com.jetbrains.intellij.idea" which can be found at https://www.jetbrains.com/intellij-repository/snapshots
platformVersion=242.19533-EAP-CANDIDATE-SNAPSHOT
platformVersion=242.20224-EAP-CANDIDATE-SNAPSHOT
8 changes: 6 additions & 2 deletions components/ide/jetbrains/toolbox/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License.AGPL.txt in the project root for license information.

import com.github.jk1.license.filter.ExcludeTransitiveDependenciesFilter
import com.github.jk1.license.render.JsonReportRenderer
import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory
Expand Down Expand Up @@ -34,12 +38,12 @@ dependencies {
implementation("com.connectrpc:connect-kotlin:0.6.0")
// Java specific dependencies.
implementation("com.connectrpc:connect-kotlin-google-java-ext:0.6.0")
implementation("com.google.protobuf:protobuf-java:4.26.0")
implementation("com.google.protobuf:protobuf-java:4.27.2")
// WebSocket
compileOnly("javax.websocket:javax.websocket-api:1.1")
compileOnly("org.eclipse.jetty.websocket:websocket-api:9.4.54.v20240208")
implementation("org.eclipse.jetty.websocket:javax-websocket-client-impl:9.4.54.v20240208")
// RD-Core
// RD-Core https://mvnrepository.com/artifact/com.jetbrains.rd/rd-core
implementation("com.jetbrains.rd:rd-core:2024.1.1")

implementation(libs.gateway.api)
Expand Down
2 changes: 1 addition & 1 deletion components/ide/jetbrains/toolbox/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
gateway = "2.4.0.30948"
gateway = "2.4.0.31544"
kotlin = "1.9.0"
coroutines = "1.7.3"
serialization = "1.5.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,44 @@ class GitpodAuthManager {
manager.addEventListener {
when (it.type) {
AuthEvent.Type.LOGIN -> {
logger.info("account ${it.accountId} logged in")
logger.debug("gitpod: user logged in ${it.accountId}")
resetCurrentAccount(it.accountId)
loginListeners.forEach { it() }
}

AuthEvent.Type.LOGOUT -> {
logger.info("account ${it.accountId} logged out")
logger.debug("gitpod: user logged out ${it.accountId}")
resetCurrentAccount(it.accountId)
logoutListeners.forEach { it() }
}
}
}
}

private fun resetCurrentAccount(accountId: String) {
val account = manager.accountsWithStatus.find { it.account.id == accountId }?.account ?: return
logger.debug("reset settings for ${account.getHost()}")
Utils.gitpodSettings.resetSettings(account.getHost())
}

fun getCurrentAccount(): GitpodAccount? {
return manager.accountsWithStatus.firstOrNull()?.account
return manager.accountsWithStatus.find { it.account.getHost() == Utils.gitpodSettings.gitpodHost }?.account
}

fun loginWithHost(host: String): Boolean {
if (getCurrentAccount()?.getHost() == host) {
// TODO: validate token is still available
return true
}
val account = manager.accountsWithStatus.find { it.account.getHost() == host }?.account
if (account != null) {
Utils.gitpodSettings.gitpodHost = host
loginListeners.forEach { it() }
// TODO: validate token is still available
return true
}
Utils.openUrl(this.getOAuthLoginUrl(host))
return false
}

fun logout() {
Expand Down Expand Up @@ -135,48 +160,12 @@ class GitpodAccount(
private val name: String,
private val host: String
) : Account {
private val orgSelectedListeners: MutableList<(String) -> Unit> = mutableListOf()
private val logger = LoggerFactory.getLogger(javaClass)

override fun getId() = id
override fun getFullName() = name
fun getCredentials() = credentials
fun getHost() = host

private fun getStoreKey(key: String) = "USER:${id}:${key}"

var organizationId: String?
get() = Utils.settingStore[getStoreKey("ORG")]
set(value){
if (value == null) {
return
}
Utils.settingStore[getStoreKey("ORG")] = value
orgSelectedListeners.forEach { it(value) }
}

var preferEditor: String?
get() = Utils.settingStore[getStoreKey("EDITOR")]
set(value){
if (value == null) {
return
}
Utils.settingStore[getStoreKey("EDITOR")] = value
}

var preferWorkspaceClass: String?
get() = Utils.settingStore[getStoreKey("WS_CLS")]
set(value){
if (value == null) {
return
}
Utils.settingStore[getStoreKey("WS_CLS")] = value
}

fun onOrgSelected(listener: (String) -> Unit) {
orgSelectedListeners.add(listener)
}

fun encode(): String {
return Json.encodeToString(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class GitpodOrganizationPage(val authManager: GitpodAuthManager, val publicApi:
val options = mutableListOf<AutocompleteItem>()
options.addAll(organizations.map { org ->
MenuItem(org.name, null, null) {
authManager.getCurrentAccount()?.organizationId = org.id
Utils.gitpodSettings.organizationId = org.id
Utils.toolboxUi.hideUiPage(this)
}
})
val orgName = organizations.find { it.id == authManager.getCurrentAccount()?.organizationId }?.name ?: ""
val orgName = organizations.find { it.id == Utils.gitpodSettings.organizationId }?.name ?: ""
AutocompleteTextField("Organization", orgName, options, 1.0f) {
if (it.isNullOrEmpty()) {
ValidationResult.Invalid("Organization is required")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
package io.gitpod.toolbox.gateway

import com.jetbrains.toolbox.gateway.deploy.DiagnosticInfoCollector
import org.slf4j.Logger
import java.nio.file.Path
import java.util.concurrent.CompletableFuture
import org.slf4j.Logger


class GitpodLogger(private val logger:Logger) : DiagnosticInfoCollector {
Expand Down

This file was deleted.

Loading

0 comments on commit fc9679b

Please sign in to comment.