-
Notifications
You must be signed in to change notification settings - Fork 90
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
db87e39
add preset settings
gagik 06b1e90
add tests
gagik d2d58e6
feat(tree-explorer): add reactivity, sample value and remove configur…
gagik bf9cd64
feat(tree-explorer): automatically derive workspace or global settings
gagik 0128835
feat(tree-explorer): allow running edit preset connections from the h…
gagik 0850375
fix(tree-explorer): update tests to use inspect and check for global …
gagik bf39230
refactor: rename to presetConnections, update test strict equality, u…
gagik a72bad8
test: add clear connection tests and use test strict equality
gagik 6cf0f1c
refactor: changes from review
gagik 63c719d
fix(tree-explorer): fix issues with collapsing active connection
gagik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,11 +11,11 @@ import formatError from '../utils/formatError'; | |
| import { getImagesPath } from '../extensionConstants'; | ||
| import type TreeItemParent from './treeItemParentInterface'; | ||
| import StreamProcessorTreeItem from './streamProcessorTreeItem'; | ||
| import type { ConnectionSource } from '../storage/connectionStorage'; | ||
|
|
||
| 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 🤷 |
||
| | 'Preset'}ConnectionTreeItem`; | ||
|
|
||
| function getIconPath(isActiveConnection: boolean): { | ||
| light: string; | ||
|
|
@@ -39,7 +39,7 @@ export default class ConnectionTreeItem | |
| extends vscode.TreeItem | ||
| implements TreeItemParent, vscode.TreeDataProvider<ConnectionTreeItem> | ||
| { | ||
| contextValue = ConnectionItemContextValues.disconnected; | ||
| contextValue: ConnectionItemContextValue = 'disconnectedConnectionTreeItem'; | ||
|
|
||
| private _childrenCache: { | ||
| [key: string]: DatabaseTreeItem | StreamProcessorTreeItem; | ||
|
|
@@ -50,6 +50,7 @@ export default class ConnectionTreeItem | |
| connectionId: string; | ||
|
|
||
| isExpanded: boolean; | ||
| source: ConnectionSource; | ||
|
|
||
| constructor({ | ||
| connectionId, | ||
|
|
@@ -58,6 +59,7 @@ export default class ConnectionTreeItem | |
| connectionController, | ||
| cacheIsUpToDate, | ||
| childrenCache, | ||
| source, | ||
| }: { | ||
| connectionId: string; | ||
| collapsibleState: vscode.TreeItemCollapsibleState; | ||
|
|
@@ -67,21 +69,24 @@ export default class ConnectionTreeItem | |
| childrenCache: { | ||
| [key: string]: DatabaseTreeItem | StreamProcessorTreeItem; | ||
| }; // Existing cache. | ||
| source: ConnectionSource; | ||
| }) { | ||
| 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'}${ | ||
| source === 'user' ? '' : 'Preset' | ||
| }ConnectionTreeItem`; | ||
|
|
||
| this.connectionId = connectionId; | ||
| this.source = source; | ||
| this._connectionController = connectionController; | ||
| this.isExpanded = isExpanded; | ||
| this._childrenCache = childrenCache; | ||
gagik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
@@ -204,7 +209,9 @@ export default class ConnectionTreeItem | |
| return Object.values(this._childrenCache); | ||
| } | ||
|
|
||
| private async _buildChildrenCacheForDatabases(dataService: DataService) { | ||
| private async _buildChildrenCacheForDatabases( | ||
| dataService: DataService | ||
| ): Promise<Record<string, DatabaseTreeItem>> { | ||
| const databases = await this.listDatabases(); | ||
| databases.sort((a: string, b: string) => a.localeCompare(b)); | ||
|
|
||
|
|
@@ -226,7 +233,9 @@ export default class ConnectionTreeItem | |
| return newChildrenCache; | ||
| } | ||
|
|
||
| private async _buildChildrenCacheForStreams(dataService: DataService) { | ||
| private async _buildChildrenCacheForStreams( | ||
| dataService: DataService | ||
| ): Promise<Record<string, StreamProcessorTreeItem>> { | ||
| const processors = await this.listStreamProcessors(); | ||
| processors.sort((a, b) => a.name.localeCompare(b.name)); | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this fixing a bug where deleted saved connections would show up because they're not overridden in the for loop? Couldn't spot a test that verifies the behavior before was incorrect - am I just blind or should we add one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this hasn't been an issue because we'd only run
loadSavedConnectionsat startup / whenthis._connectionswould be not yet defined. Now with the reloading on save this becomes more obvious. I'll add a test.