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

@@ -70,6 +70,51 @@ export class ConnectionConfig {
});
}
/**
* Checks to make sure that the profile that is being edited is not identical to another profile.
*/
public isDuplicateEdit(profile: IConnectionProfile, matcher: ProfileMatcher = ConnectionProfile.matchesProfile): Promise<boolean> {
let profiles = deepClone(this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue as IConnectionProfileStore[]);
if (!profiles) {
profiles = [];
}
return this.addGroupFromProfile(profile).then(groupId => {
let connectionProfile = this.getConnectionProfileInstance(profile, groupId);
// Profile to be stored during an edit, used to check for duplicate profile edits.
let firstMatchProfile = undefined;
profiles.find(value => {
const providerConnectionProfile = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
const match = matcher(providerConnectionProfile, connectionProfile);
// If we have a profile match, and the matcher is an edit, we must store this match.
if (match && (matcher.toString() !== ConnectionProfile.matchesProfile.toString())) {
firstMatchProfile = value;
}
return match;
});
// If a profile edit, we must now check to see it does not match the other profiles available.
if (firstMatchProfile) {
// Copy over profile list so that we can remove the actual profile we want to edit.
const index = profiles.indexOf(firstMatchProfile);
if (index > -1) {
profiles.splice(index, 1);
}
// Use the regular profile matching here to find if edit is duplicate.
let matchesExistingProfile = profiles.find(value => {
const providerConnectionProfile = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
const match = ConnectionProfile.matchesProfile(providerConnectionProfile, connectionProfile);
return match;
});
return Promise.resolve(matchesExistingProfile !== undefined);
}
return Promise.resolve(false);
});
}
/**
* Add a new connection to the connection config.
*/
@@ -317,10 +362,18 @@ export class ConnectionConfig {
p.options.database === profile.options.database &&
p.options.server === profile.options.server &&
p.options.user === profile.options.user &&
p.groupId === newGroupID);
p.options.connectionName === profile.options.connectionName &&
p.groupId === newGroupID &&
this.checkIfNonDefaultOptionsMatch(p, profile));
return existingProfile === undefined;
}
private checkIfNonDefaultOptionsMatch(profileStore: IConnectionProfileStore, profile: ConnectionProfile): boolean {
let tempProfile = ConnectionProfile.createFromStoredProfile(profileStore, this._capabilitiesService);
let result = profile.getNonDefaultOptionsString() === tempProfile.getNonDefaultOptionsString();
return result;
}
/**
* Moves the connection under the target group with the new ID.
*/