Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit30839c8

Browse files
committed
Fix selection when workspace name collides
This can happen if multiple users are using the same name for theirworkspaces.Turns out we can just match the workspace ID.It hardly seems worth a test to see that a == is working, so I did notbother to update it.
1 parent0f66e3e commit30839c8

File tree

3 files changed

+13
-65
lines changed

3 files changed

+13
-65
lines changed

‎src/main/kotlin/com/coder/gateway/models/WorkspaceAgentListModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ data class WorkspaceAgentListModel(
1616
varicon:Icon? =null,
1717
// The combined status of the workspace and agent to display on the row.
1818
valstatus:WorkspaceAndAgentStatus =WorkspaceAndAgentStatus.from(workspace, agent),
19-
// The combined `workspace.agent` name to display on the row.
19+
// The combined `workspace.agent` name to display on the row. Users can have workspaces with the same name, so it
20+
// must not be used as a unique identifier.
2021
valname:String =if (agent != null)"${workspace.name}.${agent.name}"else workspace.name,
2122
)

‎src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -989,17 +989,19 @@ class WorkspacesTable : TableView<WorkspaceAgentListModel>(WorkspacesTableModel(
989989
}
990990
}
991991

992-
fungetNewSelection(oldSelection:WorkspaceAgentListModel?):Int {
992+
/**
993+
* If a row becomes unselected because the workspace turned on, find the
994+
* first agent row and select that.
995+
*
996+
* If a row becomes unselected because the workspace turned off, find the
997+
* workspace row and select that.
998+
*/
999+
privatefungetNewSelection(oldSelection:WorkspaceAgentListModel?):Int {
9931000
if (oldSelection==null) {
9941001
return-1
9951002
}
996-
val index= listTableModel.items.indexOfFirst { it.name== oldSelection.name }
997-
if (index>-1) {
998-
return index
999-
}
1000-
// If there is no matching agent, try matching on just the workspace.
1001-
// It is possible it turned off so it no longer has agents displaying;
1002-
// in this case we want to keep it highlighted.
1003-
return listTableModel.items.indexOfFirst { it.workspace.name== oldSelection.workspace.name }
1003+
// Both cases are handled by just looking for the ID, since we only ever
1004+
// show agents or a workspace but never both.
1005+
return listTableModel.items.indexOfFirst { it.workspace.id== oldSelection.workspace.id }
10041006
}
10051007
}

‎src/test/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepViewTest.kt

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp