Skip to content

Commit 52efbbd

Browse files
authored
VSCODE-181: Move extension commands into a single file in src/commands (#185)
1 parent 93271f4 commit 52efbbd

9 files changed

+121
-124
lines changed

src/commands/README.md

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,5 @@
11
# Extension Commands
22

3-
This README contains a list of all of the commands the extension handles.
3+
The `index.ts` file in this folder contains a list of all of the commands the extension handles.
44

5-
These commands are defined in `package.json`, registered from `extension.ts` to
6-
handlers defined in `mdb.ts`.
7-
Think RPC handlers.
8-
9-
## Connection commands
10-
11-
- `mdb.connect`
12-
- `mdb.connectWithURI`
13-
- `mdb.disconnect`
14-
- `mdb.removeConnection`
15-
- `mdb.reload`
16-
- `mdb.refresh`
17-
18-
- `mdb.openMongoDBShell`
19-
- `mdb.openOverviewPage`
20-
21-
## General database commands
22-
23-
- `mdb.createDatabase`
24-
- `mdb.createCollection`
25-
26-
- `mdb.createDocument`
27-
- `mdb.removeDocument`
28-
- `mdb.updateDocument`
29-
30-
- `mdb.viewCollectionDocuments`
31-
32-
## Query commands (json input fields)
33-
34-
- `mdb.aggregate`
35-
- `mdb.explainAggregate`
36-
- `mdb.find`
37-
- `mdb.findOne`
38-
- `mdb.findBy` _-> pick(value) -> pick(key) -> show_
39-
- `mdb.explain` _Uses the active cursor (only possible after a query)_
40-
- `mdb.getMore` _Uses the active cursor (only possible after a query)_
41-
42-
## Playground commands
43-
44-
- `mdb.playground`
45-
- `mdb.createPlayground`
46-
- `mdb.removePlayground`
47-
- `mdb.runPlaygroundBlock`
48-
- `mdb.runSelectedPlaygroundBlocks`
49-
- `mdb.runAllPlaygroundBlocks`
50-
- `mdb.createNewPlaygroundFromViewAction`
51-
- `mdb.createNewPlaygroundFromOverviewPage`
52-
53-
## Index commands
54-
55-
- `mdb.createIndex`
56-
- `mdb.getIndex`
57-
- `mdb.removeIndex`
58-
59-
## Import/Export commands
60-
61-
- `mdb.importDocument`
62-
63-
- `mdb.import`
64-
- `mdb.cancelImport`
65-
- `mdb.export`
66-
- `mdb.cancelExport`
67-
68-
## CodeLens commands
69-
70-
- `mdb.codeLens.showMoreDocumentsClicked`
5+
These commands are defined in `package.json` and registered in our extension.

src/commands/index.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
enum EXTENSION_COMMANDS {
3+
MDB_CONNECT = 'mdb.connect',
4+
MDB_CONNECT_WITH_URI = 'mdb.connectWithURI',
5+
MDB_OPEN_OVERVIEW_PAGE = 'mdb.openOverviewPage',
6+
MDB_DISCONNECT = 'mdb.disconnect',
7+
MDB_REMOVE_CONNECTION = 'mdb.removeConnection',
8+
9+
MDB_OPEN_MDB_SHELL = 'mdb.openMongoDBShell',
10+
MDB_OPEN_MDB_SHELL_FROM_TREE_VIEW = 'mdb.treeViewOpenMongoDBShell',
11+
12+
MDB_CREATE_PLAYGROUND = 'mdb.createPlayground',
13+
MDB_CREATE_PLAYGROUND_FROM_OVERVIEW_PAGE = 'mdb.createNewPlaygroundFromOverviewPage',
14+
MDB_RUN_SELECTED_PLAYGROUND_BLOCKS = 'mdb.runSelectedPlaygroundBlocks',
15+
MDB_RUN_ALL_PLAYGROUND_BLOCKS = 'mdb.runAllPlaygroundBlocks',
16+
MDB_RUN_ALL_OR_SELECTED_PLAYGROUND_BLOCKS = 'mdb.runPlayground',
17+
18+
MDB_CHANGE_ACTIVE_CONNECTION = 'mdb.changeActiveConnection',
19+
MDB_REFRESH_PLAYGROUNDS = 'mdb.refreshPlaygrounds',
20+
MDB_START_LANGUAGE_STREAM_LOGS = 'mdb.startStreamLanguageServerLogs',
21+
22+
MDB_CODELENS_SHOW_MORE_DOCUMENTS = 'mdb.codeLens.showMoreDocumentsClicked',
23+
24+
// Commands from the tree view.
25+
MDB_ADD_CONNECTION = 'mdb.addConnection',
26+
MDB_ADD_CONNECTION_WITH_URI = 'mdb.addConnectionWithURI',
27+
MDB_REFRESH_PLAYGROUNDS_FROM_TREE_VIEW = 'mdb.refreshPlaygroundsFromTreeView',
28+
MDB_OPEN_PLAYGROUND_FROM_TREE_VIEW = 'mdb.openPlaygroundFromTreeItem',
29+
MDB_CONNECT_TO_CONNECTION_TREE_VIEW = 'mdb.connectToConnectionTreeItem',
30+
MDB_CREATE_PLAYGROUND_FROM_VIEW_ACTION = 'mdb.createNewPlaygroundFromViewAction',
31+
MDB_CREATE_PLAYGROUND_FROM_PLAYGROUND_EXPLORER = 'mdb.createNewPlaygroundFromPlaygroundExplorer',
32+
MDB_DISCONNECT_FROM_CONNECTION_TREE_VIEW = 'mdb.disconnectFromConnectionTreeItem',
33+
MDB_REFRESH_CONNECTION = 'mdb.refreshConnection',
34+
MDB_COPY_CONNECTION_STRING = 'mdb.copyConnectionString',
35+
MDB_REMOVE_CONNECTION_TREE_VIEW = 'mdb.treeItemRemoveConnection',
36+
MDB_RENAME_CONNECTION = 'mdb.renameConnection',
37+
MDB_ADD_DATABASE = 'mdb.addDatabase',
38+
MDB_SEARCH_FOR_DOCUMENTS = 'mdb.searchForDocuments',
39+
MDB_COPY_DATABASE_NAME = 'mdb.copyDatabaseName',
40+
MDB_DROP_DATABASE = 'mdb.dropDatabase',
41+
MDB_REFRESH_DATABASE = 'mdb.refreshDatabase',
42+
MDB_ADD_COLLECTION = 'mdb.addCollection',
43+
MDB_COPY_COLLECTION_NAME = 'mdb.copyCollectionName',
44+
MDB_DROP_COLLECTION = 'mdb.dropCollection',
45+
MDB_VIEW_DOCUMENT = 'mdb.viewDocument',
46+
MDB_VIEW_COLLECTION_DOCUMENTS = 'mdb.viewCollectionDocuments',
47+
MDB_REFRESH_COLLECTION = 'mdb.refreshCollection',
48+
MDB_REFRESH_DOCUMENT_LIST = 'mdb.refreshDocumentList',
49+
MDB_REFRESH_SCHEMA = 'mdb.refreshSchema',
50+
MDB_COPY_SCHEMA_FIELD_NAME = 'mdb.copySchemaFieldName',
51+
MDB_REFRESH_INDEXES = 'mdb.refreshIndexes',
52+
MDB_CREATE_INDEX_TREE_VIEW = 'mdb.createIndexFromTreeView'
53+
}
54+
55+
export default EXTENSION_COMMANDS;

src/editors/activeConnectionCodeLensProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from 'vscode';
2+
import EXTENSION_COMMANDS from '../commands';
23

34
export default class ActiveConnectionCodeLensProvider
45
implements vscode.CodeLensProvider {
@@ -35,7 +36,7 @@ export default class ActiveConnectionCodeLensProvider
3536

3637
codeLens.command = {
3738
title: message,
38-
command: 'mdb.changeActiveConnection',
39+
command: EXTENSION_COMMANDS.MDB_CHANGE_ACTIVE_CONNECTION,
3940
arguments: []
4041
};
4142

src/editors/collectionDocumentsCodeLensProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { URLSearchParams } from 'url';
22
import * as vscode from 'vscode';
3+
import EXTENSION_COMMANDS from '../commands';
34

45
import CollectionDocumentsOperationStore from './collectionDocumentsOperationsStore';
56
import {
@@ -88,7 +89,7 @@ export default class CollectionDocumentsCodeLensProvider implements vscode.CodeL
8889
codeLens.command = {
8990
title: commandTitle,
9091
tooltip: commandTooltip,
91-
command: 'mdb.codeLens.showMoreDocumentsClicked',
92+
command: EXTENSION_COMMANDS.MDB_CODELENS_SHOW_MORE_DOCUMENTS,
9293
arguments: [{ operationId, connectionId, namespace }]
9394
};
9495

src/editors/partialExecutionCodeLensProvider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from 'vscode';
2+
import EXTENSION_COMMANDS from '../commands';
23

34
export default class PartialExecutionCodeLensProvider
45
implements vscode.CodeLensProvider {
@@ -33,11 +34,11 @@ export default class PartialExecutionCodeLensProvider
3334
}
3435

3536
public resolveCodeLens?(codeLens: vscode.CodeLens): vscode.CodeLens {
36-
const message = `► Run Selected Lines From Playground`;
37+
const message = '► Run Selected Lines From Playground';
3738

3839
codeLens.command = {
3940
title: message,
40-
command: 'mdb.runSelectedPlaygroundBlocks',
41+
command: EXTENSION_COMMANDS.MDB_RUN_SELECTED_PLAYGROUND_BLOCKS,
4142
arguments: [message]
4243
};
4344

src/explorer/explorerTreeController.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { DOCUMENT_LIST_ITEM, CollectionTypes } from './documentListTreeItem';
88
import ConnectionTreeItem from './connectionTreeItem';
99
import { SavedConnection } from '../storage/storageController';
1010
import { sortTreeItemsByLabel } from './treeItemUtils';
11+
import EXTENSION_COMMANDS from '../commands';
1112

1213
const log = createLogger('explorer controller');
1314

@@ -98,7 +99,7 @@ implements vscode.TreeDataProvider<vscode.TreeItem> {
9899

99100
if (selectedItem.contextValue === DOCUMENT_ITEM) {
100101
vscode.commands.executeCommand(
101-
'mdb.viewDocument',
102+
EXTENSION_COMMANDS.MDB_VIEW_DOCUMENT,
102103
event.selection[0]
103104
);
104105
}
@@ -108,7 +109,7 @@ implements vscode.TreeDataProvider<vscode.TreeItem> {
108109
selectedItem.type === CollectionTypes.view
109110
) {
110111
vscode.commands.executeCommand(
111-
'mdb.viewCollectionDocuments',
112+
EXTENSION_COMMANDS.MDB_VIEW_COLLECTION_DOCUMENTS,
112113
event.selection[0]
113114
);
114115
}

src/explorer/playgroundsTree.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import PlaygroundsTreeHeader from './playgroundsTreeHeader';
55
import { PLAYGROUND_ITEM } from './playgroundsTreeItem';
66
import { createLogger } from '../logging';
77
import PlaygroundsTreeItem from './playgroundsTreeItem';
8+
import EXTENSION_COMMANDS from '../commands';
89

910
const micromatch = require('micromatch');
1011
const log = createLogger('playgrounds tree controller');
@@ -122,7 +123,7 @@ implements vscode.TreeDataProvider<vscode.TreeItem> {
122123

123124
if (selectedItem.contextValue === PLAYGROUND_ITEM) {
124125
vscode.commands.executeCommand(
125-
'mdb.openPlaygroundFromTreeItem',
126+
EXTENSION_COMMANDS.MDB_OPEN_PLAYGROUND_FROM_TREE_VIEW,
126127
selectedItem
127128
);
128129
}

0 commit comments

Comments
 (0)