- Notifications
You must be signed in to change notification settings - Fork1
Fix Coder connect workflows#2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
13 commits Select commitHold shift + click to select a range
335061a
build: rename project to coder-toolbox
fioan894fe83ce
chore: update license
fioan897151981
import code from coder/jetbrains-coder
fioan8936fba63
fix: remove Gateway string from title
fioan89e39cd05
impl: initial support for opening urls
fioan8994a6ff3
fix: use new URL opener
fioan89915d347
chore: replaces references to Gateway with Toolbox
fioan895973b0d
impl: go to main page after signing in
fioan89b031c65
fix: connection status rendering
fioan898faed95
fix: url glitch on new environment page
fioan8990d199c
impl: read plugin version from the extension.json
fioan8938e3e2b
fix: user agent did not have a proper version
fioan8933b4a60
Merge branch 'main' into fix-connection-issues
fioan89File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
28 changes: 0 additions & 28 deletionssrc/main/kotlin/com/coder/toolbox/CoderGatewayExtension.kt
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
37 changes: 27 additions & 10 deletionssrc/main/kotlin/com/coder/toolbox/CoderRemoteEnvironment.kt
This file contains hidden or 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
32 changes: 17 additions & 15 deletionssrc/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt
This file contains hidden or 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
19 changes: 19 additions & 0 deletionssrc/main/kotlin/com/coder/toolbox/CoderToolboxExtension.kt
This file contains hidden or 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,19 @@ | ||
package com.coder.toolbox | ||
import com.jetbrains.toolbox.api.core.ServiceLocator | ||
import com.jetbrains.toolbox.api.remoteDev.RemoteDevExtension | ||
import com.jetbrains.toolbox.api.remoteDev.RemoteProvider | ||
import okhttp3.OkHttpClient | ||
/** | ||
* Entry point into the extension. | ||
*/ | ||
class CoderToolboxExtension : RemoteDevExtension { | ||
// All services must be passed in here and threaded as necessary. | ||
override fun createRemoteProviderPluginInstance(serviceLocator: ServiceLocator): RemoteProvider { | ||
return CoderRemoteProvider( | ||
serviceLocator, | ||
OkHttpClient(), | ||
) | ||
} | ||
} |
5 changes: 5 additions & 0 deletionssrc/main/kotlin/com/coder/toolbox/browser/BrowserException.kt
This file contains hidden or 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,5 @@ | ||
package com.coder.toolbox.browser | ||
import java.io.IOException | ||
class BrowserException(msg: String, error: Throwable? = null) : IOException(msg, error) |
66 changes: 66 additions & 0 deletionssrc/main/kotlin/com/coder/toolbox/browser/BrowserUtil.kt
This file contains hidden or 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,66 @@ | ||
package com.coder.toolbox.browser | ||
import com.coder.toolbox.util.OS | ||
import com.coder.toolbox.util.getOS | ||
import org.zeroturnaround.exec.ProcessExecutor | ||
class BrowserUtil { | ||
companion object { | ||
fun browse(url: String, errorHandler: (BrowserException) -> Unit) { | ||
val os = getOS() | ||
if (os == null) { | ||
errorHandler(BrowserException("Failed to open the URL because we can't detect the OS")) | ||
return | ||
} | ||
when (os) { | ||
OS.LINUX -> linuxBrowse(url, errorHandler) | ||
OS.MAC -> macBrowse(url, errorHandler) | ||
OS.WINDOWS -> windowsBrowse(url, errorHandler) | ||
} | ||
} | ||
private fun linuxBrowse(url: String, errorHandler: (BrowserException) -> Unit) { | ||
try { | ||
if (OS.LINUX.getDesktopEnvironment()?.uppercase()?.contains("GNOME") == true) { | ||
exec("gnome-open", url) | ||
} else { | ||
exec("xdg-open", url) | ||
} | ||
} catch (e: Exception) { | ||
errorHandler( | ||
BrowserException( | ||
"Failed to open URL because an error was encountered. Please make sure xdg-open from package xdg-utils is available!", | ||
e | ||
) | ||
) | ||
} | ||
} | ||
private fun macBrowse(url: String, errorHandler: (BrowserException) -> Unit) { | ||
try { | ||
exec("open", url) | ||
} catch (e: Exception) { | ||
errorHandler(BrowserException("Failed to open URL because an error was encountered.", e)) | ||
} | ||
} | ||
private fun windowsBrowse(url: String, errorHandler: (BrowserException) -> Unit) { | ||
try { | ||
exec("cmd", "start \"$url\"") | ||
} catch (e: Exception) { | ||
errorHandler(BrowserException("Failed to open URL because an error was encountered.", e)) | ||
} | ||
} | ||
private fun exec(vararg args: String): String { | ||
val stdout = | ||
ProcessExecutor() | ||
.command(*args) | ||
.exitValues(0) | ||
.readOutput(true) | ||
.execute() | ||
.outputUTF8() | ||
return stdout | ||
} | ||
} | ||
} |
31 changes: 16 additions & 15 deletionssrc/main/kotlin/com/coder/toolbox/models/WorkspaceAndAgentStatus.kt
This file contains hidden or 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
12 changes: 12 additions & 0 deletionssrc/main/kotlin/com/coder/toolbox/plugin/PluginInfo.kt
This file contains hidden or 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,12 @@ | ||
package com.coder.toolbox.plugin | ||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
/** | ||
* Small subset representation of extension.json | ||
*/ | ||
@JsonClass(generateAdapter = true) | ||
data class PluginInfo( | ||
@Json(name = "id") val id: String, | ||
@Json(name = "version") val version: String) |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.