Skip to content
Next Next commit
revise recent projects flow to be less confusing
  • Loading branch information
bcpeinhardt committed Aug 14, 2024
commit a51beea09be2aef40a47071c2daca2cd2d925816
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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 Down Expand Up @@ -193,11 +194,11 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
TopGap.MEDIUM
}
row {
icon(status.first).applyToComponent {
foreground = status.second
}.align(AlignX.LEFT).gap(RightGap.SMALL).applyToComponent {
size = Dimension(JBUI.scale(16), JBUI.scale(16))
}
// icon(status.first).applyToComponent {
// foreground = status.second
// }.align(AlignX.LEFT).gap(RightGap.SMALL).applyToComponent {
// size = Dimension(JBUI.scale(16), JBUI.scale(16))
// }
label(workspaceName).applyToComponent {
font = JBFont.h3().asBold()
}.align(AlignX.LEFT).gap(RightGap.SMALL)
Expand Down Expand Up @@ -280,41 +281,47 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
if (deploymentError == null || showError) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we might want to add this check back or something similar to it. It is poorly named but basically it was making sure we only display an API error on the first workspace rather than duplicating it on each workspace (it was pretty noisy, especially since the API errors can get long).

For example, say you have 5 workspaces and your token expires, you see a message about being unauthorized and to check your token 5 times on the page.

Or we could group workspaces under a deployment heading and show the API error under the deployment heading, but that might be out of scope for this PR.

Copy link
Collaborator Author

@bcpeinhardt bcpeinhardt Aug 19, 2024

Choose a reason for hiding this comment

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

It looks like atm the moment I actually have this inside the connections.foEach loop (which makes me think with multiple WorkpaceProjectIDE combos it would render multiple times). I didn't notice because I was visually testing with one recent connection.
I'll pull it out of the loop and add the check.

^^^ My adhd is going to quickly become a driving force for building out E2E suites.

row {
// There must be a way to make this properly wrap?
if (status.first == CoderIcons.PENDING) {
icon(status.first)
}
label("<html><body style='width:350px;'>" + status.third + "</html>").applyToComponent {
foreground = status.second
}
}
}
connections.forEach { workspaceProjectIDE ->
row {
icon(workspaceProjectIDE.ideProduct.icon)
cell(
ActionLink(workspaceProjectIDE.projectPathDisplay) {
CoderRemoteConnectionHandle().connect { workspaceProjectIDE }
GatewayUI.getInstance().reset()
},
)
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)
if (workspaceWithAgent?.workspace?.latestBuild?.status == WorkspaceStatus.RUNNING && workspaceWithAgent.status == WorkspaceAndAgentStatus.READY) {
row { label("Select a project to launch.") }
connections.forEach { workspaceProjectIDE ->
row {
icon(workspaceProjectIDE.ideProduct.icon)
cell(
ActionLink(workspaceProjectIDE.projectPathDisplay) {
CoderRemoteConnectionHandle().connect { workspaceProjectIDE }
GatewayUI.getInstance().reset()
},
)
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()
}
},
)
}
actionButton(
object : DumbAwareAction(
CoderGatewayBundle.message("gateway.connector.recent-connections.remove.button.tooltip"),
"",
CoderIcons.DELETE,
) {
override fun actionPerformed(e: AnActionEvent) {
recentConnectionsService.removeConnection(workspaceProjectIDE.toRecentWorkspaceConnection())
updateRecentView()
}
},
)
}
}
}
Expand Down
Loading