-
Notifications
You must be signed in to change notification settings - Fork 77
VSCODE-66: Add connection renaming #34
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
Conversation
@@ -98,7 +99,10 @@ export default class ConnectionTreeItem extends vscode.TreeItem | |||
} | |||
|
|||
return new Promise((resolve, reject) => { | |||
const dataService = this._connectionController.getActiveConnection(); | |||
const dataService = this._connectionController.getActiveDataService(); |
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.
So there is no more getActiveConnection
only getActiveDataService
? How can I get the active connection now to read all connection properties from it?
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.
Which connection properties are you looking for? Maybe I need to keep storing the connection model as well (this pr currently removes it and just keeps the basic connection and data service). We're storing the driver url on the SavedConnection
now.
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.
-
For example, I am connected, and I want to know which host and port I am currently connected to. Or which database is the default for the current connection. How can I do it?
-
I want to check if I am currently connected or not. Is it the right way to do it?
const dataservice = this._connectionController.getActiveDataService();
if (dataservice === null) {
vscode.window.showErrorMessage(
`Unable to list documents: no longer connected to ${connectionId}`
);
}
In Compass we use DataService more like API to the driver, when ConnectionModel is more about connection properties. If the getActiveDataService returns the connection model, then maybe it would be more descriptive to call it as before getActiveConnection.
Or maybe I just got something wrong, pls help to understand :)
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.
Ah k - I'll add a call for getActiveConnectionModel
for connection details. Correct on checking data service, I'll add a helper for that in connection controller so we can just get a boolean. Dataservice is like the api for the driver yup
// When the connections change, like a connection is added or removed, | ||
// we want to open the connections dropdown if it's collapsed. | ||
if (!this.isExpanded) { | ||
this.needsToRefreshExpansionState = true; |
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.
Thx for adding it! ✨
@@ -18,6 +19,13 @@ export enum DefaultSavingLocations { | |||
'Session Only' = 'Session Only' | |||
} | |||
|
|||
export type SavedConnection = { | |||
id: string; // uuidv4 |
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.
👍
Like how you did renaming! And I believe this is very nice to be able to save connections with the same URI. It is better to delete redundant connections later than throw error messages which might be confusing for users. Great job! 🚀 |
Ah one more thing I noticed I should add before we merge this pr is we want to show the prompt for where to save the connection right after the user inputs the connection string, right now it prompts after the connection is established. |
f303346
to
8917749
Compare
@alenakhineika Added two functions to I've been noticing the tests sometimes crash on mac with this error: |
https://jira.mongodb.org/browse/VSCODE-66
This PR adds the ability to rename connections. It also improves our connection controller's saved connection implementation so we don't require a dns fetch to add a connection and adding two connections with the same driver url aren't blocked anymore. It also makes it so when a user copies a connection string from a connection in the connection tree view we no longer attach the
appname
parameter to the uri.@alenakhineika 's suggestion we also now expand the
connections
tree element if it's collapsed when a connection is added.When a connection is first added, its name is its derived instance id.
Here's the new type for connections in the connection controller:
Screenshots