Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
},
{
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/commands/localQuickStart/contributions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------------------------
* 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' }));
});
});
4 changes: 4 additions & 0 deletions src/documentdb/ClustersExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading