Changed connection title generation to use getConnections (including recent and saved). (#22954)

* remove advanced options for table designer and notebook Actions title (unnecessary in usage context)

* Revert "remove advanced options for table designer and notebook Actions title (unnecessary in usage context)"

This reverts commit e30aee5151319863aebbb4738fb30354c179c2c5.

* added changes based on feedback

* added null check and updated tests

* WIP change to connection title generation

* WIP connection management service update

* fix to connectionManagementService test

* fix editorConnectionTitles

* renamed nondefault to distinguishing options

* use stored connections for options

* removed erroneous connection name set to null

* added title by ID search for title generation

* Add recent connection title

* added fix for stub bug

* added child title options appended

* WIP rework of getEditorTitle

* more work done

* WIP changes for 5-2-2023

* moved server info to generate titles.

* added reworked title generation

* added working active connection title generation and cleanup

* added comments to argument

* remove unnecessary spaces

* added id fix assign

* added fromEditor save

* Revert "Revert new connection string format (#22997)"

This reverts commit 898bb73a34.

* added small fix to tests and exclude empty properties

* made small fixes for tests

* update expected ID

* added support for old password key and removed empty options

* added in authenticationType core property

* fix for whitespace indentation

* added connection save profile to thing

* made some small fixes to connection options

* added small change to connectionDialogService

* added nullcheck for saveProfile

* added negation for connection saveProfile

* remove duplicate editor title generation

* added edit profile handling for titles

* Cleanup serverCapabilities property

* fixed dependency issues

* removed connectionproviderproperties

* added fix for treeupdateutils

* made update to title generation

* added recent connections change

* Revert "Cleanup serverCapabilities property"

This reverts commit 2c7b94f98cabddb34116dcdd83177614a484c026.

* added dashboard text and fix for connection store test

* added group name to end also temporary added dashboard changes based on feedback

* added in new SQL version

* added fix to edit connections

* added clarifying information to title generation

---------

Co-authored-by: Cheena Malhotra <cmalhotra@microsoft.com>
This commit is contained in:
Alex Ma
2023-06-21 09:59:58 -07:00
committed by GitHub
parent 996d45bfa7
commit ef8164e5c2
32 changed files with 1705 additions and 68 deletions

View File

@@ -68,21 +68,30 @@ 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 distinguishedTitle = this.connectionManagementService.getEditorConnectionProfileTitle(connectionProfile);
let text: string = '';
let tooltip: string = '';
if (distinguishedTitle === '') {
text = connectionProfile.serverName;
if (text) {
if (connectionProfile.databaseName && connectionProfile.databaseName !== '') {
text = text + ' : ' + connectionProfile.databaseName;
} else {
text = text + ' : ' + '<default>';
}
}
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';
}
}
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 = distinguishedTitle;
tooltip = (connectionProfile as any).serverInfo;
}
this.statusItem.update({

View File

@@ -57,7 +57,9 @@ export class BreadcrumbService implements IBreadcrumbService {
}
private getServerBreadcrumb(profile: ConnectionProfile): MenuItem {
return profile.connectionName ? { label: profile.connectionName, routerLink: ['server-dashboard'] } : { label: profile.serverName, routerLink: ['server-dashboard'] };
let formattedProfileName = profile.connectionName ? profile.connectionName : profile.serverName;
formattedProfileName += this.commonService.connectionManagementService.getEditorConnectionProfileTitle(profile, true, true);
return { label: formattedProfileName, routerLink: ['server-dashboard'] };
}
private getDbBreadcrumb(profile: ConnectionProfile): MenuItem {

View File

@@ -752,7 +752,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

@@ -125,6 +125,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()) {
@@ -272,6 +273,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);
}
@@ -286,6 +288,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);
}
}
@@ -298,6 +301,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);
}
}
@@ -315,12 +319,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);
}
@@ -345,6 +351,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
await this._tree.updateChildren(newParent);
await this._tree.expand(newParent);
}
await this.refreshConnectionTreeTitles();
const newConnection = this._tree.getElementById(movedConnection.id);
if (newConnection) {
await this._tree.revealSelectFocusElement(newConnection);
@@ -359,6 +366,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);
}
}));
@@ -381,6 +389,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);
}
}));
@@ -391,6 +400,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);
}
}
@@ -409,6 +419,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);
@@ -695,6 +706,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
return;
}
await this._tree.setInput(treeInput!);
await this.refreshConnectionTreeTitles();
if (isHidden(this.messages!)) {
this._tree.getFocus();
if (this._tree instanceof AsyncServerTree) {
@@ -960,6 +972,13 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
return actionContext;
}
private async refreshConnectionTreeTitles(): Promise<void> {
let treeInput = this._tree.getInput();
let treeArray = TreeUpdateUtils.alterTreeChildrenTitles([treeInput], this._connectionManagementService, false);
treeInput = treeArray[0];
await this._tree!.setInput(treeInput);
}
public collapseAllConnections(): void {
const root = TreeUpdateUtils.getTreeInput(this._connectionManagementService)!;
const connections = ConnectionProfileGroup.getConnectionsInGroup(root);