mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IExtensionGalleryService, IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions';
|
||||
import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
@@ -12,16 +12,16 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { DashboardEditor } from 'sql/parts/dashboard/dashboardEditor';
|
||||
import { DashboardInput } from 'sql/parts/dashboard/dashboardInput';
|
||||
import { AddServerGroupAction, AddServerAction } from 'sql/parts/registeredServer/viewlet/connectionTreeAction';
|
||||
import { ClearRecentConnectionsAction } from 'sql/parts/connection/common/connectionActions';
|
||||
|
||||
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService';
|
||||
import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
import { ExtensionTipsService } from 'vs/workbench/parts/extensions/electron-browser/extensionTipsService';
|
||||
import { ExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/node/extensionsWorkbenchService';
|
||||
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actionRegistry';
|
||||
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { localize } from 'vs/nls';
|
||||
import { AddServerGroupAction, AddServerAction } from 'sql/parts/registeredServer/viewlet/connectionTreeAction';
|
||||
|
||||
// Singletons
|
||||
registerSingleton(IExtensionGalleryService, ExtensionGalleryService);
|
||||
@@ -30,10 +30,9 @@ registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService);
|
||||
|
||||
// Connection Dashboard registration
|
||||
const dashboardEditorDescriptor = new EditorDescriptor(
|
||||
DashboardEditor,
|
||||
DashboardEditor.ID,
|
||||
'Dashboard',
|
||||
'sql/parts/dashboard/dashboardEditor',
|
||||
'DashboardEditor'
|
||||
'Dashboard'
|
||||
);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
@@ -50,7 +49,6 @@ actionRegistry.registerWorkbenchAction(
|
||||
),
|
||||
ClearRecentConnectionsAction.LABEL
|
||||
);
|
||||
|
||||
actionRegistry.registerWorkbenchAction(
|
||||
new SyncActionDescriptor(
|
||||
AddServerGroupAction,
|
||||
@@ -82,8 +80,8 @@ configurationRegistry.registerConfiguration({
|
||||
},
|
||||
'sql.defaultEngine': {
|
||||
'type': 'string',
|
||||
'description': localize('sql.defaultEngineDescription', 'Default SQL Engine to use. This drives default language provider in .sql files and the default to use when creating a new connection.'),
|
||||
'description': localize('sql.defaultEngineDescription', 'Default SQL Engine to use. This drives default language provider in .sql files and the default to use when creating a new connection. Valid option is currently MSSQL'),
|
||||
'default': 'MSSQL'
|
||||
},
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -3,57 +3,84 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
|
||||
import nls = require('vs/nls');
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IMessageService, Severity } from 'vs/platform/message/common/message';
|
||||
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
|
||||
/**
|
||||
* Locates the active editor and calls runQuery() on the editor if it is a QueryEditor.
|
||||
* Workbench action to clear the recent connnections list
|
||||
*/
|
||||
export class ClearRecentConnectionsAction extends Action {
|
||||
|
||||
public static ID = 'clearRecentConnectionsAction';
|
||||
public static LABEL = nls.localize('ClearRecentlyUsedLabel', 'Clear Recent Connections List');
|
||||
public static ID = 'clearRecentConnectionsAction';
|
||||
public static LABEL = nls.localize('ClearRecentlyUsedLabel', 'Clear Recent Connections List');
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||
@IMessageService private _messageService: IMessageService,
|
||||
@IQuickOpenService private _quickOpenService: IQuickOpenService
|
||||
) {
|
||||
super(id, label);
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public run(): TPromise<void> {
|
||||
let self = this;
|
||||
return self.promptToClearRecentConnectionsList().then(result => {
|
||||
if (result) {
|
||||
self._connectionManagementService.clearRecentConnectionsList();
|
||||
self._messageService.show(Severity.Info, nls.localize('ClearedRecentConnections', 'Recent connections list cleared'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private promptToClearRecentConnectionsList(): TPromise<boolean> {
|
||||
const self = this;
|
||||
return new TPromise<boolean>((resolve, reject) => {
|
||||
let choices: { key, value }[] = [
|
||||
{ key: nls.localize('yes', 'Yes'), value: true },
|
||||
{ key: nls.localize('no', 'No'), value: false }
|
||||
];
|
||||
|
||||
self._quickOpenService.pick(choices.map(x => x.key), { placeHolder: nls.localize('ClearRecentlyUsedLabel', 'Clear Recent Connections List'), ignoreFocusLost: true }).then((choice) => {
|
||||
let confirm = choices.find(x => x.key === choice);
|
||||
resolve(confirm && confirm.value);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to delete one recently used connection from the MRU
|
||||
*/
|
||||
export class ClearSingleRecentConnectionAction extends Action {
|
||||
|
||||
public static ID = 'clearSingleRecentConnectionAction';
|
||||
public static LABEL = nls.localize('delete', 'Delete');
|
||||
private _onRecentConnectionRemoved = new Emitter<void>();
|
||||
public onRecentConnectionRemoved: Event<void> = this._onRecentConnectionRemoved.event;
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
private _connectionProfile: IConnectionProfile,
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||
@IMessageService private _messageService: IMessageService,
|
||||
@IQuickOpenService private _quickOpenService: IQuickOpenService
|
||||
) {
|
||||
super(id, label);
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public run(): TPromise<void> {
|
||||
let self = this;
|
||||
return self.promptToClearRecentConnectionsList().then(result => {
|
||||
if (result) {
|
||||
self._connectionManagementService.clearRecentConnectionsList();
|
||||
self._messageService.show(Severity.Info, nls.localize('ClearedRecentConnections', 'Recent connections list cleared'));
|
||||
}
|
||||
return new TPromise<void>((resolve, reject) => {
|
||||
resolve(this._connectionManagementService.clearRecentConnection(this._connectionProfile));
|
||||
this._onRecentConnectionRemoved.fire();
|
||||
});
|
||||
}
|
||||
|
||||
private promptToClearRecentConnectionsList(): TPromise<boolean> {
|
||||
const self = this;
|
||||
return new TPromise<boolean>((resolve, reject) => {
|
||||
let choices: { key, value }[] = [
|
||||
{ key: nls.localize('yes', 'Yes'), value: true },
|
||||
{ key: nls.localize('no', 'No'), value: false }
|
||||
];
|
||||
|
||||
self._quickOpenService.pick(choices.map(x => x.key), { placeHolder: nls.localize('ClearRecentlyUsedLabel', 'Clear Recent Connections List'), ignoreFocusLost: true }).then((choice) => {
|
||||
let confirm = choices.find(x => x.key === choice);
|
||||
resolve(confirm && confirm.value);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,9 @@ import * as Utils from './utils';
|
||||
import { IConnectionProfile, IConnectionProfileStore } from './interfaces';
|
||||
import { IConnectionConfig } from './iconnectionConfig';
|
||||
import { ConnectionProfileGroup, IConnectionProfileGroup } from './connectionProfileGroup';
|
||||
import { IConfigurationEditingService, ConfigurationTarget, IConfigurationValue } from 'vs/workbench/services/configuration/common/configurationEditing';
|
||||
import { ConfigurationEditingService, IConfigurationValue, IConfigurationValue as TConfigurationValue } from 'vs/workbench/services/configuration/node/configurationEditingService';
|
||||
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { IConfigurationValue as TConfigurationValue } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConnectionProfile } from './connectionProfile';
|
||||
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import * as data from 'data';
|
||||
@@ -30,22 +30,25 @@ export interface ISaveGroupResult {
|
||||
export class ConnectionConfig implements IConnectionConfig {
|
||||
|
||||
private _providerCapabilitiesMap: { [providerName: string]: data.DataProtocolServerCapabilities };
|
||||
private _providerCachedCapabilitiesMap: { [providerName: string]: data.DataProtocolServerCapabilities };
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public constructor(
|
||||
private _configurationEditService: IConfigurationEditingService,
|
||||
private _configurationEditService: ConfigurationEditingService,
|
||||
private _workspaceConfigurationService: IWorkspaceConfigurationService,
|
||||
private _capabilitiesService: ICapabilitiesService,
|
||||
private _cachedMetadata?: data.DataProtocolServerCapabilities[]
|
||||
cachedMetadata?: data.DataProtocolServerCapabilities[]
|
||||
) {
|
||||
this._providerCapabilitiesMap = {};
|
||||
this._providerCachedCapabilitiesMap = {};
|
||||
this.setCachedMetadata(cachedMetadata);
|
||||
}
|
||||
|
||||
public setCachedMetadata(cachedMetaData: data.DataProtocolServerCapabilities[]): void {
|
||||
this._cachedMetadata = cachedMetaData;
|
||||
public setCachedMetadata(cachedMetadata: data.DataProtocolServerCapabilities[]): void {
|
||||
if (cachedMetadata) {
|
||||
cachedMetadata.forEach(item => {
|
||||
this.updateCapabilitiesCache(item.providerName, item);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +61,6 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
let workspaceGroups = this.getConfiguration(Constants.connectionGroupsArrayName).workspace as IConnectionProfileGroup[];
|
||||
|
||||
if (userGroups) {
|
||||
|
||||
if (workspaceGroups) {
|
||||
userGroups = userGroups.filter(x => workspaceGroups.find(f => this.isSameGroupName(f, x)) === undefined);
|
||||
allGroups = allGroups.concat(workspaceGroups);
|
||||
@@ -74,43 +76,44 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
return allGroups;
|
||||
}
|
||||
|
||||
private updateCapabilitiesCache(providerName: string, providerCapabilities: data.DataProtocolServerCapabilities): void {
|
||||
if (providerName && providerCapabilities) {
|
||||
this._providerCapabilitiesMap[providerName] = providerCapabilities;
|
||||
}
|
||||
}
|
||||
|
||||
private getCapabilitiesFromCache(providerName: string): data.DataProtocolServerCapabilities {
|
||||
if (providerName in this._providerCapabilitiesMap) {
|
||||
return this._providerCapabilitiesMap[providerName];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the capabilities for given provider name. First tries to get it from capabilitiesService and if it's not registered yet,
|
||||
* Gets the data from the metadata stored in the config
|
||||
* @param providerName Provider Name
|
||||
*/
|
||||
public getCapabilities(providerName: string): data.DataProtocolServerCapabilities {
|
||||
let result: data.DataProtocolServerCapabilities;
|
||||
|
||||
if (providerName in this._providerCapabilitiesMap) {
|
||||
result = this._providerCapabilitiesMap[providerName];
|
||||
let result: data.DataProtocolServerCapabilities = this.getCapabilitiesFromCache(providerName);
|
||||
if (result) {
|
||||
return result;
|
||||
} else {
|
||||
let capabilities = this._capabilitiesService.getCapabilities();
|
||||
if (capabilities) {
|
||||
let providerCapabilities = capabilities.find(c => c.providerName === providerName);
|
||||
if (providerCapabilities) {
|
||||
this._providerCapabilitiesMap[providerName] = providerCapabilities;
|
||||
result = providerCapabilities;
|
||||
this.updateCapabilitiesCache(providerName, providerCapabilities);
|
||||
return providerCapabilities;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!result && this._cachedMetadata) {
|
||||
if (providerName in this._providerCachedCapabilitiesMap) {
|
||||
result = this._providerCachedCapabilitiesMap[providerName];
|
||||
} else {
|
||||
let metaDataFromConfig = this._cachedMetadata;
|
||||
if (metaDataFromConfig) {
|
||||
let providerCapabilities = metaDataFromConfig.find(m => m.providerName === providerName);
|
||||
this._providerCachedCapabilitiesMap[providerName] = providerCapabilities;
|
||||
result = providerCapabilities;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new connection to the connection config.
|
||||
*/
|
||||
@@ -118,13 +121,13 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
return new Promise<IConnectionProfile>((resolve, reject) => {
|
||||
if (profile.saveProfile) {
|
||||
this.addGroupFromProfile(profile).then(groupId => {
|
||||
let profiles = this._workspaceConfigurationService.lookup<IConnectionProfileStore[]>(Constants.connectionsArrayName).user;
|
||||
let profiles = this._workspaceConfigurationService.inspect<IConnectionProfileStore[]>(Constants.connectionsArrayName).user;
|
||||
if (!profiles) {
|
||||
profiles = [];
|
||||
}
|
||||
|
||||
let providerCapabilities = this.getCapabilities(profile.providerName);
|
||||
let connectionProfile = this.getConnectionProfileInstance(profile, groupId);
|
||||
let connectionProfile = this.getConnectionProfileInstance(profile, groupId, providerCapabilities);
|
||||
let newProfile = ConnectionProfile.convertToProfileStore(providerCapabilities, connectionProfile);
|
||||
|
||||
// Remove the profile if already set
|
||||
@@ -151,9 +154,8 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
});
|
||||
}
|
||||
|
||||
private getConnectionProfileInstance(profile: IConnectionProfile, groupId: string): ConnectionProfile {
|
||||
private getConnectionProfileInstance(profile: IConnectionProfile, groupId: string, providerCapabilities: data.DataProtocolServerCapabilities): ConnectionProfile {
|
||||
let connectionProfile = profile as ConnectionProfile;
|
||||
let providerCapabilities = this.getCapabilities(profile.providerName);
|
||||
if (connectionProfile === undefined) {
|
||||
connectionProfile = new ConnectionProfile(providerCapabilities, profile);
|
||||
}
|
||||
@@ -170,7 +172,7 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
if (profile.groupId && profile.groupId !== Utils.defaultGroupId) {
|
||||
resolve(profile.groupId);
|
||||
} else {
|
||||
let groups = this._workspaceConfigurationService.lookup<IConnectionProfileGroup[]>(Constants.connectionGroupsArrayName).user;
|
||||
let groups = this._workspaceConfigurationService.inspect<IConnectionProfileGroup[]>(Constants.connectionGroupsArrayName).user;
|
||||
let result = this.saveGroup(groups, profile.groupFullName, undefined, undefined);
|
||||
groups = result.groups;
|
||||
|
||||
@@ -192,7 +194,7 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
if (profileGroup.id) {
|
||||
resolve(profileGroup.id);
|
||||
} else {
|
||||
let groups = this._workspaceConfigurationService.lookup<IConnectionProfileGroup[]>(Constants.connectionGroupsArrayName).user;
|
||||
let groups = this._workspaceConfigurationService.inspect<IConnectionProfileGroup[]>(Constants.connectionGroupsArrayName).user;
|
||||
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.");
|
||||
@@ -221,7 +223,7 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
profiles = <IConnectionProfileStore[]>configs.workspace;
|
||||
}
|
||||
if (profiles) {
|
||||
if(this.fixConnectionIds(profiles)) {
|
||||
if (this.fixConnectionIds(profiles)) {
|
||||
this.writeConfiguration(Constants.connectionsArrayName, profiles, configTarget);
|
||||
}
|
||||
} else {
|
||||
@@ -245,9 +247,9 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
profile.id = generateUuid();
|
||||
changed = true;
|
||||
}
|
||||
if (profile.id in idsCache) {
|
||||
profile.id = generateUuid();
|
||||
changed = true;
|
||||
if (profile.id in idsCache) {
|
||||
profile.id = generateUuid();
|
||||
changed = true;
|
||||
}
|
||||
idsCache[profile.id] = true;
|
||||
}
|
||||
@@ -298,7 +300,7 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
*/
|
||||
public deleteConnection(profile: ConnectionProfile): Promise<void> {
|
||||
// Get all connections in the settings
|
||||
let profiles = this._workspaceConfigurationService.lookup<IConnectionProfileStore[]>(Constants.connectionsArrayName).user;
|
||||
let profiles = this._workspaceConfigurationService.inspect<IConnectionProfileStore[]>(Constants.connectionsArrayName).user;
|
||||
// Remove the profile from the connections
|
||||
profiles = profiles.filter(value => {
|
||||
let providerCapabilities = this.getCapabilities(value.providerName);
|
||||
@@ -320,7 +322,7 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
// Add selected group to subgroups list
|
||||
subgroups.push(group);
|
||||
// Get all connections in the settings
|
||||
let profiles = this._workspaceConfigurationService.lookup<IConnectionProfileStore[]>(Constants.connectionsArrayName).user;
|
||||
let profiles = this._workspaceConfigurationService.inspect<IConnectionProfileStore[]>(Constants.connectionsArrayName).user;
|
||||
// Remove the profiles from the connections
|
||||
profiles = profiles.filter(value => {
|
||||
let providerCapabilities = this.getCapabilities(value.providerName);
|
||||
@@ -329,7 +331,7 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
});
|
||||
|
||||
// Get all groups in the settings
|
||||
let groups = this._workspaceConfigurationService.lookup<IConnectionProfileGroup[]>(Constants.connectionGroupsArrayName).user;
|
||||
let groups = this._workspaceConfigurationService.inspect<IConnectionProfileGroup[]>(Constants.connectionGroupsArrayName).user;
|
||||
// Remove subgroups in the settings
|
||||
groups = groups.filter((grp) => {
|
||||
return !subgroups.some((item) => item.id === grp.id);
|
||||
@@ -347,7 +349,7 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
* Moves the source group under the target group.
|
||||
*/
|
||||
public changeGroupIdForConnectionGroup(source: ConnectionProfileGroup, target: ConnectionProfileGroup): Promise<void> {
|
||||
let groups = this._workspaceConfigurationService.lookup<IConnectionProfileGroup[]>(Constants.connectionGroupsArrayName).user;
|
||||
let groups = this._workspaceConfigurationService.inspect<IConnectionProfileGroup[]>(Constants.connectionGroupsArrayName).user;
|
||||
groups = groups.map(g => {
|
||||
if (g.id === source.id) {
|
||||
g.parentId = target.id;
|
||||
@@ -372,8 +374,8 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
*/
|
||||
private changeGroupIdForConnectionInSettings(profile: ConnectionProfile, newGroupID: string, target: ConfigurationTarget = ConfigurationTarget.USER): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
let profiles = target === ConfigurationTarget.USER ? this._workspaceConfigurationService.lookup<IConnectionProfileStore[]>(Constants.connectionsArrayName).user :
|
||||
this._workspaceConfigurationService.lookup<IConnectionProfileStore[]>(Constants.connectionsArrayName).workspace;
|
||||
let profiles = target === ConfigurationTarget.USER ? this._workspaceConfigurationService.inspect<IConnectionProfileStore[]>(Constants.connectionsArrayName).user :
|
||||
this._workspaceConfigurationService.inspect<IConnectionProfileStore[]>(Constants.connectionsArrayName).workspace;
|
||||
if (profiles) {
|
||||
let providerCapabilities = this.getCapabilities(profile.providerName);
|
||||
if (profile.parent && profile.parent.id === Constants.unsavedGroupId) {
|
||||
@@ -429,7 +431,7 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
}
|
||||
|
||||
public editGroup(source: ConnectionProfileGroup): Promise<void> {
|
||||
let groups = this._workspaceConfigurationService.lookup<IConnectionProfileGroup[]>(Constants.connectionGroupsArrayName).user;
|
||||
let groups = this._workspaceConfigurationService.inspect<IConnectionProfileGroup[]>(Constants.connectionGroupsArrayName).user;
|
||||
let sameNameGroup = groups ? groups.find(group => group.name === source.name && group.id !== source.id) : undefined;
|
||||
if (sameNameGroup) {
|
||||
let errMessage: string = nls.localize('invalidServerName', "A server group with the same name already exists.");
|
||||
@@ -510,10 +512,9 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
* @param parsedSettingsFile an object representing the parsed contents of the settings file.
|
||||
* @returns the set of connection profiles found in the parsed settings file.
|
||||
*/
|
||||
private getConfiguration(key: string): TConfigurationValue<IConnectionProfileStore[] | IConnectionProfileGroup[] | data.DataProtocolServerCapabilities[]> {
|
||||
let configs: TConfigurationValue<IConnectionProfileStore[] | IConnectionProfileGroup[] | data.DataProtocolServerCapabilities[]>;
|
||||
|
||||
configs = this._workspaceConfigurationService.lookup<IConnectionProfileStore[] | IConnectionProfileGroup[] | data.DataProtocolServerCapabilities[]>(key);
|
||||
private getConfiguration(key: string): any {
|
||||
let configs: any;
|
||||
configs = this._workspaceConfigurationService.inspect<IConnectionProfileStore[] | IConnectionProfileGroup[] | data.DataProtocolServerCapabilities[]>(key);
|
||||
return configs;
|
||||
}
|
||||
|
||||
@@ -532,7 +533,7 @@ export class ConnectionConfig implements IConnectionConfig {
|
||||
value: profiles
|
||||
};
|
||||
this._configurationEditService.writeConfiguration(target, configValue).then(result => {
|
||||
this._workspaceConfigurationService.reloadConfiguration().then(() => {
|
||||
this._workspaceConfigurationService.reloadConfiguration().then(() => {
|
||||
resolve();
|
||||
});
|
||||
}, (error => {
|
||||
|
||||
@@ -9,12 +9,12 @@ import { IViewlet } from 'vs/workbench/common/viewlet';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import Event from 'vs/base/common/event';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import data = require('data');
|
||||
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { ISelectionData } from 'data';
|
||||
import { ConnectionManagementInfo } from './connectionManagementInfo';
|
||||
|
||||
export const VIEWLET_ID = 'workbench.view.connections';
|
||||
@@ -57,6 +57,7 @@ export interface IConnectionResult {
|
||||
connected: boolean;
|
||||
errorMessage: string;
|
||||
errorCode: number;
|
||||
callStack: string;
|
||||
errorHandled?: boolean;
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ export interface IConnectionManagementService {
|
||||
/**
|
||||
* Opens the connection dialog to create new connection
|
||||
*/
|
||||
showConnectionDialog(params?: INewConnectionParams, model?: IConnectionProfile, error?: string): Promise<void>;
|
||||
showConnectionDialog(params?: INewConnectionParams, model?: IConnectionProfile, connectionResult?: IConnectionResult): Promise<void>;
|
||||
|
||||
/**
|
||||
* Opens the add server group dialog
|
||||
@@ -135,6 +136,8 @@ export interface IConnectionManagementService {
|
||||
|
||||
clearRecentConnectionsList(): void;
|
||||
|
||||
clearRecentConnection(connectionProfile: IConnectionProfile) : void;
|
||||
|
||||
getActiveConnections(): ConnectionProfile[];
|
||||
|
||||
saveProfileGroup(profile: IConnectionProfileGroup): Promise<string>;
|
||||
@@ -253,7 +256,7 @@ export interface IConnectionManagementService {
|
||||
export const IConnectionDialogService = createDecorator<IConnectionDialogService>('connectionDialogService');
|
||||
export interface IConnectionDialogService {
|
||||
_serviceBrand: any;
|
||||
showDialog(connectionManagementService: IConnectionManagementService, params: INewConnectionParams, model: IConnectionProfile, error?: string): Thenable<void>;
|
||||
showDialog(connectionManagementService: IConnectionManagementService, params: INewConnectionParams, model: IConnectionProfile, connectionResult?: IConnectionResult): Thenable<void>;
|
||||
}
|
||||
|
||||
export interface IServerGroupDialogCallbacks {
|
||||
@@ -270,7 +273,7 @@ export interface IServerGroupController {
|
||||
export const IErrorMessageService = createDecorator<IErrorMessageService>('errorMessageService');
|
||||
export interface IErrorMessageService {
|
||||
_serviceBrand: any;
|
||||
showDialog(severity: Severity, headerTitle: string, message: string): void;
|
||||
showDialog(severity: Severity, headerTitle: string, message: string, messageDetails?: string, actions?: IAction[]): void;
|
||||
}
|
||||
|
||||
export enum ServiceOptionType {
|
||||
@@ -295,14 +298,15 @@ export enum RunQueryOnConnectionMode {
|
||||
none = 0,
|
||||
executeQuery = 1,
|
||||
executeCurrentQuery = 2,
|
||||
estimatedQueryPlan = 3
|
||||
estimatedQueryPlan = 3,
|
||||
actualQueryPlan = 4
|
||||
}
|
||||
|
||||
export interface INewConnectionParams {
|
||||
connectionType: ConnectionType;
|
||||
input?: IConnectableInput;
|
||||
runQueryOnCompletion?: RunQueryOnConnectionMode;
|
||||
querySelection?: ISelectionData;
|
||||
querySelection?: data.ISelectionData;
|
||||
showDashboard?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ export class ConnectionManagementInfo {
|
||||
/**
|
||||
* Callback for when a connection notification is received.
|
||||
*/
|
||||
public connectHandler: (result: boolean, errorMessage?: string, errorCode?: number) => void;
|
||||
public connectHandler: (result: boolean, errorMessage?: string, errorCode?: number, callStack?: string) => void;
|
||||
|
||||
/**
|
||||
* Information about the SQL Server instance.
|
||||
|
||||
@@ -43,7 +43,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ConnectionProfileGroup, IConnectionProfileGroup } from './connectionProfileGroup';
|
||||
import { IConfigurationEditingService } from 'vs/workbench/services/configuration/common/configurationEditing';
|
||||
import { ConfigurationEditingService } from 'vs/workbench/services/configuration/node/configurationEditingService';
|
||||
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
@@ -78,6 +78,8 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
|
||||
private _connectionGlobalStatus: ConnectionGlobalStatus;
|
||||
|
||||
private _configurationEditService: ConfigurationEditingService;
|
||||
|
||||
constructor(
|
||||
private _connectionMemento: Memento,
|
||||
private _connectionStore: ConnectionStore,
|
||||
@@ -89,7 +91,6 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
@IWorkspaceContextService private _contextService: IWorkspaceContextService,
|
||||
@IStorageService private _storageService: IStorageService,
|
||||
@ITelemetryService private _telemetryService: ITelemetryService,
|
||||
@IConfigurationEditingService private _configurationEditService: IConfigurationEditingService,
|
||||
@IWorkspaceConfigurationService private _workspaceConfigurationService: IWorkspaceConfigurationService,
|
||||
@ICredentialsService private _credentialsService: ICredentialsService,
|
||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
||||
@@ -100,13 +101,17 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
@IViewletService private _viewletService: IViewletService,
|
||||
@IAngularEventingService private _angularEventing: IAngularEventingService
|
||||
) {
|
||||
if (this._instantiationService) {
|
||||
this._configurationEditService = this._instantiationService.createInstance(ConfigurationEditingService);
|
||||
}
|
||||
|
||||
// _connectionMemento and _connectionStore are in constructor to enable this class to be more testable
|
||||
if (!this._connectionMemento) {
|
||||
this._connectionMemento = new Memento('ConnectionManagement');
|
||||
}
|
||||
if (!this._connectionStore) {
|
||||
this._connectionStore = new ConnectionStore(_storageService, this._connectionMemento,
|
||||
_configurationEditService, this._workspaceConfigurationService, this._credentialsService, this._capabilitiesService);
|
||||
this._configurationEditService, this._workspaceConfigurationService, this._credentialsService, this._capabilitiesService);
|
||||
}
|
||||
|
||||
this._connectionStatusManager = new ConnectionStatusManager(this._capabilitiesService);
|
||||
@@ -196,7 +201,7 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
// show the Registered Server viewlet
|
||||
let startupConfig = this._workspaceConfigurationService.getConfiguration('startup');
|
||||
if (startupConfig) {
|
||||
let showServerViewlet = <boolean>startupConfig['alwaysShowServersView'];
|
||||
let showServerViewlet = <boolean>startupConfig['alwaysShowServersView'];
|
||||
if (showServerViewlet) {
|
||||
// only show the Servers viewlet if there isn't another active viewlet
|
||||
if (!this._viewletService.getActiveViewlet()) {
|
||||
@@ -212,7 +217,7 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
* @param params Include the uri, type of connection
|
||||
* @param model the existing connection profile to create a new one from
|
||||
*/
|
||||
public showConnectionDialog(params?: INewConnectionParams, model?: IConnectionProfile, error?: string): Promise<void> {
|
||||
public showConnectionDialog(params?: INewConnectionParams, model?: IConnectionProfile, connectionResult?: IConnectionResult): Promise<void> {
|
||||
let self = this;
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
if (!params) {
|
||||
@@ -221,7 +226,7 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
if (!model && params.input && params.input.uri) {
|
||||
model = this._connectionStatusManager.getConnectionProfile(params.input.uri);
|
||||
}
|
||||
self._connectionDialogService.showDialog(self, params, model, error).then(() => {
|
||||
self._connectionDialogService.showDialog(self, params, model, connectionResult).then(() => {
|
||||
resolve();
|
||||
}, dialogError => {
|
||||
warn('failed to open the connection dialog. error: ' + dialogError);
|
||||
@@ -301,7 +306,7 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
}
|
||||
// If the password is required and still not loaded show the dialog
|
||||
if (!foundPassword && this._connectionStore.isPasswordRequired(newConnection) && !newConnection.password) {
|
||||
resolve(this.showConnectionDialogOnError(connection, owner, { connected: false, errorMessage: undefined, errorCode: undefined }, options));
|
||||
resolve(this.showConnectionDialogOnError(connection, owner, { connected: false, errorMessage: undefined, callStack: undefined, errorCode: undefined }, options));
|
||||
} else {
|
||||
// Try to connect
|
||||
this.connectWithOptions(newConnection, owner.uri, options, owner).then(connectionResult => {
|
||||
@@ -340,7 +345,7 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
runQueryOnCompletion: RunQueryOnConnectionMode.none,
|
||||
showDashboard: options.showDashboard
|
||||
};
|
||||
this.showConnectionDialog(params, connection, connectionResult.errorMessage).then(() => {
|
||||
this.showConnectionDialog(params, connection, connectionResult).then(() => {
|
||||
resolve(connectionResult);
|
||||
}).catch(err => {
|
||||
reject(err);
|
||||
@@ -643,6 +648,10 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
return this._connectionStore.clearRecentlyUsed();
|
||||
}
|
||||
|
||||
public clearRecentConnection(connectionProfile: IConnectionProfile) : void {
|
||||
this._connectionStore.removeConnectionToMemento(connectionProfile, Constants.recentConnections);
|
||||
}
|
||||
|
||||
public getActiveConnections(): ConnectionProfile[] {
|
||||
return this._connectionStore.getActiveConnections();
|
||||
}
|
||||
@@ -825,6 +834,9 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
return new Promise<data.ListDatabasesResult>((resolve, reject) => {
|
||||
let provider = this._providers[providerId];
|
||||
provider.listDatabases(uri).then(result => {
|
||||
if (result && result.databaseNames) {
|
||||
result.databaseNames.sort();
|
||||
}
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
@@ -845,9 +857,9 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
/**
|
||||
* Add a connection to the active connections list.
|
||||
*/
|
||||
private tryAddActiveConnection(connectionManagementInfo: ConnectionManagementInfo, newConnection: IConnectionProfile): void {
|
||||
private tryAddActiveConnection(connectionManagementInfo: ConnectionManagementInfo, newConnection: IConnectionProfile, isConnectionToDefaultDb: boolean): void {
|
||||
if (newConnection) {
|
||||
this._connectionStore.addActiveConnection(newConnection)
|
||||
this._connectionStore.addActiveConnection(newConnection, isConnectionToDefaultDb)
|
||||
.then(() => {
|
||||
connectionManagementInfo.connectHandler(true);
|
||||
}, err => {
|
||||
@@ -881,6 +893,10 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
let connection = this._connectionStatusManager.onConnectionComplete(info);
|
||||
|
||||
if (info.connectionId) {
|
||||
let isConnectionToDefaultDb = false;
|
||||
if (connection.connectionProfile && (!connection.connectionProfile.databaseName || connection.connectionProfile.databaseName.trim() === '')) {
|
||||
isConnectionToDefaultDb = true;
|
||||
}
|
||||
if (info.connectionSummary && info.connectionSummary.databaseName) {
|
||||
this._connectionStatusManager.updateDatabaseName(info);
|
||||
}
|
||||
@@ -889,14 +905,14 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
|
||||
connection.connectHandler(true);
|
||||
let activeConnection = connection.connectionProfile;
|
||||
self.tryAddActiveConnection(connection, activeConnection);
|
||||
self.tryAddActiveConnection(connection, activeConnection, isConnectionToDefaultDb);
|
||||
self.addTelemetryForConnection(connection);
|
||||
} else {
|
||||
connection.connectHandler(false, info.messages, info.errorNumber);
|
||||
}
|
||||
|
||||
if (this._connectionStatusManager.isDefaultTypeUri(info.ownerUri)) {
|
||||
this._connectionGlobalStatus.setStatusToConnected(info.connectionSummary);
|
||||
if (self._connectionStatusManager.isDefaultTypeUri(info.ownerUri)) {
|
||||
self._connectionGlobalStatus.setStatusToConnected(info.connectionSummary);
|
||||
}
|
||||
} else {
|
||||
connection.connectHandler(false, info.errorMessage, info.errorNumber, info.messages);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1004,18 +1020,18 @@ export class ConnectionManagementService implements IConnectionManagementService
|
||||
this._capabilitiesService.onCapabilitiesReady().then(() => {
|
||||
let connectionInfo = this._connectionStatusManager.addConnection(connection, uri);
|
||||
// Setup the handler for the connection complete notification to call
|
||||
connectionInfo.connectHandler = ((connectResult, errorMessage, errorCode) => {
|
||||
connectionInfo.connectHandler = ((connectResult, errorMessage, errorCode, callStack) => {
|
||||
let connectionMngInfo = this._connectionStatusManager.findConnection(uri);
|
||||
if (connectionMngInfo && connectionMngInfo.deleted) {
|
||||
this._connectionStatusManager.deleteConnection(uri);
|
||||
resolve({ connected: connectResult, errorMessage: undefined, errorCode: undefined, errorHandled: true });
|
||||
resolve({ connected: connectResult, errorMessage: undefined, errorCode: undefined, callStack: undefined, errorHandled: true });
|
||||
} else {
|
||||
if (errorMessage) {
|
||||
// Connection to the server failed
|
||||
this._connectionStatusManager.deleteConnection(uri);
|
||||
resolve({ connected: connectResult, errorMessage: errorMessage, errorCode: errorCode });
|
||||
resolve({ connected: connectResult, errorMessage: errorMessage, errorCode: errorCode, callStack: callStack });
|
||||
} else {
|
||||
resolve({ connected: connectResult, errorMessage: errorMessage, errorCode: errorCode });
|
||||
resolve({ connected: connectResult, errorMessage: errorMessage, errorCode: errorCode, callStack: callStack });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -79,6 +79,26 @@ export class ConnectionProfileGroup implements IConnectionProfileGroup {
|
||||
return false;
|
||||
}
|
||||
|
||||
public get hasValidConnections(): boolean {
|
||||
if (this.connections) {
|
||||
let invalidConnections = this.connections.find(c => c.serverCapabilities === undefined);
|
||||
if (invalidConnections !== undefined) {
|
||||
return false;
|
||||
} else {
|
||||
let childrenAreValid: boolean = true;
|
||||
this.children.forEach(element => {
|
||||
let isChildValid = element.hasValidConnections;
|
||||
if (!isChildValid) {
|
||||
childrenAreValid = false;
|
||||
}
|
||||
});
|
||||
return childrenAreValid;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public getChildren(): any {
|
||||
let allChildren = [];
|
||||
|
||||
|
||||
@@ -155,9 +155,9 @@ export class ConnectionStatusManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to find an existing connection that's mapped with given the ownerUri
|
||||
* Tries to find an existing connection that's mapped with the given ownerUri
|
||||
* The purpose for this method is to find the connection given the ownerUri and find the original uri assigned to it. most of the times should be the same.
|
||||
* Only if the db name in the original uri is different than when connection is complete, we need to use the original uri
|
||||
* Only if the db name in the original uri is different when connection is complete, we need to use the original uri
|
||||
* Returns the generated ownerUri for the connection profile if not existing connection found
|
||||
* @param ownerUri connection owner uri to find an existing connection
|
||||
* @param purpose purpose for the connection
|
||||
|
||||
@@ -15,11 +15,11 @@ import { ConnectionConfig } from './connectionConfig';
|
||||
import { Memento, Scope as MementoScope } from 'vs/workbench/common/memento';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ConnectionProfileGroup, IConnectionProfileGroup } from './connectionProfileGroup';
|
||||
import { IConfigurationEditingService } from 'vs/workbench/services/configuration/common/configurationEditing';
|
||||
import { ConfigurationEditingService } from 'vs/workbench/services/configuration/node/configurationEditingService';
|
||||
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { equalsIgnoreCase } from 'vs/base/common/strings';
|
||||
import * as data from 'data';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
const MAX_CONNECTIONS_DEFAULT = 25;
|
||||
|
||||
@@ -37,24 +37,21 @@ export class ConnectionStore {
|
||||
constructor(
|
||||
private _storageService: IStorageService,
|
||||
private _context: Memento,
|
||||
private _configurationEditService: IConfigurationEditingService,
|
||||
private _configurationEditService: ConfigurationEditingService,
|
||||
private _workspaceConfigurationService: IWorkspaceConfigurationService,
|
||||
private _credentialService: ICredentialsService,
|
||||
private _capabilitiesService: ICapabilitiesService,
|
||||
private _connectionConfig?: IConnectionConfig
|
||||
) {
|
||||
|
||||
if (_context) {
|
||||
this._memento = this._context.getMemento(this._storageService, MementoScope.GLOBAL);
|
||||
}
|
||||
this._groupIdToFullNameMap = {};
|
||||
this._groupFullNameToIdMap = {};
|
||||
|
||||
if (!this._connectionConfig) {
|
||||
let cachedServerCapabilities = this.getCachedServerCapabilities();
|
||||
this._connectionConfig = new ConnectionConfig(this._configurationEditService,
|
||||
this._workspaceConfigurationService, this._capabilitiesService, cachedServerCapabilities);
|
||||
this._connectionConfig.setCachedMetadata(cachedServerCapabilities);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,17 +112,6 @@ export class ConnectionStore {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all connection profiles stored in the user settings
|
||||
* Profiles from workspace will be included if getWorkspaceProfiles is passed as true
|
||||
* Note: connections will not include password value
|
||||
*
|
||||
* @returns {IConnectionProfile[]}
|
||||
*/
|
||||
public getProfiles(getWorkspaceProfiles: boolean): IConnectionProfile[] {
|
||||
return this.loadProfiles(getWorkspaceProfiles);
|
||||
}
|
||||
|
||||
public addSavedPassword(credentialsItem: IConnectionProfile): Promise<{ profile: IConnectionProfile, savedCred: boolean }> {
|
||||
let self = this;
|
||||
return new Promise<{ profile: IConnectionProfile, savedCred: boolean }>((resolve, reject) => {
|
||||
@@ -314,12 +300,15 @@ export class ConnectionStore {
|
||||
* @param {IConnectionCredentials} conn the connection to add
|
||||
* @returns {Promise<void>} a Promise that returns when the connection was saved
|
||||
*/
|
||||
public addActiveConnection(conn: IConnectionProfile): Promise<void> {
|
||||
if(this.getActiveConnections().some(existingConn => existingConn.id === conn.id)) {
|
||||
public addActiveConnection(conn: IConnectionProfile, isConnectionToDefaultDb: boolean = false): Promise<void> {
|
||||
if (this.getActiveConnections().some(existingConn => existingConn.id === conn.id)) {
|
||||
return Promise.resolve(undefined);
|
||||
} else {
|
||||
return this.addConnectionToMemento(conn, Constants.activeConnections, undefined, conn.savePassword).then(() => {
|
||||
let maxConnections = this.getMaxRecentConnectionsCount();
|
||||
if (isConnectionToDefaultDb) {
|
||||
conn.databaseName = '';
|
||||
}
|
||||
return this.addConnectionToMemento(conn, Constants.recentConnections, maxConnections);
|
||||
});
|
||||
}
|
||||
@@ -330,8 +319,7 @@ export class ConnectionStore {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
// Get all profiles
|
||||
let configValues = self.getConnectionsFromMemento(mementoKey);
|
||||
let configToSave: IConnectionProfile[] = this.addToConnectionList(conn, configValues, mementoKey === Constants.recentConnections);
|
||||
|
||||
let configToSave = this.addToConnectionList(conn, configValues);
|
||||
if (maxConnections) {
|
||||
// Remove last element if needed
|
||||
if (configToSave.length > maxConnections) {
|
||||
@@ -349,24 +337,6 @@ export class ConnectionStore {
|
||||
});
|
||||
}
|
||||
|
||||
private isSameConnectionProfileNoGroup(profile1: IConnectionProfile, profile2: IConnectionProfile): boolean {
|
||||
// both are undefined
|
||||
if (!profile1 && !profile2) {
|
||||
return true;
|
||||
}
|
||||
// only one is undefined
|
||||
if (!profile1 || !profile2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// compare all the connection's "identity" properties
|
||||
return equalsIgnoreCase(profile1.serverName, profile2.serverName) &&
|
||||
equalsIgnoreCase(profile1.databaseName, profile2.databaseName) &&
|
||||
equalsIgnoreCase(profile1.userName, profile2.userName) &&
|
||||
profile1.authenticationType === profile2.authenticationType &&
|
||||
profile1.providerName === profile2.providerName;
|
||||
}
|
||||
|
||||
public removeConnectionToMemento(conn: IConnectionProfile, mementoKey: string): Promise<void> {
|
||||
const self = this;
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
@@ -388,25 +358,18 @@ export class ConnectionStore {
|
||||
return this.convertConfigValuesToConnectionProfiles(configValues);
|
||||
}
|
||||
|
||||
private addToConnectionList(conn: IConnectionProfile, list: ConnectionProfile[], isRecentConnections: boolean): IConnectionProfile[] {
|
||||
private addToConnectionList(conn: IConnectionProfile, list: ConnectionProfile[]): IConnectionProfile[] {
|
||||
let savedProfile: ConnectionProfile = this.getProfileWithoutPassword(conn);
|
||||
|
||||
// Remove the connection from the list if it already exists
|
||||
if (isRecentConnections) {
|
||||
// recent connections should use a different comparison the server viewlet for managing connection list
|
||||
list = list.filter(value => {
|
||||
return !(this.isSameConnectionProfileNoGroup(value, savedProfile));
|
||||
});
|
||||
} else {
|
||||
list = list.filter(value => {
|
||||
let equal = value && value.getConnectionInfoId() === savedProfile.getConnectionInfoId();
|
||||
if (equal && savedProfile.saveProfile) {
|
||||
equal = value.groupId === savedProfile.groupId ||
|
||||
ConnectionProfileGroup.sameGroupName(value.groupFullName, savedProfile.groupFullName);
|
||||
}
|
||||
return !equal;
|
||||
});
|
||||
}
|
||||
list = list.filter(value => {
|
||||
let equal = value && value.getConnectionInfoId() === savedProfile.getConnectionInfoId();
|
||||
if (equal && savedProfile.saveProfile) {
|
||||
equal = value.groupId === savedProfile.groupId ||
|
||||
ConnectionProfileGroup.sameGroupName(value.groupFullName, savedProfile.groupFullName);
|
||||
}
|
||||
return !equal;
|
||||
});
|
||||
|
||||
list.unshift(savedProfile);
|
||||
|
||||
@@ -527,11 +490,6 @@ export class ConnectionStore {
|
||||
return result;
|
||||
}
|
||||
|
||||
private loadProfiles(loadWorkspaceProfiles: boolean): IConnectionProfile[] {
|
||||
let connections: IConnectionProfile[] = this._connectionConfig.getConnections(loadWorkspaceProfiles);
|
||||
return connections;
|
||||
}
|
||||
|
||||
private getMaxRecentConnectionsCount(): number {
|
||||
let config = this._workspaceConfigurationService.getConfiguration(Constants.sqlConfigSectionName);
|
||||
|
||||
|
||||
@@ -25,3 +25,10 @@ export const mssqlProviderName = 'MSSQL';
|
||||
export const applicationName = 'sqlops';
|
||||
|
||||
export const defaultEngine = 'defaultEngine';
|
||||
|
||||
export const passwordChars = '***************';
|
||||
|
||||
/* authentication types */
|
||||
export const sqlLogin = 'SqlLogin';
|
||||
export const integrated = 'Integrated';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user