10000 revise recent projects flow to be less confusing by bcpeinhardt · Pull Request #464 · coder/jetbrains-coder · GitHub
[go: up one dir, main page]

Skip to content

revise recent projects flow to be less confusing #464

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 19, 2024
Prev Previous commit
Next Next commit
remove underline for disabled link
  • Loading branch information
bcpeinhardt committed Aug 16, 2024
commit 9c876af87df1413af7700c0d81b4eb44430ab04a
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import com.coder.gateway.models.WorkspaceProjectIDE
import com.coder.gateway.models.toIdeWithStatus
import com.coder.gateway.models.toRawString
import com.coder.gateway.models.withWorkspaceProject
import com.coder.gateway.sdk.CoderRestClient
import com.coder.gateway.sdk.v2.models.Workspace
import com.coder.gateway.sdk.v2.models.WorkspaceStatus
import com.coder.gateway.services.CoderRecentWorkspaceConnectionsService
import com.coder.gateway.services.CoderSettingsService
import com.coder.gateway.util.SemVer
Expand Down Expand Up @@ -68,7 +65,6 @@ class CoderRemoteConnectionHandle {
private val localTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm")

fun connect(getParameters: (indicator: ProgressIndicator) -> WorkspaceProjectIDE) {

val clientLifetime = LifetimeDefinition()
clientLifetime.launchUnderBackgroundProgress(CoderGatewayBundle.message("gateway.connector.coder.connection.provider.title")) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.coder.gateway.CoderGatewayConstants
import com.coder.gateway.CoderRemoteConnectionHandle
import com.coder.gateway.icons.CoderIcons
import com.coder.gateway.models.WorkspaceAgentListModel
import com.coder.gateway.models.WorkspaceAndAgentStatus
import com.coder.gateway.models.WorkspaceProjectIDE
import com.coder.gateway.models.toWorkspaceProjectIDE
import com.coder.gateway.sdk.CoderRestClient
Expand All @@ -18,10 +17,8 @@ import com.coder.gateway.services.CoderRestClientService
import com.coder.gateway.services.CoderSettingsService
import com.coder.gateway.util.humanizeConnectionError
import com.coder.gateway.util.toURL
import com.coder.gateway.util.withPath
import com.coder.gateway.util.withoutNull
import com.intellij.icons.AllIcons
import com.intellij.ide.BrowserUtil
import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ModalityState
Expand All @@ -33,7 +30,6 @@ import com.intellij.openapi.ui.panel.ComponentPanelBuilder
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenUIManager
import com.intellij.ui.AnimatedIcon
import com.intellij.ui.DocumentAdapter
import com.intellij.ui.JBColor
import com.intellij.ui.SearchTextField
import com.intellij.ui.components.ActionLink
import com.intellij.ui.components.JBScrollPane
Expand Down Expand Up @@ -206,63 +202,61 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
label("").resizableColumn().align(AlignX.FILL)
}.topGap(gap)

connections.forEach { workspaceProjectIDE ->
val enableLinks = listOf(WorkspaceStatus.STOPPED, WorkspaceStatus.CANCELED, WorkspaceStatus.FAILED, WorkspaceStatus.STARTING, WorkspaceStatus.RUNNING).contains(workspaceWithAgent?.workspace?.latestBuild?.status)
val inLoadingState = listOf(WorkspaceStatus.STARTING, WorkspaceStatus.CANCELING, WorkspaceStatus.DELETING, WorkspaceStatus.STOPPING).contains(workspaceWithAgent?.workspace?.latestBuild?.status)
connections.forEach { workspaceProjectIDE ->
val enableLinks = listOf(WorkspaceStatus.STOPPED, WorkspaceStatus.CANCELED, WorkspaceStatus.FAILED, WorkspaceStatus.STARTING, WorkspaceStatus.RUNNING).contains(workspaceWithAgent?.workspace?.latestBuild?.status)
val inLoadingState = listOf(WorkspaceStatus.STARTING, WorkspaceStatus.CANCELING, WorkspaceStatus.DELETING, WorkspaceStatus.STOPPING).contains(workspaceWithAgent?.workspace?.latestBuild?.status)

val actionLink = ActionLink(workspaceProjectIDE.projectPathDisplay) {
withoutNull(deployment?.client, workspaceWithAgent?.workspace) { client, workspace ->
CoderRemoteConnectionHandle().connect {
if (listOf(WorkspaceStatus.STOPPED, WorkspaceStatus.CANCELED, WorkspaceStatus.FAILED).contains(workspace.latestBuild.status)) {
client.startWorkspace(workspace)
}
workspaceProjectIDE
}
GatewayUI.getInstance().reset()
}
}

if (!enableLinks) {
actionLink.foreground = Color.GRAY
actionLink.actionListeners.forEach { actionLink.removeActionListener(it) }
}

row {
if (inLoadingState) {
icon(AnimatedIcon.Default())
}
label(workspaceWithAgent?.status?.description.orEmpty())
row {
if (inLoadingState) {
icon(AnimatedIcon.Default())
}
label(workspaceWithAgent?.status?.description.orEmpty())
}

row {
icon(workspaceProjectIDE.ideProduct.icon)
row {
icon(workspaceProjectIDE.ideProduct.icon)
if (enableLinks) {
cell(
actionLink,
)
label("").resizableColumn().align(AlignX.FILL)
label(workspaceProjectIDE.ideName).applyToComponent {
foreground = JBUI.CurrentTheme.ContextHelp.FOREGROUND
font = ComponentPanelBuilder.getCommentFont(font)
}
label(workspaceProjectIDE.lastOpened.toString()).applyToComponent {
foreground = JBUI.CurrentTheme.ContextHelp.FOREGROUND
font = ComponentPanelBuilder.getCommentFont(font)
}
actionButton(
object : DumbAwareAction(
CoderGatewayBundle.message("gateway.connector.recent-connections.remove.button.tooltip"),
"",
CoderIcons.DELETE,
) {
override fun actionPerformed(e: AnActionEvent) {
recentConnectionsService.removeConnection(workspaceProjectIDE.toRecentWorkspaceConnection())
updateRecentView()
ActionLink(workspaceProjectIDE.projectPathDisplay) {
withoutNull(deployment?.client, workspaceWithAgent?.workspace) { client, workspace ->
CoderRemoteConnectionHandle().connect {
if (listOf(WorkspaceStatus.STOPPED, WorkspaceStatus.CANCELED, WorkspaceStatus.FAILED).contains(workspace.latestBuild.status)) {
client.startWorkspace(workspace)
Comment on lines +233 to +234
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #465 for future improvement

}
workspaceProjectIDE
}
GatewayUI.getInstance().reset()
}
},
)
} else {
label(workspaceProjectIDE.projectPathDisplay).applyToComponent {
foreground = Color.GRAY
}
}
label("").resizableColumn().align(AlignX.FILL)
label(workspaceProjectIDE.ideName).applyToComponent {
foreground = JBUI.CurrentTheme.ContextHelp.FOREGROUND
font = ComponentPanelBuilder.getCommentFont(font)
}
label(workspaceProjectIDE.lastOpened.toString()).applyToComponent {
foreground = JBUI.CurrentTheme.ContextHelp.FOREGROUND
font = ComponentPanelBuilder.getCommentFont(font)
}
actionButton(
object : DumbAwareAction(
CoderGatewayBundle.message("gateway.connector.recent-connections.remove.button.tooltip"),
"",
CoderIcons.DELETE,
) {
override fun actionPerformed(e: AnActionEvent) {
recentConnectionsService.removeConnection(workspaceProjectIDE.toRecentWorkspaceConnection())
updateRecentView()
}
},
)
}

}
}
}
}.apply {
Expand Down
Loading
0