Skip to content

Commit

Permalink
Connect in one click
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Zatsarynnyi <[email protected]>
  • Loading branch information
azatsarynnyy committed Feb 13, 2024
1 parent 20a8cea commit 56ff7d0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package com.github.devspaces.gateway

import com.jetbrains.gateway.api.ConnectionRequestor
import com.jetbrains.gateway.api.GatewayConnectionHandle
import com.jetbrains.gateway.api.GatewayConnectionProvider
import com.jetbrains.gateway.thinClientLink.LinkedClientManager
import com.jetbrains.rd.util.lifetime.Lifetime
import java.net.URI

/**
* Handles links as:
* jetbrains-gateway://connect#type=devspaces
* https://code-with-me.jetbrains.com/remoteDev#type=devspaces
*/
class DevSpacesConnectionProvider : GatewayConnectionProvider {

override suspend fun connect(parameters: Map<String, String>, requestor: ConnectionRequestor): GatewayConnectionHandle? {
val joinLink = parameters["link"]?.replace("_", "&")
LinkedClientManager.getInstance().startNewClient(Lifetime.Eternal, URI(joinLink))

Check warning on line 30 in src/main/kotlin/com/github/devspaces/gateway/DevSpacesConnectionProvider.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getInstance()' is declared in unstable 'com.jetbrains.gateway.thinClientLink.LinkedClientManager' marked with @ApiStatus.Experimental

Check warning on line 30 in src/main/kotlin/com/github/devspaces/gateway/DevSpacesConnectionProvider.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'startNewClient(com.jetbrains.rd.util.lifetime.Lifetime, java.net.URI, java.lang.String, kotlin.jvm.functions.Function0)' is declared in unstable 'com.jetbrains.gateway.thinClientLink.LinkedClientManager' marked with @ApiStatus.Experimental

Check warning on line 30 in src/main/kotlin/com/github/devspaces/gateway/DevSpacesConnectionProvider.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'com.jetbrains.gateway.thinClientLink.LinkedClientManager.Companion' is declared in unstable 'com.jetbrains.gateway.thinClientLink.LinkedClientManager' marked with @ApiStatus.Experimental
return null
}

override fun isApplicable(parameters: Map<String, String>): Boolean {
return parameters["type"] == "devspaces"
}
}
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
<idea-plugin>
<id>com.github.devspaces.gateway</id>
<name>OpenShift DevSpaces</name>
<name>OpenShift Dev Spaces</name>
<vendor>Red Hat</vendor>

<depends>com.intellij.modules.platform</depends>
Expand All @@ -10,6 +10,6 @@

<extensions defaultExtensionNs="com.jetbrains">
<gatewayConnector implementation="com.github.devspaces.gateway.DevSpacesConnector"/>
<!-- <gatewayConnectionProvider implementation="com.github.devspaces.gateway.DevSpacesConnectionProvider"/>-->
<gatewayConnectionProvider implementation="com.github.devspaces.gateway.DevSpacesConnectionProvider"/>
</extensions>
</idea-plugin>

0 comments on commit 56ff7d0

Please sign in to comment.