Summary
The Connections View tree has canSelectMany: true, but most context menu commands only operate on a single item. When multiple items are selected, these commands either silently act on only the first item or fail. We need to either:
- Hide single-item commands when multiple items are selected (add
&& !listMultiSelection to when)
- Add multi-select support where batch operations make sense
How listMultiSelection works
VS Code provides the listMultiSelection context key, which is true when more than one item is selected in a tree view. Use it in the when clause of view/item/context menu entries in package.json:
// Hide when multiple items are selected:
"when": "view == connectionsView && viewItem =~ /.../ && !listMultiSelection"
// Show ONLY when multiple items are selected:
"when": "view == connectionsView && viewItem =~ /.../ && listMultiSelection"
Note: Only the connectionsView has canSelectMany: true. The discoveryView and Azure Resource views do not, so their commands are unaffected.
Already handled
| Command |
Status |
Delete Connection (removeConnection) |
Multi-select supported (#667) |
Move to Folder (moveItems) |
Multi-select supported |
Commands to revisit
Cluster-level (connectionsView only)
| Command |
Recommendation |
Update Connection String (updateConnectionString) |
Add !listMultiSelection |
Update Credentials (updateCredentials) |
Add !listMultiSelection |
Rename Connection (renameConnection) |
Add !listMultiSelection |
Cluster-level (shared across views)
| Command |
Recommendation |
Create Database (createDatabase) |
Add !listMultiSelection |
Copy Connection String (copyConnectionString) |
Add !listMultiSelection |
Open Interactive Shell (shell.open) |
Add !listMultiSelection |
Data Migration (accessDataMigrationServices) |
Add !listMultiSelection |
Database-level
| Command |
Recommendation |
Create Collection (createCollection) |
Add !listMultiSelection |
Drop Database (dropDatabase) |
Add !listMultiSelection — or add multi-delete support |
Paste Collection (pasteCollection on database) |
Add !listMultiSelection |
Open Shell (shell.open on database) |
Add !listMultiSelection |
Open Shell inline (shell.open.inline on database) |
Add !listMultiSelection |
New Playground (playground.new on database) |
Add !listMultiSelection |
Copy Reference (copyReference on database) |
Add !listMultiSelection |
Collection-level
| Command |
Recommendation |
Open Collection (containerView.open) |
Add !listMultiSelection |
Open Collection inline (containerView.open.inline) |
Add !listMultiSelection |
Create Document (createDocument) |
Add !listMultiSelection |
Import Documents (importDocuments) |
Add !listMultiSelection |
Export Documents (exportDocuments) |
Add !listMultiSelection |
Drop Collection (dropCollection) |
Add !listMultiSelection — or add multi-delete support |
Copy Collection (copyCollection) |
Add !listMultiSelection |
Paste Collection (pasteCollection on collection) |
Add !listMultiSelection |
Open Shell (shell.open on collection) |
Add !listMultiSelection |
Open Shell inline (shell.open.inline on collection) |
Add !listMultiSelection |
New Playground (playground.new on collection) |
Add !listMultiSelection |
New Playground inline (playground.new.inline) |
Add !listMultiSelection |
Copy Reference (copyReference on collection) |
Add !listMultiSelection |
Index-level
| Command |
Recommendation |
Hide Index (hideIndex) |
Add !listMultiSelection |
Unhide Index (unhideIndex) |
Add !listMultiSelection |
Drop Index (dropIndex) |
Add !listMultiSelection — or add multi-drop support |
Copy Reference (copyReference on index) |
Add !listMultiSelection |
Folder-level
| Command |
Recommendation |
New Connection in Folder (newConnectionInFolder) |
Add !listMultiSelection |
Create Subfolder (createSubfolder) |
Add !listMultiSelection |
Rename Folder (renameFolder) |
Add !listMultiSelection |
Delete Folder (deleteFolder) |
Add !listMultiSelection — or add multi-delete support |
Refresh commands
| Command |
Recommendation |
Refresh (refresh on various viewItems) |
Add !listMultiSelection |
Candidates for multi-select support
These destructive/batch operations would benefit from multi-select rather than just hiding:
- Drop Collection — natural batch operation, same pattern as
removeConnection
- Drop Database — natural batch operation
- Delete Folder — natural batch operation
- Drop Index — natural batch operation
- Copy Reference — could copy multiple references to clipboard
Implementation notes
- The simplest fix for most commands is a one-line
when clause update in package.json
- For commands that should support multi-select, follow the pattern in
removeConnection.ts: accept nodes?: T[], build a list, loop with resilient error handling
- The
TreeNodeCommandCallback<T> type from @microsoft/vscode-azext-utils already supports (context, node?, nodes?, ...args) — no framework changes needed
Summary
The Connections View tree has
canSelectMany: true, but most context menu commands only operate on a single item. When multiple items are selected, these commands either silently act on only the first item or fail. We need to either:&& !listMultiSelectiontowhen)How
listMultiSelectionworksVS Code provides the
listMultiSelectioncontext key, which istruewhen more than one item is selected in a tree view. Use it in thewhenclause ofview/item/contextmenu entries inpackage.json:Already handled
removeConnection)moveItems)Commands to revisit
Cluster-level (connectionsView only)
updateConnectionString)!listMultiSelectionupdateCredentials)!listMultiSelectionrenameConnection)!listMultiSelectionCluster-level (shared across views)
createDatabase)!listMultiSelectioncopyConnectionString)!listMultiSelectionshell.open)!listMultiSelectionaccessDataMigrationServices)!listMultiSelectionDatabase-level
createCollection)!listMultiSelectiondropDatabase)!listMultiSelection— or add multi-delete supportpasteCollectionon database)!listMultiSelectionshell.openon database)!listMultiSelectionshell.open.inlineon database)!listMultiSelectionplayground.newon database)!listMultiSelectioncopyReferenceon database)!listMultiSelectionCollection-level
containerView.open)!listMultiSelectioncontainerView.open.inline)!listMultiSelectioncreateDocument)!listMultiSelectionimportDocuments)!listMultiSelectionexportDocuments)!listMultiSelectiondropCollection)!listMultiSelection— or add multi-delete supportcopyCollection)!listMultiSelectionpasteCollectionon collection)!listMultiSelectionshell.openon collection)!listMultiSelectionshell.open.inlineon collection)!listMultiSelectionplayground.newon collection)!listMultiSelectionplayground.new.inline)!listMultiSelectioncopyReferenceon collection)!listMultiSelectionIndex-level
hideIndex)!listMultiSelectionunhideIndex)!listMultiSelectiondropIndex)!listMultiSelection— or add multi-drop supportcopyReferenceon index)!listMultiSelectionFolder-level
newConnectionInFolder)!listMultiSelectioncreateSubfolder)!listMultiSelectionrenameFolder)!listMultiSelectiondeleteFolder)!listMultiSelection— or add multi-delete supportRefresh commands
refreshon various viewItems)!listMultiSelectionCandidates for multi-select support
These destructive/batch operations would benefit from multi-select rather than just hiding:
removeConnectionImplementation notes
whenclause update inpackage.jsonremoveConnection.ts: acceptnodes?: T[], build a list, loop with resilient error handlingTreeNodeCommandCallback<T>type from@microsoft/vscode-azext-utilsalready supports(context, node?, nodes?, ...args)— no framework changes needed