Skip to content

Commit

Permalink
Connect from the Dashboard with one click (#19)
Browse files Browse the repository at this point in the history
* Connect in one click

Signed-off-by: Artem Zatsarynnyi <[email protected]>

* Connect in one click

Signed-off-by: Artem Zatsarynnyi <[email protected]>

---------

Signed-off-by: Artem Zatsarynnyi <[email protected]>
  • Loading branch information
azatsarynnyy authored Feb 13, 2024
1 parent 8bb51bb commit 6693555
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 {

@Suppress("UnstableApiUsage")
override suspend fun connect(parameters: Map<String, String>, requestor: ConnectionRequestor): GatewayConnectionHandle? {
val joinLink = parameters["link"]?.replace("_", "&")
LinkedClientManager.getInstance().startNewClient(Lifetime.Eternal, URI(joinLink))
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 6693555

Please sign in to comment.