Skip to content

Audit context menu commands for tree view multi-select support #668

@tnaum-ms

Description

@tnaum-ms

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:

  1. Hide single-item commands when multiple items are selected (add && !listMultiSelection to when)
  2. 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 !listMultiSelectionor 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions