mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 17:22:48 -05:00
Merge from vscode e3c4990c67c40213af168300d1cfeb71d680f877 (#16569)
This commit is contained in:
@@ -89,7 +89,7 @@ export class ConnectionConfig {
|
||||
public addConnection(profile: IConnectionProfile, matcher: ProfileMatcher = ConnectionProfile.matchesProfile): Promise<IConnectionProfile> {
|
||||
if (profile.saveProfile) {
|
||||
return this.addGroupFromProfile(profile).then(groupId => {
|
||||
let profiles = deepClone(this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue);
|
||||
let profiles = deepClone(this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue as IConnectionProfileStore[]);
|
||||
if (!profiles) {
|
||||
profiles = [];
|
||||
}
|
||||
@@ -134,7 +134,7 @@ export class ConnectionConfig {
|
||||
if (profile.groupId && profile.groupId !== Utils.defaultGroupId) {
|
||||
return Promise.resolve(profile.groupId);
|
||||
} else {
|
||||
let groups = deepClone(this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue);
|
||||
let groups = deepClone(this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue as IConnectionProfileGroup[]);
|
||||
let result = this.saveGroup(groups!, profile.groupFullName, undefined, undefined);
|
||||
groups = result.groups;
|
||||
|
||||
@@ -149,7 +149,7 @@ export class ConnectionConfig {
|
||||
if (profileGroup.id) {
|
||||
return Promise.resolve(profileGroup.id);
|
||||
} else {
|
||||
let groups = deepClone(this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue);
|
||||
let groups = deepClone(this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue as IConnectionProfileGroup[]);
|
||||
let sameNameGroup = groups ? groups.find(group => group.name === profileGroup.name) : undefined;
|
||||
if (sameNameGroup) {
|
||||
let errMessage: string = nls.localize('invalidServerName', "A server group with the same name already exists.");
|
||||
@@ -169,9 +169,9 @@ export class ConnectionConfig {
|
||||
if (configs) {
|
||||
let fromConfig: IConnectionProfileStore[] | undefined;
|
||||
if (configTarget === ConfigurationTarget.USER) {
|
||||
fromConfig = configs.userValue;
|
||||
fromConfig = configs.userValue as IConnectionProfileStore[];
|
||||
} else if (configTarget === ConfigurationTarget.WORKSPACE) {
|
||||
fromConfig = configs.workspaceValue || [];
|
||||
fromConfig = configs.workspaceValue as IConnectionProfileStore[] || [];
|
||||
}
|
||||
if (fromConfig) {
|
||||
profiles = deepClone(fromConfig);
|
||||
@@ -340,8 +340,8 @@ export class ConnectionConfig {
|
||||
* Moves the connection under the target group with the new ID.
|
||||
*/
|
||||
private changeGroupIdForConnectionInSettings(profile: ConnectionProfile, newGroupID: string, target: ConfigurationTarget = ConfigurationTarget.USER): Promise<void> {
|
||||
let profiles = deepClone(target === ConfigurationTarget.USER ? this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue :
|
||||
this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).workspaceValue);
|
||||
let profiles = deepClone(target === ConfigurationTarget.USER ? this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue as IConnectionProfileStore[] :
|
||||
this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).workspaceValue as IConnectionProfileStore[]);
|
||||
if (profiles) {
|
||||
if (profile.parent && profile.parent.id === UNSAVED_GROUP_ID) {
|
||||
profile.groupId = newGroupID;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
export interface INewConnectionProfileGroup {
|
||||
id?: string;
|
||||
@@ -56,7 +55,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
});
|
||||
}
|
||||
|
||||
return assign({}, { name: this.name, id: this.id, parentId: this.parentId, children: subgroups, color: this.color, description: this.description });
|
||||
return Object.assign({}, { name: this.name, id: this.id, parentId: this.parentId, children: subgroups, color: this.color, description: this.description });
|
||||
}
|
||||
|
||||
public get groupName(): string {
|
||||
|
||||
@@ -14,7 +14,6 @@ import { join } from 'vs/base/common/path';
|
||||
import * as Utils from 'sql/platform/connection/common/utils';
|
||||
import * as azdata from 'azdata';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export class ConnectionStatusManager {
|
||||
@@ -193,7 +192,7 @@ export class ConnectionStatusManager {
|
||||
}
|
||||
|
||||
private isSharedSession(fileUri: string): boolean {
|
||||
return !!(fileUri && startsWith(fileUri, 'vsls:'));
|
||||
return !!(fileUri && fileUri.startsWith('vsls:'));
|
||||
}
|
||||
|
||||
public isConnected(id: string): boolean {
|
||||
@@ -208,7 +207,7 @@ export class ConnectionStatusManager {
|
||||
}
|
||||
|
||||
public isDefaultTypeUri(uri: string): boolean {
|
||||
return !!(uri && startsWith(uri, Utils.uriPrefixes.default));
|
||||
return !!(uri && uri.startsWith(Utils.uriPrefixes.default));
|
||||
}
|
||||
|
||||
public getProviderIdFromUri(ownerUri: string): string {
|
||||
|
||||
@@ -9,7 +9,6 @@ import { isString } from 'vs/base/common/types';
|
||||
import * as azdata from 'azdata';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { ICapabilitiesService, ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
type SettableProperty = 'serverName' | 'authenticationType' | 'databaseName' | 'password' | 'connectionName' | 'userName';
|
||||
@@ -95,7 +94,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
|
||||
public clone(): ProviderConnectionInfo {
|
||||
let instance = new ProviderConnectionInfo(this.capabilitiesService, this.providerName);
|
||||
instance.options = assign({}, this.options);
|
||||
instance.options = Object.assign({}, this.options);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import * as assert from 'assert';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
suite('SQL ConnectionProfileInfo tests', () => {
|
||||
let msSQLCapabilities: ConnectionProviderProperties;
|
||||
@@ -187,7 +186,7 @@ suite('SQL ConnectionProfileInfo tests', () => {
|
||||
});
|
||||
|
||||
test('createFromStoredProfile should set the id to new guid if not set in stored profile', () => {
|
||||
let savedProfile: IConnectionProfileStore = assign({}, storedProfile, { id: undefined });
|
||||
let savedProfile: IConnectionProfileStore = Object.assign({}, storedProfile, { id: undefined });
|
||||
let connectionProfile = ConnectionProfile.createFromStoredProfile(savedProfile, capabilitiesService);
|
||||
assert.equal(savedProfile.groupId, connectionProfile.groupId);
|
||||
assert.deepEqual(savedProfile.providerName, connectionProfile.providerName);
|
||||
|
||||
@@ -13,7 +13,7 @@ import { IConnectionProfile, ConnectionOptionSpecialType, ServiceOptionType } fr
|
||||
import { TestConfigurationService } from 'sql/platform/connection/test/common/testConfigurationService';
|
||||
import { TestCredentialsService } from 'sql/platform/credentials/test/common/testCredentialsService';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { deepClone, deepFreeze, assign } from 'vs/base/common/objects';
|
||||
import { deepClone, deepFreeze } from 'vs/base/common/objects';
|
||||
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
@@ -154,7 +154,7 @@ suite('ConnectionStore', () => {
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
for (let i = 0; i < numCreds; i++) {
|
||||
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
|
||||
await connectionStore.addRecentConnection(connectionProfile);
|
||||
const current = connectionStore.getRecentlyUsedConnections();
|
||||
@@ -190,7 +190,7 @@ suite('ConnectionStore', () => {
|
||||
// Then expect the only 1 instance of that connection to be listed in the MRU
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + 1 });
|
||||
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + 1 });
|
||||
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
|
||||
await connectionStore.addRecentConnection(defaultNamedConnectionProfile);
|
||||
await connectionStore.addRecentConnection(connectionProfile);
|
||||
@@ -212,13 +212,13 @@ suite('ConnectionStore', () => {
|
||||
// Given we save 1 connection with password and multiple other connections without
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
const integratedCred = assign({}, defaultNamedProfile, {
|
||||
const integratedCred = Object.assign({}, defaultNamedProfile, {
|
||||
serverName: defaultNamedProfile.serverName + 'Integrated',
|
||||
authenticationType: 'Integrated',
|
||||
userName: '',
|
||||
password: ''
|
||||
});
|
||||
const noPwdCred = assign({}, defaultNamedProfile, {
|
||||
const noPwdCred = Object.assign({}, defaultNamedProfile, {
|
||||
serverName: defaultNamedProfile.serverName + 'NoPwd',
|
||||
password: ''
|
||||
});
|
||||
@@ -322,7 +322,7 @@ suite('ConnectionStore', () => {
|
||||
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
const connectionProfile: IConnectionProfile = assign({}, defaultNamedProfile, { providerName: providerName });
|
||||
const connectionProfile: IConnectionProfile = Object.assign({}, defaultNamedProfile, { providerName: providerName });
|
||||
|
||||
assert.ok(!connectionStore.isPasswordRequired(connectionProfile));
|
||||
});
|
||||
@@ -333,7 +333,7 @@ suite('ConnectionStore', () => {
|
||||
const credentialsService = new TestCredentialsService();
|
||||
|
||||
const password: string = 'asdf!@#$';
|
||||
const connectionProfile: IConnectionProfile = assign({}, defaultNamedProfile, { password });
|
||||
const connectionProfile: IConnectionProfile = Object.assign({}, defaultNamedProfile, { password });
|
||||
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
@@ -403,7 +403,7 @@ suite('ConnectionStore', () => {
|
||||
const profile = deepClone(defaultNamedProfile);
|
||||
profile.options['password'] = profile.password;
|
||||
profile.id = 'testId';
|
||||
let expectedProfile = assign({}, profile);
|
||||
let expectedProfile = Object.assign({}, profile);
|
||||
expectedProfile.password = '';
|
||||
expectedProfile.options['password'] = '';
|
||||
expectedProfile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, expectedProfile).toIConnectionProfile();
|
||||
@@ -416,7 +416,7 @@ suite('ConnectionStore', () => {
|
||||
const configurationService = new TestConfigurationService();
|
||||
const credentialsService = new TestCredentialsService();
|
||||
|
||||
const profile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, assign({}, defaultNamedProfile, { password: undefined }));
|
||||
const profile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, Object.assign({}, defaultNamedProfile, { password: undefined }));
|
||||
|
||||
const credId = `Microsoft.SqlTools|itemtype:Profile|id:${profile.getConnectionInfoId()}`;
|
||||
const password: string = 'asdf!@#$';
|
||||
@@ -477,7 +477,7 @@ suite('ConnectionStore', () => {
|
||||
credentialsService, capabilitiesService);
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
|
||||
await connectionStore.addRecentConnection(connectionProfile);
|
||||
const current = connectionStore.getRecentlyUsedConnections();
|
||||
@@ -485,7 +485,7 @@ suite('ConnectionStore', () => {
|
||||
}
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
|
||||
connectionStore.removeRecentConnection(connectionProfile);
|
||||
const current = connectionStore.getRecentlyUsedConnections();
|
||||
|
||||
@@ -9,7 +9,6 @@ import * as azdata from 'azdata';
|
||||
import * as assert from 'assert';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
suite('SQL ProviderConnectionInfo tests', () => {
|
||||
let msSQLCapabilities: any;
|
||||
@@ -202,7 +201,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
||||
test('constructor should initialize the options given a valid model with options', () => {
|
||||
let options: { [key: string]: string } = {};
|
||||
options['encrypt'] = 'test value';
|
||||
let conn2 = assign({}, connectionProfile, { options: options });
|
||||
let conn2 = Object.assign({}, connectionProfile, { options: options });
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, conn2);
|
||||
|
||||
assert.equal(conn.connectionName, conn2.connectionName);
|
||||
@@ -223,7 +222,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
||||
|
||||
test('getOptionsKey should create different id for different server names', () => {
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
|
||||
let conn2 = new ProviderConnectionInfo(capabilitiesService, assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));
|
||||
let conn2 = new ProviderConnectionInfo(capabilitiesService, Object.assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));
|
||||
|
||||
assert.notEqual(conn.getOptionsKey(), conn2.getOptionsKey());
|
||||
});
|
||||
|
||||
@@ -15,7 +15,6 @@ import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
|
||||
let connections: ConnectionStatusManager;
|
||||
@@ -171,7 +170,7 @@ suite('SQL ConnectionStatusManager tests', () => {
|
||||
let expectedConnectionId = 'new id';
|
||||
connections.addConnection(connectionProfile, connection1Id);
|
||||
|
||||
let updatedConnection = assign({}, connectionProfile, { groupId: expected, getOptionsKey: () => connectionProfile.getOptionsKey() + expected, id: expectedConnectionId });
|
||||
let updatedConnection = Object.assign({}, connectionProfile, { groupId: expected, getOptionsKey: () => connectionProfile.getOptionsKey() + expected, id: expectedConnectionId });
|
||||
let actualId = connections.updateConnectionProfile(updatedConnection, connection1Id);
|
||||
|
||||
let newId = Utils.generateUri(updatedConnection);
|
||||
@@ -246,7 +245,7 @@ suite('SQL ConnectionStatusManager tests', () => {
|
||||
|
||||
test('getActiveConnectionProfiles should return a list of all the unique connections that the status manager knows about', () => {
|
||||
// Add duplicate connections
|
||||
let newConnection = assign({}, connectionProfile);
|
||||
let newConnection = Object.assign({}, connectionProfile);
|
||||
newConnection.id = 'test_id';
|
||||
newConnection.serverName = 'new_server_name';
|
||||
newConnection.options['databaseDisplayName'] = newConnection.databaseName;
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as azdata from 'azdata';
|
||||
import { IAdsTelemetryService, ITelemetryInfo, ITelemetryEvent, ITelemetryEventMeasures, ITelemetryEventProperties } from 'sql/platform/telemetry/common/telemetry';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { EventName } from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
|
||||
|
||||
@@ -36,17 +35,17 @@ class TelemetryEventImpl implements ITelemetryEvent {
|
||||
}
|
||||
|
||||
public withAdditionalProperties(additionalProperties: ITelemetryEventProperties): ITelemetryEvent {
|
||||
assign(this._properties, additionalProperties);
|
||||
Object.assign(this._properties, additionalProperties);
|
||||
return this;
|
||||
}
|
||||
|
||||
public withAdditionalMeasurements(additionalMeasurements: ITelemetryEventMeasures): ITelemetryEvent {
|
||||
assign(this._measurements, additionalMeasurements);
|
||||
Object.assign(this._measurements, additionalMeasurements);
|
||||
return this;
|
||||
}
|
||||
|
||||
public withConnectionInfo(connectionInfo?: azdata.IConnectionProfile): ITelemetryEvent {
|
||||
assign(this._properties,
|
||||
Object.assign(this._properties,
|
||||
{
|
||||
authenticationType: connectionInfo?.authenticationType,
|
||||
provider: connectionInfo?.providerName
|
||||
@@ -55,7 +54,7 @@ class TelemetryEventImpl implements ITelemetryEvent {
|
||||
}
|
||||
|
||||
public withServerInfo(serverInfo?: azdata.ServerInfo): ITelemetryEvent {
|
||||
assign(this._properties,
|
||||
Object.assign(this._properties,
|
||||
{
|
||||
connectionType: serverInfo?.isCloud !== undefined ? (serverInfo.isCloud ? 'Azure' : 'Standalone') : '',
|
||||
serverVersion: serverInfo?.serverVersion ?? '',
|
||||
|
||||
Reference in New Issue
Block a user