-
Notifications
You must be signed in to change notification settings - Fork 91
feat(tree-explorer): add ability to set preset connections in settings.json VSCODE-665 #909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
db87e39
06b1e90
d2d58e6
bf9cd64
0128835
0850375
bf39230
a72bad8
6cf0f1c
63c719d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,5 +16,11 @@ | |
| "out": true | ||
| }, | ||
| // Turn off tsc task auto detection since we have the necessary tasks as npm scripts | ||
| "typescript.tsc.autoDetect": "off" | ||
| "typescript.tsc.autoDetect": "off", | ||
| "mdb.presetSavedConnections": [ | ||
|
||
| { | ||
| "name": "Local Test", | ||
| "connectionString": "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000" | ||
| } | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -320,6 +320,10 @@ | |
| "command": "mdb.copyConnectionString", | ||
| "title": "Copy Connection String" | ||
| }, | ||
| { | ||
| "command": "mdb.openWorkspaceSettingsFile", | ||
| "title": "Open Workspace Settings" | ||
| }, | ||
| { | ||
| "command": "mdb.renameConnection", | ||
| "title": "Rename Connection..." | ||
|
|
@@ -499,32 +503,32 @@ | |
| "view/item/context": [ | ||
| { | ||
| "command": "mdb.addDatabase", | ||
| "when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem && mdb.isAtlasStreams == false", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == connectedConnectionTreeItem || viewItem == connectedImmutableConnectionTreeItem) && mdb.isAtlasStreams == false", | ||
| "group": "inline" | ||
| }, | ||
| { | ||
| "command": "mdb.addDatabase", | ||
| "when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem && mdb.isAtlasStreams == false", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == connectedConnectionTreeItem || viewItem == connectedImmutableConnectionTreeItem) && mdb.isAtlasStreams == false", | ||
| "group": "1@1" | ||
| }, | ||
| { | ||
| "command": "mdb.addStreamProcessor", | ||
| "when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem && mdb.isAtlasStreams == true", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == connectedConnectionTreeItem || viewItem == connectedImmutableConnectionTreeItem) && mdb.isAtlasStreams == true", | ||
| "group": "inline" | ||
| }, | ||
| { | ||
| "command": "mdb.addStreamProcessor", | ||
| "when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem && mdb.isAtlasStreams == true", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == connectedConnectionTreeItem || viewItem == connectedImmutableConnectionTreeItem) && mdb.isAtlasStreams == true", | ||
| "group": "1@1" | ||
| }, | ||
| { | ||
| "command": "mdb.refreshConnection", | ||
| "when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == connectedConnectionTreeItem || viewItem == connectedImmutableConnectionTreeItem)", | ||
| "group": "1@2" | ||
| }, | ||
| { | ||
| "command": "mdb.treeViewOpenMongoDBShell", | ||
| "when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == connectedConnectionTreeItem || viewItem == connectedImmutableConnectionTreeItem)", | ||
| "group": "2@1" | ||
| }, | ||
| { | ||
|
|
@@ -537,14 +541,19 @@ | |
| "when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem", | ||
| "group": "3@2" | ||
| }, | ||
| { | ||
| "command": "mdb.openWorkspaceSettingsFile", | ||
|
||
| "when": "view == mongoDBConnectionExplorer && (viewItem == connectedImmutableConnectionTreeItem)", | ||
| "group": "3@2" | ||
| }, | ||
| { | ||
| "command": "mdb.copyConnectionString", | ||
| "when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == connectedConnectionTreeItem || viewItem == connectedImmutableConnectionTreeItem)", | ||
| "group": "4@1" | ||
| }, | ||
| { | ||
| "command": "mdb.disconnectFromConnectionTreeItem", | ||
| "when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == connectedConnectionTreeItem || viewItem == connectedImmutableConnectionTreeItem)", | ||
| "group": "5@1" | ||
| }, | ||
| { | ||
|
|
@@ -559,7 +568,7 @@ | |
| }, | ||
| { | ||
| "command": "mdb.connectToConnectionTreeItem", | ||
| "when": "view == mongoDBConnectionExplorer && viewItem == disconnectedConnectionTreeItem", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == disconnectedConnectionTreeItem || viewItem == disconnectedImmutableConnectionTreeItem)", | ||
| "group": "1@1" | ||
| }, | ||
| { | ||
|
|
@@ -572,9 +581,14 @@ | |
| "when": "view == mongoDBConnectionExplorer && viewItem == disconnectedConnectionTreeItem", | ||
| "group": "2@2" | ||
| }, | ||
| { | ||
| "command": "mdb.openWorkspaceSettingsFile", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == disconnectedImmutableConnectionTreeItem)", | ||
| "group": "2@2" | ||
| }, | ||
| { | ||
| "command": "mdb.copyConnectionString", | ||
| "when": "view == mongoDBConnectionExplorer && viewItem == disconnectedConnectionTreeItem", | ||
| "when": "view == mongoDBConnectionExplorer && (viewItem == disconnectedConnectionTreeItem || viewItem == disconnectedImmutableConnectionTreeItem)", | ||
| "group": "3@1" | ||
| }, | ||
| { | ||
|
|
@@ -1171,6 +1185,28 @@ | |
| "type": "string", | ||
| "default": "", | ||
| "description": "Specify a shell command that is run to start the browser for authenticating with the OIDC identity provider for the server connection. Leave this empty for default browser." | ||
| }, | ||
| "mdb.presetSavedConnections": { | ||
| "scope": "window", | ||
| "type": "array", | ||
| "description": "Defines preset saved connections.", | ||
| "items": { | ||
| "type": "object", | ||
| "properties": { | ||
| "name": { | ||
| "type": "string", | ||
| "description": "Name of the connection." | ||
| }, | ||
| "connectionString": { | ||
| "type": "string", | ||
| "description": "Connection string. Do not store sensitive credentials here." | ||
| } | ||
| }, | ||
| "required": [ | ||
| "name", | ||
| "connectionString" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,10 +12,9 @@ | |
| import type TreeItemParent from './treeItemParentInterface'; | ||
| import StreamProcessorTreeItem from './streamProcessorTreeItem'; | ||
|
|
||
| export enum ConnectionItemContextValues { | ||
| disconnected = 'disconnectedConnectionTreeItem', | ||
| connected = 'connectedConnectionTreeItem', | ||
| } | ||
| export type ConnectionItemContextValue = `${'disconnected' | 'connected'}${ | ||
| | '' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [extreme nit] The leading
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This gets automatically added by the linter 🤷 |
||
| | 'Immutable'}ConnectionTreeItem`; | ||
|
|
||
| function getIconPath(isActiveConnection: boolean): { | ||
| light: string; | ||
|
|
@@ -39,7 +38,7 @@ | |
| extends vscode.TreeItem | ||
| implements TreeItemParent, vscode.TreeDataProvider<ConnectionTreeItem> | ||
| { | ||
| contextValue = ConnectionItemContextValues.disconnected; | ||
| contextValue: ConnectionItemContextValue = 'disconnectedConnectionTreeItem'; | ||
|
|
||
| private _childrenCache: { | ||
| [key: string]: DatabaseTreeItem | StreamProcessorTreeItem; | ||
|
|
@@ -50,6 +49,7 @@ | |
| connectionId: string; | ||
|
|
||
| isExpanded: boolean; | ||
| isMutable: boolean; | ||
|
|
||
| constructor({ | ||
| connectionId, | ||
|
|
@@ -58,6 +58,7 @@ | |
| connectionController, | ||
| cacheIsUpToDate, | ||
| childrenCache, | ||
| isMutable, | ||
| }: { | ||
| connectionId: string; | ||
| collapsibleState: vscode.TreeItemCollapsibleState; | ||
|
|
@@ -67,21 +68,24 @@ | |
| childrenCache: { | ||
| [key: string]: DatabaseTreeItem | StreamProcessorTreeItem; | ||
| }; // Existing cache. | ||
| isMutable: boolean; | ||
| }) { | ||
| super( | ||
| connectionController.getSavedConnectionName(connectionId), | ||
| collapsibleState | ||
| ); | ||
|
|
||
| if ( | ||
| const isConnected = | ||
| connectionController.getActiveConnectionId() === connectionId && | ||
| !connectionController.isDisconnecting() && | ||
| !connectionController.isConnecting() | ||
| ) { | ||
| this.contextValue = ConnectionItemContextValues.connected; | ||
| } | ||
| !connectionController.isConnecting(); | ||
|
|
||
| this.contextValue = `${isConnected ? 'connected' : 'disconnected'}${ | ||
| isMutable ? '' : 'Immutable' | ||
|
||
| }ConnectionTreeItem`; | ||
|
|
||
| this.connectionId = connectionId; | ||
| this.isMutable = isMutable; | ||
| this._connectionController = connectionController; | ||
| this.isExpanded = isExpanded; | ||
| this._childrenCache = childrenCache; | ||
gagik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
@@ -204,7 +208,7 @@ | |
| return Object.values(this._childrenCache); | ||
| } | ||
|
|
||
| private async _buildChildrenCacheForDatabases(dataService: DataService) { | ||
|
Check warning on line 211 in src/explorer/connectionTreeItem.ts
|
||
| const databases = await this.listDatabases(); | ||
| databases.sort((a: string, b: string) => a.localeCompare(b)); | ||
|
|
||
|
|
@@ -226,7 +230,7 @@ | |
| return newChildrenCache; | ||
| } | ||
|
|
||
| private async _buildChildrenCacheForStreams(dataService: DataService) { | ||
|
Check warning on line 233 in src/explorer/connectionTreeItem.ts
|
||
| const processors = await this.listStreamProcessors(); | ||
| processors.sort((a, b) => a.name.localeCompare(b.name)); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.