generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connect from the Dashboard with one click (#19)
* 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
1 parent
8bb51bb
commit 6693555
Showing
2 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/com/github/devspaces/gateway/DevSpacesConnectionProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters