From 48c443c1021639c3f530b6c91d5aba58a32e397c Mon Sep 17 00:00:00 2001 From: Tomasz Naumowicz Date: Fri, 18 Sep 2026 05:47:18 +0000 Subject: [PATCH 1/2] Label bulk connection deletion accurately --- package.json | 18 ++++++- .../localQuickStart/contributions.test.ts | 1 + .../removeConnection.packageJson.test.ts | 50 +++++++++++++++++++ src/documentdb/ClustersExtension.ts | 4 ++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/commands/removeConnection/removeConnection.packageJson.test.ts diff --git a/package.json b/package.json index e9a27db60..6cb1ec923 100644 --- a/package.json +++ b/package.json @@ -421,6 +421,12 @@ "command": "vscode-documentdb.command.connectionsView.removeConnection", "title": "Delete Connection…" }, + { + "//": "[ConnectionsView] Delete Selected Connections", + "category": "DocumentDB", + "command": "vscode-documentdb.command.connectionsView.removeSelectedConnections", + "title": "Delete Selected Connections…" + }, { "//": "[ConnectionsView] Create Folder", "category": "DocumentDB", @@ -926,7 +932,13 @@ { "//": "Delete Connection...", "command": "vscode-documentdb.command.connectionsView.removeConnection", - "when": "view == connectionsView && viewItem =~ /\\btreeitem_documentdbcluster\\b/i", + "when": "view == connectionsView && viewItem =~ /\\btreeitem_documentdbcluster\\b/i && !listMultiSelection", + "group": "4@1" + }, + { + "//": "Delete Selected Connections...", + "command": "vscode-documentdb.command.connectionsView.removeSelectedConnections", + "when": "view == connectionsView && viewItem =~ /\\btreeitem_documentdbcluster\\b/i && listMultiSelection", "group": "4@1" }, { @@ -1335,6 +1347,10 @@ "command": "vscode-documentdb.command.connectionsView.removeConnection", "when": "never" }, + { + "command": "vscode-documentdb.command.connectionsView.removeSelectedConnections", + "when": "never" + }, { "command": "vscode-documentdb.command.connectionsView.createFolder", "when": "never" diff --git a/src/commands/localQuickStart/contributions.test.ts b/src/commands/localQuickStart/contributions.test.ts index efca9d2e5..a6f353877 100644 --- a/src/commands/localQuickStart/contributions.test.ts +++ b/src/commands/localQuickStart/contributions.test.ts @@ -137,6 +137,7 @@ describe('Local Quick Start cluster-command opt-in (UX review item 20)', () => { 'vscode-documentdb.command.connectionsView.renameConnection', 'vscode-documentdb.command.connectionsView.moveItems', 'vscode-documentdb.command.connectionsView.removeConnection', + 'vscode-documentdb.command.connectionsView.removeSelectedConnections', 'vscode-documentdb.command.connectionsView.updateCredentials', 'vscode-documentdb.command.connectionsView.updateConnectionString', 'vscode-documentdb.command.accessDataMigrationServices', diff --git a/src/commands/removeConnection/removeConnection.packageJson.test.ts b/src/commands/removeConnection/removeConnection.packageJson.test.ts new file mode 100644 index 000000000..169d0785e --- /dev/null +++ b/src/commands/removeConnection/removeConnection.packageJson.test.ts @@ -0,0 +1,50 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as fs from 'fs'; +import * as path from 'path'; + +interface MenuContribution { + readonly command: string; + readonly when?: string; +} + +interface PackageContributions { + readonly commands: readonly { readonly command: string; readonly title: string }[]; + readonly menus: { + readonly 'view/item/context': readonly MenuContribution[]; + readonly commandPalette: readonly MenuContribution[]; + }; +} + +describe('remove connection command contributions', () => { + let contributes: PackageContributions; + + beforeAll(() => { + const packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../../package.json'), 'utf8')) as { + contributes: PackageContributions; + }; + contributes = packageJson.contributes; + }); + + it.each([ + [ + 'vscode-documentdb.command.connectionsView.removeConnection', + 'Delete Connection…', + '!listMultiSelection', + ], + [ + 'vscode-documentdb.command.connectionsView.removeSelectedConnections', + 'Delete Selected Connections…', + 'listMultiSelection', + ], + ])('declares and gates %s', (command, title, selectionGate) => { + expect(contributes.commands).toContainEqual(expect.objectContaining({ command, title })); + const menuEntry = contributes.menus['view/item/context'].find((entry) => entry.command === command); + expect(menuEntry?.when).toContain('treeitem_documentdbcluster'); + expect(menuEntry?.when).toMatch(new RegExp(`&& ${selectionGate.replace('!', '\\!')}$`)); + expect(contributes.menus.commandPalette).toContainEqual(expect.objectContaining({ command, when: 'never' })); + }); +}); \ No newline at end of file diff --git a/src/documentdb/ClustersExtension.ts b/src/documentdb/ClustersExtension.ts index 0d906c55d..0d9aa824d 100644 --- a/src/documentdb/ClustersExtension.ts +++ b/src/documentdb/ClustersExtension.ts @@ -882,6 +882,10 @@ export class ClustersExtension implements vscode.Disposable { 'vscode-documentdb.command.connectionsView.removeConnection', withTreeNodeCommandCorrelation(removeConnection), ); + registerCommandWithTreeNodeUnwrapping( + 'vscode-documentdb.command.connectionsView.removeSelectedConnections', + withTreeNodeCommandCorrelation(removeConnection), + ); registerCommandWithTreeNodeUnwrapping( 'vscode-documentdb.command.connectionsView.renameConnection', From 6d295ee3e71b79a98373c6be8e6344615e9cf35c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 18 Sep 2026 08:15:07 +0000 Subject: [PATCH 2/2] Format deletion command manifest test Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com> --- .../removeConnection/removeConnection.packageJson.test.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/commands/removeConnection/removeConnection.packageJson.test.ts b/src/commands/removeConnection/removeConnection.packageJson.test.ts index 169d0785e..ac64213f6 100644 --- a/src/commands/removeConnection/removeConnection.packageJson.test.ts +++ b/src/commands/removeConnection/removeConnection.packageJson.test.ts @@ -30,11 +30,7 @@ describe('remove connection command contributions', () => { }); it.each([ - [ - 'vscode-documentdb.command.connectionsView.removeConnection', - 'Delete Connection…', - '!listMultiSelection', - ], + ['vscode-documentdb.command.connectionsView.removeConnection', 'Delete Connection…', '!listMultiSelection'], [ 'vscode-documentdb.command.connectionsView.removeSelectedConnections', 'Delete Selected Connections…', @@ -47,4 +43,4 @@ describe('remove connection command contributions', () => { expect(menuEntry?.when).toMatch(new RegExp(`&& ${selectionGate.replace('!', '\\!')}$`)); expect(contributes.menus.commandPalette).toContainEqual(expect.objectContaining({ command, when: 'never' })); }); -}); \ No newline at end of file +});