mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 09:35:37 -05:00
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:
@@ -540,6 +540,22 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
|
||||
let isEdit = options?.params?.isEditConnection ?? false;
|
||||
|
||||
let matcher: interfaces.ProfileMatcher;
|
||||
if (isEdit) {
|
||||
matcher = (a: interfaces.IConnectionProfile, b: interfaces.IConnectionProfile) => a.id === options.params.oldProfileId;
|
||||
|
||||
//Check to make sure the edits are not identical to another connection.
|
||||
await this._connectionStore.isDuplicateEdit(connection, matcher).then(result => {
|
||||
if (result) {
|
||||
// Must get connection group name here as it may not always be initialized and causes problems when deleting when included with options.
|
||||
this._logService.error(`Profile edit for '${connection.id}' exactly matches an existing profile with data: '${ConnectionProfile.getDisplayOptionsKey(connection.getOptionsKey())}'`);
|
||||
throw new Error(`Cannot save profile, the selected connection options are identical to an existing profile with details: \n
|
||||
${ConnectionProfile.getDisplayOptionsKey(connection.getOptionsKey())}${(connection.groupFullName !== undefined && connection.groupFullName !== '' && connection.groupFullName !== '/') ?
|
||||
ConnectionProfile.displayIdSeparator + 'groupName' + ConnectionProfile.displayNameValueSeparator + connection.groupFullName : ''}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!uri) {
|
||||
uri = Utils.generateUri(connection);
|
||||
}
|
||||
@@ -588,11 +604,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
callbacks.onConnectSuccess(options.params, connectionResult.connectionProfile);
|
||||
}
|
||||
if (options.saveTheConnection || isEdit) {
|
||||
let matcher: interfaces.ProfileMatcher;
|
||||
if (isEdit) {
|
||||
matcher = (a: interfaces.IConnectionProfile, b: interfaces.IConnectionProfile) => a.id === options.params.oldProfileId;
|
||||
}
|
||||
|
||||
await this.saveToSettings(uri, connection, matcher).then(value => {
|
||||
this._onAddConnectionProfile.fire(connection);
|
||||
if (isEdit) {
|
||||
@@ -700,6 +711,20 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
return result;
|
||||
}
|
||||
|
||||
public getEditorConnectionProfileTitle(profile: interfaces.IConnectionProfile, getNonDefaultsOnly?: boolean): string {
|
||||
let result = '';
|
||||
if (profile) {
|
||||
let tempProfile = new ConnectionProfile(this._capabilitiesService, profile);
|
||||
if (!getNonDefaultsOnly) {
|
||||
result = tempProfile.getEditorFullTitleWithOptions();
|
||||
}
|
||||
else {
|
||||
result = tempProfile.getNonDefaultOptionsString();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private doActionsAfterConnectionComplete(uri: string, options: IConnectionCompletionOptions): void {
|
||||
let connectionManagementInfo = this._connectionStatusManager.findConnection(uri);
|
||||
if (!connectionManagementInfo) {
|
||||
@@ -1265,7 +1290,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
this._connectionGlobalStatus.setStatusToConnected(info.connectionSummary);
|
||||
}
|
||||
|
||||
const connectionUniqueId = connection.connectionProfile.getConnectionInfoId();
|
||||
const connectionUniqueId = connection.connectionProfile.getOptionsKey();
|
||||
if (info.isSupportedVersion === false
|
||||
&& this._connectionsGotUnsupportedVersionWarning.indexOf(connectionUniqueId) === -1
|
||||
&& this._configurationService.getValue<boolean>('connection.showUnsupportedServerVersionWarning')) {
|
||||
|
||||
Reference in New Issue
Block a user