Connection URI with complete options (finalized) (#22735)

* Connection URI made to include every option available instead of basic details (#22045)

* Revert "Merge remote-tracking branch 'origin' into feat/connectionUri"

This reverts commit 11b2d31bf99e216daee823f732254f69a017fee1, reversing
changes made to 36e4db8c0744f81565efdfd2f56a3ae3c0026896.

* Revert "Revert "Merge remote-tracking branch 'origin' into feat/connectionUri""

This reverts commit f439673c2693e1144c52e04c14e82cd8566c13a6.

* Added changes and fixes for feat connectionuri (#22706)

* add title generation at start

* added await to refreshConnectionTreeTitles
This commit is contained in:
Alex Ma
2023-04-18 11:08:48 -07:00
committed by GitHub
parent a9bc34acf0
commit b69e87df15
27 changed files with 1641 additions and 86 deletions

View File

@@ -68,23 +68,38 @@ export class ConnectionStatusbarItem extends Disposable implements IWorkbenchCon
// Set connection info to connection status bar
private _setConnectionText(connectionProfile: IConnectionProfile): void {
let text: string = connectionProfile.serverName;
if (text) {
if (connectionProfile.databaseName && connectionProfile.databaseName !== '') {
text = text + ' : ' + connectionProfile.databaseName;
} else {
text = text + ' : ' + '<default>';
let text: string = undefined;
let fullEditorText: string = this.connectionManagementService.getEditorConnectionProfileTitle(connectionProfile);
if (fullEditorText.length === 0) {
text = connectionProfile.serverName;
if (text) {
if (connectionProfile.databaseName && connectionProfile.databaseName !== '') {
text = text + ' : ' + connectionProfile.databaseName;
} else {
text = text + ' : ' + '<default>';
}
}
}
let tooltip: string =
'Server: ' + connectionProfile.serverName + '\r\n' +
'Database: ' + (connectionProfile.databaseName ? connectionProfile.databaseName : '<default>') + '\r\n';
if (connectionProfile.userName && connectionProfile.userName !== '') {
tooltip = tooltip + 'Login: ' + connectionProfile.userName + '\r\n';
else {
text = fullEditorText;
}
let tooltip: string = undefined;
if (!fullEditorText) {
tooltip = 'Server: ' + connectionProfile.serverName + '\r\n' +
'Database: ' + (connectionProfile.databaseName ? connectionProfile.databaseName : '<default>') + '\r\n';
if (connectionProfile.userName && connectionProfile.userName !== '') {
tooltip = tooltip + 'Login: ' + connectionProfile.userName + '\r\n';
}
}
else {
// It is difficult to have every possible option that is different displayed as above with consistent naming, therefore the tooltip will show the full string.
tooltip = fullEditorText;
}
this.statusItem.update({
name: this.name,
text: text,

View File

@@ -731,7 +731,10 @@ export class AttachToDropdown extends SelectBox {
} else {
let connections: string[] = [];
if (model.context && model.context.title && (connProviderIds.includes(this.model.context.providerName))) {
connections.push(model.context.title);
let textResult = model.context.title;
let fullTitleText = this._connectionManagementService.getEditorConnectionProfileTitle(model.context);
textResult = fullTitleText.length !== 0 ? fullTitleText : textResult;
connections.push(textResult);
} else if (this._configurationService.getValue(saveConnectionNameConfigName) && model.savedConnectionName) {
connections.push(model.savedConnectionName);
} else {

View File

@@ -121,6 +121,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
// get the full ConnectionProfiles with the server info updated properly
const treeInput = TreeUpdateUtils.getTreeInput(this._connectionManagementService)!;
await this._tree.setInput(treeInput);
await this.refreshConnectionTreeTitles();
this._treeSelectionHandler.onTreeActionStateChange(false);
} else {
if (this._connectionManagementService.hasRegisteredServers()) {
@@ -263,6 +264,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
if (connectionParentGroup) {
connectionParentGroup.addOrReplaceConnection(newConnection);
await this._tree.updateChildren(connectionParentGroup);
await this.refreshConnectionTreeTitles();
await this._tree.revealSelectFocusElement(newConnection);
await this._tree.expand(newConnection);
}
@@ -277,6 +279,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
await this._tree.rerender(connectionInTree);
await this._tree.revealSelectFocusElement(connectionInTree);
await this._tree.updateChildren(connectionInTree);
await this.refreshConnectionTreeTitles();
await this._tree.expand(connectionInTree);
}
}
@@ -289,6 +292,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
if (parentGroup) {
parentGroup.removeConnections([e]);
await this._tree.updateChildren(parentGroup);
await this.refreshConnectionTreeTitles();
await this._tree.revealSelectFocusElement(parentGroup);
}
}
@@ -306,12 +310,14 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
const newProfileParent = <ConnectionProfileGroup>this._tree.getElementById(e.profile.groupId);
newProfileParent.addOrReplaceConnection(e.profile);
await this._tree.updateChildren(newProfileParent);
await this.refreshConnectionTreeTitles();
await this._tree.revealSelectFocusElement(e.profile);
await this._tree.expand(e.profile);
} else {
// If the profile was not moved to a different group then just update the profile in the group.
oldProfileParent.replaceConnection(e.profile, e.oldProfileId);
await this._tree.updateChildren(oldProfileParent)
await this.refreshConnectionTreeTitles();
await this._tree.revealSelectFocusElement(e.profile);
await this._tree.expand(e.profile);
}
@@ -333,6 +339,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
newParent.addOrReplaceConnection(movedConnection);
await this._tree.updateChildren(newParent);
}
await this.refreshConnectionTreeTitles();
const newConnection = this._tree.getElementById(movedConnection.id);
if (newConnection) {
await this._tree.revealSelectFocusElement(newConnection);
@@ -347,6 +354,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
const parent = <ConnectionProfileGroup>this._tree.getElementById(e.parentId);
parent.children = parent.children.filter(c => c.id !== e.id);
await this._tree.updateChildren(parent);
await this.refreshConnectionTreeTitles();
await this._tree.revealSelectFocusElement(parent);
}
}));
@@ -369,6 +377,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
e.parent = parent;
e.parentId = parent.id;
await this._tree.updateChildren(parent);
await this.refreshConnectionTreeTitles();
await this._tree.revealSelectFocusElement(e);
}
}));
@@ -379,6 +388,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
if (newParent) {
newParent.children[newParent.children.findIndex(c => c.id === e.id)] = e;
await this._tree.updateChildren(newParent);
await this.refreshConnectionTreeTitles();
await this._tree.revealSelectFocusElement(e);
}
}
@@ -397,6 +407,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
(<ConnectionProfileGroup>movedGroup).parent = newParent;
(<ConnectionProfileGroup>movedGroup).parentId = newParent.id;
await this._tree.updateChildren(newParent);
await this.refreshConnectionTreeTitles();
await this._tree.revealSelectFocusElement(movedGroup);
// Expanding the previously expanded children of the moved group after the move.
this._tree.expandElements(profileExpandedState);
@@ -636,6 +647,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
if (this._tree instanceof AsyncServerTree) {
await this._tree.setInput(treeInput!);
await this._tree.updateChildren(treeInput!);
await this.refreshConnectionTreeTitles();
return;
}
await this._tree.setInput(treeInput!);
@@ -897,4 +909,11 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
}
return actionContext;
}
private async refreshConnectionTreeTitles(): Promise<void> {
let treeInput = TreeUpdateUtils.getTreeInput(this._connectionManagementService);
let treeArray = TreeUpdateUtils.alterTreeChildrenTitles([treeInput]);
treeInput = treeArray[0];
await this._tree!.setInput(treeInput);
}
}