mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 01:25:38 -05:00
Another code layering (#4037)
* working on formatting * fixed basic lint errors; starting moving things to their appropriate location * formatting * update tslint to match the version of vscode we have * remove unused code * work in progress fixing layering * formatting * moved connection management service to platform * formatting * add missing file * moving more servies * formatting * moving more services * formatting * wip * moving more services * formatting * move css file * add missing svgs * moved the rest of services * formatting * changing around some references * formatting * revert tslint * revert some changes that brake things * formatting * fix tests * fix testzx * fix tests * fix tests * fix compile issue
This commit is contained in:
@@ -0,0 +1,196 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IConnectionComponentCallbacks, IConnectionComponentController, IConnectionValidateResult } from 'sql/workbench/services/connection/browser/connectionDialogService';
|
||||
import { AdvancedPropertiesController } from 'sql/parts/connection/connectionDialog/advancedPropertiesController';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as Utils from 'sql/platform/connection/common/utils';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||
import { ConnectionWidget } from 'sql/workbench/services/connection/browser/connectionWidget';
|
||||
|
||||
export class ConnectionController implements IConnectionComponentController {
|
||||
private _container: HTMLElement;
|
||||
private _connectionManagementService: IConnectionManagementService;
|
||||
private _callback: IConnectionComponentCallbacks;
|
||||
private _connectionWidget: ConnectionWidget;
|
||||
private _advancedController: AdvancedPropertiesController;
|
||||
private _model: IConnectionProfile;
|
||||
private _providerOptions: sqlops.ConnectionOption[];
|
||||
private _providerName: string;
|
||||
/* key: uri, value : list of databases */
|
||||
private _databaseCache = new Map<string, string[]>();
|
||||
|
||||
constructor(container: HTMLElement,
|
||||
connectionManagementService: IConnectionManagementService,
|
||||
connectionProperties: ConnectionProviderProperties,
|
||||
callback: IConnectionComponentCallbacks,
|
||||
providerName: string,
|
||||
@IInstantiationService private _instantiationService: IInstantiationService) {
|
||||
this._container = container;
|
||||
this._connectionManagementService = connectionManagementService;
|
||||
this._callback = callback;
|
||||
this._providerOptions = connectionProperties.connectionOptions;
|
||||
var specialOptions = this._providerOptions.filter(
|
||||
(property) => (property.specialValueType !== null && property.specialValueType !== undefined));
|
||||
this._connectionWidget = this._instantiationService.createInstance(ConnectionWidget, specialOptions, {
|
||||
onSetConnectButton: (enable: boolean) => this._callback.onSetConnectButton(enable),
|
||||
onCreateNewServerGroup: () => this.onCreateNewServerGroup(),
|
||||
onAdvancedProperties: () => this.handleOnAdvancedProperties(),
|
||||
onSetAzureTimeOut: () => this.handleonSetAzureTimeOut(),
|
||||
onFetchDatabases: (serverName: string, authenticationType: string, userName?: string, password?: string) => this.onFetchDatabases(
|
||||
serverName, authenticationType, userName, password).then(result => {
|
||||
return result;
|
||||
})
|
||||
}, providerName);
|
||||
this._providerName = providerName;
|
||||
}
|
||||
|
||||
private onFetchDatabases(serverName: string, authenticationType: string, userName?: string, password?: string): Promise<string[]> {
|
||||
let tempProfile = this._model;
|
||||
tempProfile.serverName = serverName;
|
||||
tempProfile.authenticationType = authenticationType;
|
||||
tempProfile.userName = userName;
|
||||
tempProfile.password = password;
|
||||
tempProfile.groupFullName = '';
|
||||
tempProfile.saveProfile = false;
|
||||
let uri = this._connectionManagementService.getConnectionUri(tempProfile);
|
||||
return new Promise<string[]>((resolve, reject) => {
|
||||
if (this._databaseCache.has(uri)) {
|
||||
let cachedDatabases: string[] = this._databaseCache.get(uri);
|
||||
if (cachedDatabases !== null) {
|
||||
resolve(cachedDatabases);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
} else {
|
||||
this._connectionManagementService.connect(tempProfile, uri).then(connResult => {
|
||||
if (connResult && connResult.connected) {
|
||||
this._connectionManagementService.listDatabases(uri).then(result => {
|
||||
if (result && result.databaseNames) {
|
||||
this._databaseCache.set(uri, result.databaseNames);
|
||||
resolve(result.databaseNames);
|
||||
} else {
|
||||
this._databaseCache.set(uri, null);
|
||||
reject();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
reject(connResult.errorMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private onCreateNewServerGroup(): void {
|
||||
this._connectionManagementService.showCreateServerGroupDialog({
|
||||
onAddGroup: (groupName) => this._connectionWidget.updateServerGroup(this.getAllServerGroups(), groupName),
|
||||
onClose: () => this._connectionWidget.focusOnServerGroup()
|
||||
});
|
||||
}
|
||||
|
||||
private handleonSetAzureTimeOut(): void {
|
||||
var timeoutPropertyName = 'connectTimeout';
|
||||
var timeoutOption = this._model.options[timeoutPropertyName];
|
||||
if (timeoutOption === undefined || timeoutOption === null) {
|
||||
this._model.options[timeoutPropertyName] = 30;
|
||||
}
|
||||
}
|
||||
|
||||
private handleOnAdvancedProperties(): void {
|
||||
if (!this._advancedController) {
|
||||
this._advancedController = this._instantiationService.createInstance(AdvancedPropertiesController, () => this._connectionWidget.focusOnAdvancedButton());
|
||||
}
|
||||
var advancedOption = this._providerOptions.filter(
|
||||
(property) => (property.specialValueType === undefined || property.specialValueType === null));
|
||||
this._advancedController.showDialog(advancedOption, this._container, this._model.options);
|
||||
}
|
||||
|
||||
public showUiComponent(container: HTMLElement): void {
|
||||
this._databaseCache = new Map<string, string[]>();
|
||||
this._connectionWidget.createConnectionWidget(container);
|
||||
}
|
||||
|
||||
private getServerGroupHelper(group: ConnectionProfileGroup, groupNames: IConnectionProfileGroup[]): void {
|
||||
if (group) {
|
||||
if (group.fullName !== '') {
|
||||
groupNames.push(group);
|
||||
}
|
||||
if (group.hasChildren()) {
|
||||
group.children.forEach((child) => this.getServerGroupHelper(child, groupNames));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getAllServerGroups(providers?: string[]): IConnectionProfileGroup[] {
|
||||
var connectionGroupRoot = this._connectionManagementService.getConnectionGroups(providers);
|
||||
var connectionGroupNames: IConnectionProfileGroup[] = [];
|
||||
if (connectionGroupRoot && connectionGroupRoot.length > 0) {
|
||||
this.getServerGroupHelper(connectionGroupRoot[0], connectionGroupNames);
|
||||
}
|
||||
let defaultGroupId: string;
|
||||
if (connectionGroupRoot && connectionGroupRoot.length > 0 && ConnectionProfileGroup.isRoot(connectionGroupRoot[0].name)) {
|
||||
defaultGroupId = connectionGroupRoot[0].id;
|
||||
} else {
|
||||
defaultGroupId = Utils.defaultGroupId;
|
||||
}
|
||||
connectionGroupNames.push(Object.assign({}, this._connectionWidget.DefaultServerGroup, { id: defaultGroupId }));
|
||||
connectionGroupNames.push(this._connectionWidget.NoneServerGroup);
|
||||
return connectionGroupNames;
|
||||
}
|
||||
|
||||
public initDialog(providers: string[], connectionInfo: IConnectionProfile): void {
|
||||
this._connectionWidget.updateServerGroup(this.getAllServerGroups(providers));
|
||||
this._model = connectionInfo;
|
||||
this._model.providerName = this._providerName;
|
||||
let appNameOption = this._providerOptions.find(option => option.specialValueType === ConnectionOptionSpecialType.appName);
|
||||
if (appNameOption) {
|
||||
let appNameKey = appNameOption.name;
|
||||
this._model.options[appNameKey] = Constants.applicationName;
|
||||
}
|
||||
this._connectionWidget.initDialog(this._model);
|
||||
}
|
||||
|
||||
public focusOnOpen(): void {
|
||||
this._connectionWidget.focusOnOpen();
|
||||
}
|
||||
|
||||
public validateConnection(): IConnectionValidateResult {
|
||||
return { isValid: this._connectionWidget.connect(this._model), connection: this._model };
|
||||
}
|
||||
|
||||
public fillInConnectionInputs(connectionInfo: IConnectionProfile): void {
|
||||
this._model = connectionInfo;
|
||||
this._connectionWidget.fillInConnectionInputs(connectionInfo);
|
||||
}
|
||||
|
||||
public handleOnConnecting(): void {
|
||||
this._connectionWidget.handleOnConnecting();
|
||||
}
|
||||
|
||||
public handleResetConnection(): void {
|
||||
this._connectionWidget.handleResetConnection();
|
||||
}
|
||||
|
||||
public closeDatabaseDropdown(): void {
|
||||
this._connectionWidget.closeDatabaseDropdown();
|
||||
}
|
||||
|
||||
public get databaseDropdownExpanded(): boolean {
|
||||
return this._connectionWidget.databaseDropdownExpanded;
|
||||
}
|
||||
|
||||
public set databaseDropdownExpanded(val: boolean) {
|
||||
this._connectionWidget.databaseDropdownExpanded = val;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,408 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import {
|
||||
IConnectionManagementService,
|
||||
ConnectionType, INewConnectionParams, IConnectionCompletionOptions, IConnectionResult
|
||||
} from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionDialogWidget, OnShowUIResponse } from 'sql/workbench/services/connection/browser/connectionDialogWidget';
|
||||
import { ConnectionController } from 'sql/workbench/services/connection/browser/connectionController';
|
||||
import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { entries } from 'sql/base/common/objects';
|
||||
import { Deferred } from 'sql/base/common/promise';
|
||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||
import { IConnectionDialogService } from 'sql/workbench/services/connection/common/connectionDialogService';
|
||||
|
||||
import { IPartService } from 'vs/workbench/services/part/common/partService';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { Action, IAction } from 'vs/base/common/actions';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import { trim } from 'vs/base/common/strings';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export interface IConnectionValidateResult {
|
||||
isValid: boolean;
|
||||
connection: IConnectionProfile;
|
||||
}
|
||||
|
||||
export interface IConnectionComponentCallbacks {
|
||||
onSetConnectButton: (enable: boolean) => void;
|
||||
onCreateNewServerGroup?: () => void;
|
||||
onAdvancedProperties?: () => void;
|
||||
onSetAzureTimeOut?: () => void;
|
||||
onFetchDatabases?: (serverName: string, authenticationType: string, userName?: string, password?: string) => Promise<string[]>;
|
||||
}
|
||||
|
||||
export interface IConnectionComponentController {
|
||||
showUiComponent(container: HTMLElement): void;
|
||||
initDialog(providers: string[], model: IConnectionProfile): void;
|
||||
validateConnection(): IConnectionValidateResult;
|
||||
fillInConnectionInputs(connectionInfo: IConnectionProfile): void;
|
||||
handleOnConnecting(): void;
|
||||
handleResetConnection(): void;
|
||||
focusOnOpen(): void;
|
||||
closeDatabaseDropdown(): void;
|
||||
databaseDropdownExpanded: boolean;
|
||||
}
|
||||
|
||||
export class ConnectionDialogService implements IConnectionDialogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private _container: HTMLElement;
|
||||
private _connectionDialog: ConnectionDialogWidget;
|
||||
private _connectionControllerMap: { [providerDisplayName: string]: IConnectionComponentController } = {};
|
||||
private _model: ConnectionProfile;
|
||||
private _params: INewConnectionParams;
|
||||
private _inputModel: IConnectionProfile;
|
||||
private _providerNameToDisplayNameMap: { [providerDisplayName: string]: string } = {};
|
||||
private _providerTypes: string[] = [];
|
||||
private _currentProviderType: string = 'Microsoft SQL Server';
|
||||
private _connecting: boolean = false;
|
||||
private _connectionErrorTitle = localize('connectionError', 'Connection error');
|
||||
private _dialogDeferredPromise: Deferred<IConnectionProfile>;
|
||||
|
||||
private _connectionManagementService: IConnectionManagementService;
|
||||
|
||||
constructor(
|
||||
@IPartService private _partService: IPartService,
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
||||
@IErrorMessageService private _errorMessageService: IErrorMessageService,
|
||||
@IWorkspaceConfigurationService private _workspaceConfigurationService: IWorkspaceConfigurationService,
|
||||
@IClipboardService private _clipboardService: IClipboardService,
|
||||
@ICommandService private _commandService: ICommandService
|
||||
) { }
|
||||
/**
|
||||
* Gets the default provider with the following actions
|
||||
* 1. Checks if master provider(map) has data
|
||||
* 2. If so, filters provider paramter against master map
|
||||
* 3. Fetches the result array and extracts the first element
|
||||
* 4. If none of the above data exists, returns 'MSSQL'
|
||||
* @returns: Default provider as string
|
||||
*/
|
||||
private getDefaultProviderName(): string {
|
||||
let defaultProvider: string;
|
||||
if (this._providerNameToDisplayNameMap) {
|
||||
let keys = Object.keys(this._providerNameToDisplayNameMap);
|
||||
let filteredKeys: string[];
|
||||
if (keys && keys.length > 0) {
|
||||
if (this._params && this._params.providers && this._params.providers.length > 0) {
|
||||
//Filter providers from master keys.
|
||||
filteredKeys = keys.filter(key => this._params.providers.includes(key));
|
||||
}
|
||||
if (filteredKeys && filteredKeys.length > 0) {
|
||||
defaultProvider = filteredKeys[0];
|
||||
}
|
||||
else {
|
||||
defaultProvider = keys[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!defaultProvider && this._workspaceConfigurationService) {
|
||||
defaultProvider = WorkbenchUtils.getSqlConfigValue<string>(this._workspaceConfigurationService, Constants.defaultEngine);
|
||||
}
|
||||
// as a fallback, default to MSSQL if the value from settings is not available
|
||||
return defaultProvider || Constants.mssqlProviderName;
|
||||
}
|
||||
|
||||
private handleOnConnect(params: INewConnectionParams, profile?: IConnectionProfile): void {
|
||||
if (!this._connecting) {
|
||||
this._connecting = true;
|
||||
this.handleProviderOnConnecting();
|
||||
if (!profile) {
|
||||
let result = this.uiController.validateConnection();
|
||||
if (!result.isValid) {
|
||||
this._connecting = false;
|
||||
this._connectionDialog.resetConnection();
|
||||
return;
|
||||
}
|
||||
profile = result.connection;
|
||||
|
||||
profile.serverName = trim(profile.serverName);
|
||||
|
||||
// append the port to the server name for SQL Server connections
|
||||
if (this.getCurrentProviderName() === Constants.mssqlProviderName) {
|
||||
let portPropertyName: string = 'port';
|
||||
let portOption: string = profile.options[portPropertyName];
|
||||
if (portOption && portOption.indexOf(',') === -1) {
|
||||
profile.serverName = profile.serverName + ',' + portOption;
|
||||
}
|
||||
profile.options[portPropertyName] = undefined;
|
||||
}
|
||||
|
||||
// Disable password prompt during reconnect if connected with an empty password
|
||||
if (profile.password === '' && profile.savePassword === false) {
|
||||
profile.savePassword = true;
|
||||
}
|
||||
|
||||
this.handleDefaultOnConnect(params, profile);
|
||||
} else {
|
||||
profile.serverName = trim(profile.serverName);
|
||||
this._connectionManagementService.addSavedPassword(profile).then(connectionWithPassword => {
|
||||
this.handleDefaultOnConnect(params, connectionWithPassword);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private handleOnCancel(params: INewConnectionParams): void {
|
||||
if (this.uiController.databaseDropdownExpanded) {
|
||||
this.uiController.closeDatabaseDropdown();
|
||||
} else {
|
||||
if (params && params.input && params.connectionType === ConnectionType.editor) {
|
||||
this._connectionManagementService.cancelEditorConnection(params.input);
|
||||
} else {
|
||||
this._connectionManagementService.cancelConnection(this._model);
|
||||
}
|
||||
if (params && params.input && params.input.onConnectCanceled) {
|
||||
params.input.onConnectCanceled();
|
||||
}
|
||||
this._connectionDialog.resetConnection();
|
||||
this._connecting = false;
|
||||
}
|
||||
this.uiController.databaseDropdownExpanded = false;
|
||||
if (this._dialogDeferredPromise) {
|
||||
this._dialogDeferredPromise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private handleDefaultOnConnect(params: INewConnectionParams, connection: IConnectionProfile): Thenable<void> {
|
||||
let fromEditor = params && params.connectionType === ConnectionType.editor;
|
||||
let uri: string = undefined;
|
||||
if (fromEditor && params && params.input) {
|
||||
uri = params.input.uri;
|
||||
}
|
||||
let options: IConnectionCompletionOptions = {
|
||||
params: params,
|
||||
saveTheConnection: !fromEditor,
|
||||
showDashboard: params && params.showDashboard !== undefined ? params.showDashboard : !fromEditor,
|
||||
showConnectionDialogOnError: false,
|
||||
showFirewallRuleOnError: true
|
||||
};
|
||||
|
||||
return this._connectionManagementService.connectAndSaveProfile(connection, uri, options, params && params.input).then(connectionResult => {
|
||||
this._connecting = false;
|
||||
if (connectionResult && connectionResult.connected) {
|
||||
this._connectionDialog.close();
|
||||
if (this._dialogDeferredPromise) {
|
||||
this._dialogDeferredPromise.resolve(connectionResult.connectionProfile);
|
||||
}
|
||||
} else if (connectionResult && connectionResult.errorHandled) {
|
||||
this._connectionDialog.resetConnection();
|
||||
} else {
|
||||
this._connectionDialog.resetConnection();
|
||||
this.showErrorDialog(Severity.Error, this._connectionErrorTitle, connectionResult.errorMessage, connectionResult.callStack);
|
||||
}
|
||||
}).catch(err => {
|
||||
this._connecting = false;
|
||||
this._connectionDialog.resetConnection();
|
||||
this.showErrorDialog(Severity.Error, this._connectionErrorTitle, err);
|
||||
});
|
||||
}
|
||||
|
||||
private get uiController(): IConnectionComponentController {
|
||||
// Find the provider name from the selected provider type, or throw an error if it does not correspond to a known provider
|
||||
let providerName = this.getCurrentProviderName();
|
||||
if (!providerName) {
|
||||
throw Error('Invalid provider type');
|
||||
}
|
||||
|
||||
// Set the model name, initialize the controller if needed, and return the controller
|
||||
this._model.providerName = providerName;
|
||||
if (!this._connectionControllerMap[providerName]) {
|
||||
this._connectionControllerMap[providerName] = this._instantiationService.createInstance(ConnectionController, this._container, this._connectionManagementService, this._capabilitiesService.getCapabilities(providerName).connection, {
|
||||
onSetConnectButton: (enable: boolean) => this.handleSetConnectButtonEnable(enable)
|
||||
}, providerName);
|
||||
}
|
||||
return this._connectionControllerMap[providerName];
|
||||
}
|
||||
|
||||
private handleSetConnectButtonEnable(enable: boolean): void {
|
||||
this._connectionDialog.connectButtonState = enable;
|
||||
}
|
||||
|
||||
private handleShowUiComponent(input: OnShowUIResponse) {
|
||||
if (input.selectedProviderType) {
|
||||
this._currentProviderType = input.selectedProviderType;
|
||||
}
|
||||
this._model.providerName = this.getCurrentProviderName();
|
||||
|
||||
this._model = new ConnectionProfile(this._capabilitiesService, this._model);
|
||||
this.uiController.showUiComponent(input.container);
|
||||
}
|
||||
|
||||
private handleInitDialog() {
|
||||
this.uiController.initDialog(this._params && this._params.providers, this._model);
|
||||
}
|
||||
|
||||
private handleFillInConnectionInputs(connectionInfo: IConnectionProfile): void {
|
||||
this._connectionManagementService.addSavedPassword(connectionInfo).then(connectionWithPassword => {
|
||||
var model = this.createModel(connectionWithPassword);
|
||||
this._model = model;
|
||||
this.uiController.fillInConnectionInputs(model);
|
||||
});
|
||||
this._connectionDialog.updateProvider(this._providerNameToDisplayNameMap[connectionInfo.providerName]);
|
||||
}
|
||||
|
||||
private handleProviderOnResetConnection(): void {
|
||||
this.uiController.handleResetConnection();
|
||||
}
|
||||
|
||||
private handleProviderOnConnecting(): void {
|
||||
this.uiController.handleOnConnecting();
|
||||
}
|
||||
|
||||
private updateModelServerCapabilities(model: IConnectionProfile) {
|
||||
this._model = this.createModel(model);
|
||||
if (this._model.providerName) {
|
||||
this._currentProviderType = this._providerNameToDisplayNameMap[this._model.providerName];
|
||||
if (this._connectionDialog) {
|
||||
this._connectionDialog.updateProvider(this._currentProviderType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private createModel(model: IConnectionProfile): ConnectionProfile {
|
||||
let defaultProvider = this.getDefaultProviderName();
|
||||
let providerName = model ? model.providerName : defaultProvider;
|
||||
providerName = providerName ? providerName : defaultProvider;
|
||||
let newProfile = new ConnectionProfile(this._capabilitiesService, model || providerName);
|
||||
newProfile.saveProfile = true;
|
||||
newProfile.generateNewId();
|
||||
// If connecting from a query editor set "save connection" to false
|
||||
if (this._params && this._params.input && this._params.connectionType === ConnectionType.editor) {
|
||||
newProfile.saveProfile = false;
|
||||
}
|
||||
return newProfile;
|
||||
}
|
||||
|
||||
private showDialogWithModel(): TPromise<void> {
|
||||
return new TPromise<void>((resolve, reject) => {
|
||||
this.updateModelServerCapabilities(this._inputModel);
|
||||
this.doShowDialog(this._params);
|
||||
resolve(null);
|
||||
});
|
||||
}
|
||||
|
||||
public openDialogAndWait(
|
||||
connectionManagementService: IConnectionManagementService,
|
||||
params?: INewConnectionParams,
|
||||
model?: IConnectionProfile,
|
||||
connectionResult?: IConnectionResult): Thenable<IConnectionProfile> {
|
||||
this._dialogDeferredPromise = new Deferred<IConnectionProfile>();
|
||||
|
||||
this.showDialog(connectionManagementService, params,
|
||||
model,
|
||||
connectionResult).then(() => {
|
||||
}, error => {
|
||||
this._dialogDeferredPromise.reject(error);
|
||||
});
|
||||
return this._dialogDeferredPromise;
|
||||
}
|
||||
|
||||
public showDialog(
|
||||
connectionManagementService: IConnectionManagementService,
|
||||
params?: INewConnectionParams,
|
||||
model?: IConnectionProfile,
|
||||
connectionResult?: IConnectionResult): Thenable<void> {
|
||||
this._connectionManagementService = connectionManagementService;
|
||||
|
||||
this._params = params;
|
||||
this._inputModel = model;
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
// only create the provider maps first time the dialog gets called
|
||||
if (this._providerTypes.length === 0) {
|
||||
entries(this._capabilitiesService.providers).forEach(p => {
|
||||
this._providerTypes.push(p[1].connection.displayName);
|
||||
this._providerNameToDisplayNameMap[p[0]] = p[1].connection.displayName;
|
||||
});
|
||||
}
|
||||
this.updateModelServerCapabilities(model);
|
||||
// If connecting from a query editor set "save connection" to false
|
||||
if (params && params.input && params.connectionType === ConnectionType.editor) {
|
||||
this._model.saveProfile = false;
|
||||
}
|
||||
|
||||
resolve(this.showDialogWithModel().then(() => {
|
||||
if (connectionResult && connectionResult.errorMessage) {
|
||||
this.showErrorDialog(Severity.Error, this._connectionErrorTitle, connectionResult.errorMessage, connectionResult.callStack);
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private doShowDialog(params: INewConnectionParams): TPromise<void> {
|
||||
if (!this._connectionDialog) {
|
||||
let container = document.getElementById(this._partService.getWorkbenchElementId()).parentElement;
|
||||
this._container = container;
|
||||
this._connectionDialog = this._instantiationService.createInstance(ConnectionDialogWidget, this._providerTypes, this._providerNameToDisplayNameMap[this._model.providerName], this._providerNameToDisplayNameMap);
|
||||
this._connectionDialog.onCancel(() => {
|
||||
this._connectionDialog.databaseDropdownExpanded = this.uiController.databaseDropdownExpanded;
|
||||
this.handleOnCancel(this._connectionDialog.newConnectionParams);
|
||||
});
|
||||
this._connectionDialog.onConnect((profile) => this.handleOnConnect(this._connectionDialog.newConnectionParams, profile));
|
||||
this._connectionDialog.onShowUiComponent((input) => this.handleShowUiComponent(input));
|
||||
this._connectionDialog.onInitDialog(() => this.handleInitDialog());
|
||||
this._connectionDialog.onFillinConnectionInputs((input) => this.handleFillInConnectionInputs(input));
|
||||
this._connectionDialog.onResetConnection(() => this.handleProviderOnResetConnection());
|
||||
this._connectionDialog.render();
|
||||
}
|
||||
this._connectionDialog.newConnectionParams = params;
|
||||
|
||||
return new TPromise<void>(() => {
|
||||
this._connectionDialog.open(this._connectionManagementService.getRecentConnections(params.providers).length > 0);
|
||||
this.uiController.focusOnOpen();
|
||||
});
|
||||
}
|
||||
|
||||
private getCurrentProviderName(): string {
|
||||
return Object.keys(this._providerNameToDisplayNameMap).find(providerName => {
|
||||
return this._currentProviderType === this._providerNameToDisplayNameMap[providerName];
|
||||
});
|
||||
}
|
||||
|
||||
private showErrorDialog(severity: Severity, headerTitle: string, message: string, messageDetails?: string): void {
|
||||
// Kerberos errors are currently very hard to understand, so adding handling of these to solve the common scenario
|
||||
// note that ideally we would have an extensible service to handle errors by error code and provider, but for now
|
||||
// this solves the most common "hard error" that we've noticed
|
||||
const helpLink = 'https://aka.ms/sqlopskerberos';
|
||||
let actions: IAction[] = [];
|
||||
if (!platform.isWindows && types.isString(message) && message.toLowerCase().includes('kerberos') && message.toLowerCase().includes('kinit')) {
|
||||
message = [
|
||||
localize('kerberosErrorStart', "Connection failed due to Kerberos error."),
|
||||
localize('kerberosHelpLink', "Help configuring Kerberos is available at {0}", helpLink),
|
||||
localize('kerberosKinit', "If you have previously connected you may need to re-run kinit.")
|
||||
].join('\r\n');
|
||||
actions.push(new Action('Kinit', 'Run kinit', null, true, () => {
|
||||
this._connectionDialog.close();
|
||||
this._clipboardService.writeText('kinit\r');
|
||||
this._commandService.executeCommand('workbench.action.terminal.focus').then(resolve => {
|
||||
// setTimeout to allow for terminal Instance to load.
|
||||
setTimeout(() => {
|
||||
return this._commandService.executeCommand('workbench.action.terminal.paste');
|
||||
}, 10);
|
||||
}).then(resolve => null, reject => null);
|
||||
return null;
|
||||
}));
|
||||
|
||||
}
|
||||
this._errorMessageService.showDialog(severity, headerTitle, message, messageDetails, actions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,459 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import 'vs/css!./media/connectionDialog';
|
||||
|
||||
import { Button } from 'sql/base/browser/ui/button/button';
|
||||
import { attachModalDialogStyler, attachButtonStyler } from 'sql/platform/theme/common/styler';
|
||||
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { Modal } from 'sql/workbench/browser/modal/modal';
|
||||
import { IConnectionManagementService, INewConnectionParams } from 'sql/platform/connection/common/connectionManagement';
|
||||
import * as DialogHelper from 'sql/workbench/browser/modal/dialogHelper';
|
||||
import { TreeCreationUtils } from 'sql/parts/objectExplorer/viewlet/treeCreationUtils';
|
||||
import { TreeUpdateUtils } from 'sql/parts/objectExplorer/viewlet/treeUpdateUtils';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { TabbedPanel, PanelTabIdentifier } from 'sql/base/browser/ui/panel/panel';
|
||||
import { RecentConnectionTreeController, RecentConnectionActionsProvider } from 'sql/parts/connection/connectionDialog/recentConnectionTreeController';
|
||||
import { SavedConnectionTreeController } from 'sql/parts/connection/connectionDialog/savedConnectionTreeController';
|
||||
import * as TelemetryKeys from 'sql/common/telemetryKeys';
|
||||
import { ClearRecentConnectionsAction } from 'sql/parts/connection/common/connectionActions';
|
||||
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IWorkbenchThemeService, IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { IPartService } from 'vs/workbench/services/part/common/partService';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Builder, $ } from 'vs/base/browser/builder';
|
||||
import { ICancelableEvent } from 'vs/base/parts/tree/browser/treeDefaults';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import * as styler from 'vs/platform/theme/common/styler';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
|
||||
|
||||
export interface OnShowUIResponse {
|
||||
selectedProviderType: string;
|
||||
container: HTMLElement;
|
||||
}
|
||||
|
||||
export class ConnectionDialogWidget extends Modal {
|
||||
private _bodyBuilder: Builder;
|
||||
private _recentConnectionBuilder: Builder;
|
||||
private _noRecentConnectionBuilder: Builder;
|
||||
private _savedConnectionBuilder: Builder;
|
||||
private _noSavedConnectionBuilder: Builder;
|
||||
private _connectionDetailTitle: Builder;
|
||||
private _connectButton: Button;
|
||||
private _closeButton: Button;
|
||||
private _providerTypeSelectBox: SelectBox;
|
||||
private _newConnectionParams: INewConnectionParams;
|
||||
private _recentConnectionTree: ITree;
|
||||
private _savedConnectionTree: ITree;
|
||||
private $connectionUIContainer: Builder;
|
||||
private _databaseDropdownExpanded: boolean;
|
||||
private _actionbar: ActionBar;
|
||||
private _providers: string[];
|
||||
|
||||
private _panel: TabbedPanel;
|
||||
private _recentConnectionTabId: PanelTabIdentifier;
|
||||
|
||||
private _onInitDialog = new Emitter<void>();
|
||||
public onInitDialog: Event<void> = this._onInitDialog.event;
|
||||
|
||||
private _onCancel = new Emitter<void>();
|
||||
public onCancel: Event<void> = this._onCancel.event;
|
||||
|
||||
private _onConnect = new Emitter<IConnectionProfile>();
|
||||
public onConnect: Event<IConnectionProfile> = this._onConnect.event;
|
||||
|
||||
private _onShowUiComponent = new Emitter<OnShowUIResponse>();
|
||||
public onShowUiComponent: Event<OnShowUIResponse> = this._onShowUiComponent.event;
|
||||
|
||||
private _onFillinConnectionInputs = new Emitter<IConnectionProfile>();
|
||||
public onFillinConnectionInputs: Event<IConnectionProfile> = this._onFillinConnectionInputs.event;
|
||||
|
||||
private _onResetConnection = new Emitter<void>();
|
||||
public onResetConnection: Event<void> = this._onResetConnection.event;
|
||||
|
||||
private _connecting = false;
|
||||
|
||||
constructor(
|
||||
private providerTypeOptions: string[],
|
||||
private selectedProviderType: string,
|
||||
private providerNameToDisplayNameMap: { [providerDisplayName: string]: string },
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||
@IWorkbenchThemeService private _workbenchThemeService: IWorkbenchThemeService,
|
||||
@IPartService _partService: IPartService,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IContextMenuService private _contextMenuService: IContextMenuService,
|
||||
@IContextViewService private _contextViewService: IContextViewService,
|
||||
@IClipboardService clipboardService: IClipboardService
|
||||
) {
|
||||
super(localize('connection', 'Connection'), TelemetryKeys.Connection, _partService, telemetryService, clipboardService, _workbenchThemeService, contextKeyService, { hasSpinner: true, hasErrors: true });
|
||||
}
|
||||
|
||||
public refresh(): void {
|
||||
let filteredProviderTypes = this.providerTypeOptions;
|
||||
|
||||
if (this._newConnectionParams && this._newConnectionParams.providers) {
|
||||
let validProviderNames = Object.keys(this.providerNameToDisplayNameMap).filter(x => this.includeProvider(x, this._newConnectionParams));
|
||||
if (validProviderNames && validProviderNames.length > 0) {
|
||||
filteredProviderTypes = filteredProviderTypes.filter(x => validProviderNames.find(v => this.providerNameToDisplayNameMap[v] === x) !== undefined);
|
||||
}
|
||||
}
|
||||
this._providerTypeSelectBox.setOptions(filteredProviderTypes);
|
||||
}
|
||||
|
||||
private includeProvider(providerName: string, params?: INewConnectionParams): Boolean {
|
||||
return params === undefined || params.providers === undefined || params.providers.find(x => x === providerName) !== undefined;
|
||||
}
|
||||
|
||||
protected renderBody(container: HTMLElement): void {
|
||||
let connectionContainer = $('.connection-dialog');
|
||||
container.appendChild(connectionContainer.getHTMLElement());
|
||||
|
||||
this._bodyBuilder = new Builder(connectionContainer.getHTMLElement());
|
||||
const connectTypeLabel = localize('connectType', 'Connection type');
|
||||
this._providerTypeSelectBox = new SelectBox(this.providerTypeOptions, this.selectedProviderType, this._contextViewService, undefined, { ariaLabel: connectTypeLabel });
|
||||
// Recent connection tab
|
||||
let recentConnectionTab = $('.connection-recent-tab');
|
||||
recentConnectionTab.div({ class: 'connection-recent', id: 'recentConnection' }, (builder) => {
|
||||
this._recentConnectionBuilder = new Builder(builder.getHTMLElement());
|
||||
this._noRecentConnectionBuilder = new Builder(builder.getHTMLElement());
|
||||
this.createRecentConnections();
|
||||
this._recentConnectionBuilder.hide();
|
||||
});
|
||||
|
||||
// Saved connection tab
|
||||
let savedConnectionTab = $('.connection-saved-tab');
|
||||
savedConnectionTab.div({ class: 'connection-saved' }, (builder) => {
|
||||
this._savedConnectionBuilder = new Builder(builder.getHTMLElement());
|
||||
this._noSavedConnectionBuilder = new Builder(builder.getHTMLElement());
|
||||
this.createSavedConnections();
|
||||
this._savedConnectionBuilder.hide();
|
||||
});
|
||||
|
||||
this._panel = new TabbedPanel(connectionContainer.getHTMLElement());
|
||||
this._recentConnectionTabId = this._panel.pushTab({
|
||||
identifier: 'recent_connection',
|
||||
title: localize('recentConnectionTitle', 'Recent Connections'),
|
||||
view: {
|
||||
render: c => {
|
||||
recentConnectionTab.appendTo(c);
|
||||
},
|
||||
layout: () => { }
|
||||
}
|
||||
});
|
||||
|
||||
let savedConnectionTabId = this._panel.pushTab({
|
||||
identifier: 'saved_connection',
|
||||
title: localize('savedConnectionTitle', 'Saved Connections'),
|
||||
view: {
|
||||
layout: () => { },
|
||||
render: c => {
|
||||
savedConnectionTab.appendTo(c);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this._panel.onTabChange(c => {
|
||||
if (c === savedConnectionTabId && this._savedConnectionTree.getContentHeight() === 0) {
|
||||
// Update saved connection tree
|
||||
TreeUpdateUtils.structuralTreeUpdate(this._savedConnectionTree, 'saved', this._connectionManagementService, this._providers);
|
||||
|
||||
if (this._savedConnectionTree.getContentHeight() > 0) {
|
||||
this._noSavedConnectionBuilder.hide();
|
||||
this._savedConnectionBuilder.show();
|
||||
} else {
|
||||
this._noSavedConnectionBuilder.show();
|
||||
this._savedConnectionBuilder.hide();
|
||||
}
|
||||
this._savedConnectionTree.layout(DOM.getTotalHeight(this._savedConnectionTree.getHTMLElement()));
|
||||
}
|
||||
});
|
||||
|
||||
this._bodyBuilder.div({ class: 'connection-details-title' }, (dividerContainer) => {
|
||||
this._connectionDetailTitle = dividerContainer;
|
||||
this._connectionDetailTitle.text(localize('connectionDetailsTitle', 'Connection Details'));
|
||||
});
|
||||
|
||||
this._bodyBuilder.div({ class: 'connection-type' }, (modelTableContent) => {
|
||||
modelTableContent.element('table', { class: 'connection-table-content' }, (tableContainer) => {
|
||||
DialogHelper.appendInputSelectBox(
|
||||
DialogHelper.appendRow(tableContainer, connectTypeLabel, 'connection-label', 'connection-input'), this._providerTypeSelectBox);
|
||||
});
|
||||
});
|
||||
|
||||
this.$connectionUIContainer = $('.connection-provider-info#connectionProviderInfo');
|
||||
this.$connectionUIContainer.appendTo(this._bodyBuilder);
|
||||
|
||||
let self = this;
|
||||
this._register(self._workbenchThemeService.onDidColorThemeChange(e => self.updateTheme(e)));
|
||||
self.updateTheme(self._workbenchThemeService.getColorTheme());
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the connection flyout
|
||||
*/
|
||||
public render() {
|
||||
super.render();
|
||||
attachModalDialogStyler(this, this._themeService);
|
||||
let connectLabel = localize('connectionDialog.connect', 'Connect');
|
||||
let cancelLabel = localize('connectionDialog.cancel', 'Cancel');
|
||||
this._connectButton = this.addFooterButton(connectLabel, () => this.connect());
|
||||
this._connectButton.enabled = false;
|
||||
this._closeButton = this.addFooterButton(cancelLabel, () => this.cancel());
|
||||
this.registerListeners();
|
||||
this.onProviderTypeSelected(this._providerTypeSelectBox.value);
|
||||
}
|
||||
|
||||
// Update theming that is specific to connection flyout body
|
||||
private updateTheme(theme: IColorTheme): void {
|
||||
let borderColor = theme.getColor(contrastBorder);
|
||||
let border = borderColor ? borderColor.toString() : null;
|
||||
let backgroundColor = theme.getColor(SIDE_BAR_BACKGROUND);
|
||||
if (this._connectionDetailTitle) {
|
||||
this._connectionDetailTitle.style('border-width', border ? '1px 0px' : null);
|
||||
this._connectionDetailTitle.style('border-style', border ? 'solid none' : null);
|
||||
this._connectionDetailTitle.style('border-color', border);
|
||||
this._connectionDetailTitle.style('background-color', backgroundColor ? backgroundColor.toString() : null);
|
||||
}
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
// Theme styler
|
||||
this._register(styler.attachSelectBoxStyler(this._providerTypeSelectBox, this._themeService));
|
||||
this._register(attachButtonStyler(this._connectButton, this._themeService));
|
||||
this._register(attachButtonStyler(this._closeButton, this._themeService));
|
||||
|
||||
this._register(this._providerTypeSelectBox.onDidSelect(selectedProviderType => {
|
||||
this.onProviderTypeSelected(selectedProviderType.selected);
|
||||
}));
|
||||
}
|
||||
|
||||
private onProviderTypeSelected(selectedProviderType: string) {
|
||||
// Show connection form based on server type
|
||||
this.$connectionUIContainer.empty();
|
||||
this._onShowUiComponent.fire({ selectedProviderType: selectedProviderType, container: this.$connectionUIContainer.getHTMLElement() });
|
||||
this.initDialog();
|
||||
}
|
||||
|
||||
private connect(element?: IConnectionProfile): void {
|
||||
if (this._connectButton.enabled) {
|
||||
this._connecting = true;
|
||||
this._connectButton.enabled = false;
|
||||
this._providerTypeSelectBox.disable();
|
||||
this.showSpinner();
|
||||
this._onConnect.fire(element);
|
||||
}
|
||||
}
|
||||
|
||||
/* Overwrite espace key behavior */
|
||||
protected onClose(e: StandardKeyboardEvent) {
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
/* Overwrite enter key behavior */
|
||||
protected onAccept(e: StandardKeyboardEvent) {
|
||||
if (!e.target.classList.contains('monaco-tree')) {
|
||||
this.connect();
|
||||
}
|
||||
}
|
||||
|
||||
private cancel() {
|
||||
let wasConnecting = this._connecting;
|
||||
this._onCancel.fire();
|
||||
if (!this._databaseDropdownExpanded && !wasConnecting) {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
public close() {
|
||||
this.resetConnection();
|
||||
this.hide();
|
||||
}
|
||||
|
||||
private createRecentConnectionList(): void {
|
||||
this._recentConnectionBuilder.div({ class: 'connection-recent-content' }, (recentConnectionContainer) => {
|
||||
recentConnectionContainer.div({ class: 'recent-titles-container' }, (container) => {
|
||||
container.div({ class: 'connection-history-actions' }, (actionsContainer) => {
|
||||
this._actionbar = this._register(new ActionBar(actionsContainer.getHTMLElement(), { animated: false }));
|
||||
let clearAction = this._instantiationService.createInstance(ClearRecentConnectionsAction, ClearRecentConnectionsAction.ID, ClearRecentConnectionsAction.LABEL);
|
||||
clearAction.useConfirmationMessage = true;
|
||||
clearAction.onRecentConnectionsRemoved(() => this.open(false));
|
||||
this._actionbar.push(clearAction, { icon: true, label: true });
|
||||
});
|
||||
});
|
||||
recentConnectionContainer.div({ class: 'server-explorer-viewlet' }, (divContainer: Builder) => {
|
||||
divContainer.div({ class: 'explorer-servers' }, (treeContainer: Builder) => {
|
||||
let leftClick = (element: any, eventish: ICancelableEvent, origin: string) => {
|
||||
// element will be a server group if the tree is clicked rather than a item
|
||||
if (element instanceof ConnectionProfile) {
|
||||
this.onConnectionClick({ payload: { origin: origin, originalEvent: eventish } }, element);
|
||||
}
|
||||
};
|
||||
let actionProvider = this._instantiationService.createInstance(RecentConnectionActionsProvider);
|
||||
let controller = new RecentConnectionTreeController(leftClick, actionProvider, this._connectionManagementService, this._contextMenuService);
|
||||
actionProvider.onRecentConnectionRemoved(() => {
|
||||
this.open(this._connectionManagementService.getRecentConnections().length > 0);
|
||||
});
|
||||
controller.onRecentConnectionRemoved(() => {
|
||||
this.open(this._connectionManagementService.getRecentConnections().length > 0);
|
||||
});
|
||||
this._recentConnectionTree = TreeCreationUtils.createConnectionTree(treeContainer.getHTMLElement(), this._instantiationService, controller);
|
||||
|
||||
// Theme styler
|
||||
this._register(styler.attachListStyler(this._recentConnectionTree, this._themeService));
|
||||
divContainer.append(this._recentConnectionTree.getHTMLElement());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private createRecentConnections() {
|
||||
this.createRecentConnectionList();
|
||||
this._noRecentConnectionBuilder.div({ class: 'connection-recent-content' }, (noRecentConnectionContainer) => {
|
||||
let noRecentHistoryLabel = localize('noRecentConnections', 'No recent connection');
|
||||
noRecentConnectionContainer.div({ class: 'no-recent-connections' }, (noRecentTitle) => {
|
||||
noRecentTitle.text(noRecentHistoryLabel);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private createSavedConnectionList(): void {
|
||||
this._savedConnectionBuilder.div({ class: 'connection-saved-content' }, (savedConnectioncontainer) => {
|
||||
savedConnectioncontainer.div({ class: 'server-explorer-viewlet' }, (divContainer: Builder) => {
|
||||
divContainer.div({ class: 'explorer-servers' }, (treeContainer: Builder) => {
|
||||
let leftClick = (element: any, eventish: ICancelableEvent, origin: string) => {
|
||||
// element will be a server group if the tree is clicked rather than a item
|
||||
if (element instanceof ConnectionProfile) {
|
||||
this.onConnectionClick({ payload: { origin: origin, originalEvent: eventish } }, element);
|
||||
}
|
||||
};
|
||||
|
||||
let controller = new SavedConnectionTreeController(leftClick);
|
||||
this._savedConnectionTree = TreeCreationUtils.createConnectionTree(treeContainer.getHTMLElement(), this._instantiationService, controller);
|
||||
|
||||
// Theme styler
|
||||
this._register(styler.attachListStyler(this._savedConnectionTree, this._themeService));
|
||||
divContainer.append(this._savedConnectionTree.getHTMLElement());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private createSavedConnections() {
|
||||
this.createSavedConnectionList();
|
||||
this._noSavedConnectionBuilder.div({ class: 'connection-saved-content' }, (noSavedConnectionContainer) => {
|
||||
let noSavedConnectionLabel = localize('noSavedConnections', 'No saved connection');
|
||||
noSavedConnectionContainer.div({ class: 'no-saved-connections' }, (titleContainer) => {
|
||||
titleContainer.text(noSavedConnectionLabel);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private onConnectionClick(event: any, element: IConnectionProfile) {
|
||||
let isMouseOrigin = event.payload && (event.payload.origin === 'mouse');
|
||||
let isDoubleClick = isMouseOrigin && event.payload.originalEvent && event.payload.originalEvent.detail === 2;
|
||||
if (isDoubleClick) {
|
||||
this.connect(element);
|
||||
} else {
|
||||
if (element) {
|
||||
this._onFillinConnectionInputs.fire(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the flyout dialog
|
||||
* @param recentConnections Are there recent connections that should be shown
|
||||
*/
|
||||
public open(recentConnections: boolean) {
|
||||
this._panel.showTab(this._recentConnectionTabId);
|
||||
|
||||
this.show();
|
||||
if (recentConnections) {
|
||||
this._noRecentConnectionBuilder.hide();
|
||||
this._recentConnectionBuilder.show();
|
||||
} else {
|
||||
this._recentConnectionBuilder.hide();
|
||||
this._noRecentConnectionBuilder.show();
|
||||
}
|
||||
TreeUpdateUtils.structuralTreeUpdate(this._recentConnectionTree, 'recent', this._connectionManagementService, this._providers);
|
||||
|
||||
// reset saved connection tree
|
||||
this._savedConnectionTree.setInput([]);
|
||||
|
||||
// call layout with view height
|
||||
this.layout();
|
||||
this.initDialog();
|
||||
}
|
||||
|
||||
protected layout(height?: number): void {
|
||||
// Height is the overall height. Since we're laying out a specific component, always get its actual height
|
||||
this._recentConnectionTree.layout(DOM.getTotalHeight(this._recentConnectionTree.getHTMLElement()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the state of the connect button
|
||||
* @param enabled The state to set the the button
|
||||
*/
|
||||
public set connectButtonState(enabled: boolean) {
|
||||
this._connectButton.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the connect button state
|
||||
*/
|
||||
public get connectButtonState(): boolean {
|
||||
return this._connectButton.enabled;
|
||||
}
|
||||
|
||||
private initDialog(): void {
|
||||
super.setError('');
|
||||
this.hideSpinner();
|
||||
this._onInitDialog.fire();
|
||||
}
|
||||
|
||||
public resetConnection(): void {
|
||||
this.hideSpinner();
|
||||
this._connectButton.enabled = true;
|
||||
this._providerTypeSelectBox.enable();
|
||||
this._onResetConnection.fire();
|
||||
this._connecting = false;
|
||||
}
|
||||
|
||||
public get newConnectionParams(): INewConnectionParams {
|
||||
return this._newConnectionParams;
|
||||
}
|
||||
|
||||
public set newConnectionParams(params: INewConnectionParams) {
|
||||
this._newConnectionParams = params;
|
||||
this._providers = params && params.providers;
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
public updateProvider(displayName: string) {
|
||||
this._providerTypeSelectBox.selectWithOptionName(displayName);
|
||||
|
||||
this.onProviderTypeSelected(displayName);
|
||||
}
|
||||
|
||||
public set databaseDropdownExpanded(val: boolean) {
|
||||
this._databaseDropdownExpanded = val;
|
||||
}
|
||||
|
||||
public get databaseDropdownExpanded(): boolean {
|
||||
return this._databaseDropdownExpanded;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,835 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./media/sqlConnection';
|
||||
|
||||
import { Button } from 'sql/base/browser/ui/button/button';
|
||||
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
||||
import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox';
|
||||
import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox';
|
||||
import * as DialogHelper from 'sql/workbench/browser/modal/dialogHelper';
|
||||
import { IConnectionComponentCallbacks } from 'sql/workbench/services/connection/browser/connectionDialogService';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { Dropdown } from 'sql/base/browser/ui/editableDropdown/dropdown';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import * as styler from 'sql/platform/theme/common/styler';
|
||||
import { IAccountManagementService } from 'sql/platform/accountManagement/common/interfaces';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
|
||||
import * as lifecycle from 'vs/base/common/lifecycle';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { localize } from 'vs/nls';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { OS, OperatingSystem } from 'vs/base/common/platform';
|
||||
import { Builder, $ } from 'vs/base/browser/builder';
|
||||
import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import { endsWith, startsWith } from 'vs/base/common/strings';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
export class ConnectionWidget {
|
||||
private _builder: Builder;
|
||||
private _serverGroupSelectBox: SelectBox;
|
||||
private _previousGroupOption: string;
|
||||
private _serverGroupOptions: IConnectionProfileGroup[];
|
||||
private _connectionNameInputBox: InputBox;
|
||||
private _serverNameInputBox: InputBox;
|
||||
private _databaseNameInputBox: Dropdown;
|
||||
private _userNameInputBox: InputBox;
|
||||
private _passwordInputBox: InputBox;
|
||||
private _password: string;
|
||||
private _rememberPasswordCheckBox: Checkbox;
|
||||
private _azureAccountDropdown: SelectBox;
|
||||
private _azureTenantDropdown: SelectBox;
|
||||
private _refreshCredentialsLinkBuilder: Builder;
|
||||
private _addAzureAccountMessage: string = localize('connectionWidget.AddAzureAccount', 'Add an account...');
|
||||
private readonly _azureProviderId = 'azurePublicCloud';
|
||||
private _azureTenantId: string;
|
||||
private _azureAccountList: sqlops.Account[];
|
||||
private _advancedButton: Button;
|
||||
private _callbacks: IConnectionComponentCallbacks;
|
||||
private _authTypeSelectBox: SelectBox;
|
||||
private _toDispose: lifecycle.IDisposable[];
|
||||
private _optionsMaps: { [optionType: number]: sqlops.ConnectionOption };
|
||||
private _tableContainer: Builder;
|
||||
private _focusedBeforeHandleOnConnection: HTMLElement;
|
||||
private _providerName: string;
|
||||
private _authTypeMap: { [providerName: string]: AuthenticationType[] } = {
|
||||
[Constants.mssqlProviderName]: [AuthenticationType.SqlLogin, AuthenticationType.Integrated, AuthenticationType.AzureMFA]
|
||||
};
|
||||
private _saveProfile: boolean;
|
||||
private _databaseDropdownExpanded: boolean = false;
|
||||
private _defaultDatabaseName: string = localize('defaultDatabaseOption', '<Default>');
|
||||
private _loadingDatabaseName: string = localize('loadingDatabaseOption', 'Loading...');
|
||||
private _serverGroupDisplayString: string = localize('serverGroup', 'Server group');
|
||||
public DefaultServerGroup: IConnectionProfileGroup = {
|
||||
id: '',
|
||||
name: localize('defaultServerGroup', '<Default>'),
|
||||
parentId: undefined,
|
||||
color: undefined,
|
||||
description: undefined,
|
||||
};
|
||||
|
||||
private _addNewServerGroup = {
|
||||
id: '',
|
||||
name: localize('addNewServerGroup', 'Add new group...'),
|
||||
parentId: undefined,
|
||||
color: undefined,
|
||||
description: undefined,
|
||||
};
|
||||
public NoneServerGroup: IConnectionProfileGroup = {
|
||||
id: '',
|
||||
name: localize('noneServerGroup', '<Do not save>'),
|
||||
parentId: undefined,
|
||||
color: undefined,
|
||||
description: undefined,
|
||||
};
|
||||
constructor(options: sqlops.ConnectionOption[],
|
||||
callbacks: IConnectionComponentCallbacks,
|
||||
providerName: string,
|
||||
@IThemeService private _themeService: IThemeService,
|
||||
@IContextViewService private _contextViewService: IContextViewService,
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
||||
@IClipboardService private _clipboardService: IClipboardService,
|
||||
@IConfigurationService private _configurationService: IConfigurationService,
|
||||
@IAccountManagementService private _accountManagementService: IAccountManagementService
|
||||
) {
|
||||
this._callbacks = callbacks;
|
||||
this._toDispose = [];
|
||||
this._optionsMaps = {};
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
var option = options[i];
|
||||
this._optionsMaps[option.specialValueType] = option;
|
||||
}
|
||||
|
||||
var authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType];
|
||||
if (authTypeOption) {
|
||||
if (OS === OperatingSystem.Windows) {
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.Integrated);
|
||||
} else {
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.SqlLogin);
|
||||
}
|
||||
this._authTypeSelectBox = new SelectBox(authTypeOption.categoryValues.map(c => c.displayName), authTypeOption.defaultValue, this._contextViewService, undefined, { ariaLabel: authTypeOption.displayName });
|
||||
}
|
||||
this._providerName = providerName;
|
||||
}
|
||||
|
||||
public createConnectionWidget(container: HTMLElement): void {
|
||||
this._serverGroupOptions = [this.DefaultServerGroup];
|
||||
this._serverGroupSelectBox = new SelectBox(this._serverGroupOptions.map(g => g.name), this.DefaultServerGroup.name, this._contextViewService, undefined, { ariaLabel: this._serverGroupDisplayString });
|
||||
this._previousGroupOption = this._serverGroupSelectBox.value;
|
||||
this._builder = $().div({ class: 'connection-table' }, (modelTableContent) => {
|
||||
modelTableContent.element('table', { class: 'connection-table-content' }, (tableContainer) => {
|
||||
this._tableContainer = tableContainer;
|
||||
});
|
||||
});
|
||||
this.fillInConnectionForm();
|
||||
this.registerListeners();
|
||||
if (this._authTypeSelectBox) {
|
||||
this.onAuthTypeSelected(this._authTypeSelectBox.value);
|
||||
}
|
||||
|
||||
DOM.addDisposableListener(container, 'paste', e => {
|
||||
this._handleClipboard();
|
||||
});
|
||||
|
||||
DOM.append(container, this._builder.getHTMLElement());
|
||||
}
|
||||
|
||||
private _handleClipboard(): void {
|
||||
if (this._configurationService.getValue<boolean>('connection.parseClipboardForConnectionString')) {
|
||||
let paste = this._clipboardService.readText();
|
||||
this._connectionManagementService.buildConnectionInfo(paste, this._providerName).then(e => {
|
||||
if (e) {
|
||||
let profile = new ConnectionProfile(this._capabilitiesService, this._providerName);
|
||||
profile.options = e.options;
|
||||
if (profile.serverName) {
|
||||
this.initDialog(profile);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private fillInConnectionForm(): void {
|
||||
// Server name
|
||||
let serverNameOption = this._optionsMaps[ConnectionOptionSpecialType.serverName];
|
||||
let serverNameBuilder = DialogHelper.appendRow(this._tableContainer, serverNameOption.displayName, 'connection-label', 'connection-input');
|
||||
this._serverNameInputBox = new InputBox(serverNameBuilder.getHTMLElement(), this._contextViewService, {
|
||||
validationOptions: {
|
||||
validation: (value: string) => {
|
||||
if (!value) {
|
||||
return ({ type: MessageType.ERROR, content: localize('connectionWidget.missingRequireField', '{0} is required.', serverNameOption.displayName) });
|
||||
} else if (startsWith(value, ' ') || endsWith(value, ' ')) {
|
||||
return ({ type: MessageType.WARNING, content: localize('connectionWidget.fieldWillBeTrimmed', '{0} will be trimmed.', serverNameOption.displayName) });
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
ariaLabel: serverNameOption.displayName
|
||||
});
|
||||
|
||||
// Authentication type
|
||||
if (this._optionsMaps[ConnectionOptionSpecialType.authType]) {
|
||||
let authTypeBuilder = DialogHelper.appendRow(this._tableContainer, this._optionsMaps[ConnectionOptionSpecialType.authType].displayName, 'connection-label', 'connection-input');
|
||||
DialogHelper.appendInputSelectBox(authTypeBuilder, this._authTypeSelectBox);
|
||||
}
|
||||
|
||||
// Username
|
||||
let self = this;
|
||||
let userNameOption = this._optionsMaps[ConnectionOptionSpecialType.userName];
|
||||
let userNameBuilder = DialogHelper.appendRow(this._tableContainer, userNameOption.displayName, 'connection-label', 'connection-input', 'username-password-row');
|
||||
this._userNameInputBox = new InputBox(userNameBuilder.getHTMLElement(), this._contextViewService, {
|
||||
validationOptions: {
|
||||
validation: (value: string) => self.validateUsername(value, userNameOption.isRequired) ? ({ type: MessageType.ERROR, content: localize('connectionWidget.missingRequireField', '{0} is required.', userNameOption.displayName) }) : null
|
||||
},
|
||||
ariaLabel: userNameOption.displayName
|
||||
});
|
||||
// Password
|
||||
let passwordOption = this._optionsMaps[ConnectionOptionSpecialType.password];
|
||||
let passwordBuilder = DialogHelper.appendRow(this._tableContainer, passwordOption.displayName, 'connection-label', 'connection-input', 'username-password-row');
|
||||
this._passwordInputBox = new InputBox(passwordBuilder.getHTMLElement(), this._contextViewService, { ariaLabel: passwordOption.displayName });
|
||||
this._passwordInputBox.inputElement.type = 'password';
|
||||
this._password = '';
|
||||
|
||||
// Remember password
|
||||
let rememberPasswordLabel = localize('rememberPassword', 'Remember password');
|
||||
this._rememberPasswordCheckBox = this.appendCheckbox(this._tableContainer, rememberPasswordLabel, 'connection-checkbox', 'connection-input', 'username-password-row', false);
|
||||
|
||||
// Azure account picker
|
||||
let accountLabel = localize('connection.azureAccountDropdownLabel', 'Account');
|
||||
let accountDropdownBuilder = DialogHelper.appendRow(this._tableContainer, accountLabel, 'connection-label', 'connection-input', 'azure-account-row');
|
||||
this._azureAccountDropdown = new SelectBox([], undefined, this._contextViewService, accountDropdownBuilder.getContainer(), { ariaLabel: accountLabel });
|
||||
DialogHelper.appendInputSelectBox(accountDropdownBuilder, this._azureAccountDropdown);
|
||||
let refreshCredentialsBuilder = DialogHelper.appendRow(this._tableContainer, '', 'connection-label', 'connection-input', 'azure-account-row refresh-credentials-link');
|
||||
this._refreshCredentialsLinkBuilder = refreshCredentialsBuilder.a({ href: '#' }).text(localize('connectionWidget.refreshAzureCredentials', 'Refresh account credentials'));
|
||||
|
||||
// Azure tenant picker
|
||||
let tenantLabel = localize('connection.azureTenantDropdownLabel', 'Azure AD tenant');
|
||||
let tenantDropdownBuilder = DialogHelper.appendRow(this._tableContainer, tenantLabel, 'connection-label', 'connection-input', 'azure-account-row azure-tenant-row');
|
||||
this._azureTenantDropdown = new SelectBox([], undefined, this._contextViewService, tenantDropdownBuilder.getContainer(), { ariaLabel: tenantLabel });
|
||||
DialogHelper.appendInputSelectBox(tenantDropdownBuilder, this._azureTenantDropdown);
|
||||
|
||||
// Database
|
||||
let databaseOption = this._optionsMaps[ConnectionOptionSpecialType.databaseName];
|
||||
let databaseNameBuilder = DialogHelper.appendRow(this._tableContainer, databaseOption.displayName, 'connection-label', 'connection-input');
|
||||
|
||||
this._databaseNameInputBox = new Dropdown(databaseNameBuilder.getHTMLElement(), this._contextViewService, this._themeService, {
|
||||
values: [this._defaultDatabaseName, this._loadingDatabaseName],
|
||||
strictSelection: false,
|
||||
placeholder: this._defaultDatabaseName,
|
||||
maxHeight: 125,
|
||||
ariaLabel: databaseOption.displayName,
|
||||
actionLabel: localize('connectionWidget.toggleDatabaseNameDropdown', 'Select Database Toggle Dropdown')
|
||||
});
|
||||
|
||||
// Server group
|
||||
let serverGroupBuilder = DialogHelper.appendRow(this._tableContainer, this._serverGroupDisplayString, 'connection-label', 'connection-input');
|
||||
DialogHelper.appendInputSelectBox(serverGroupBuilder, this._serverGroupSelectBox);
|
||||
|
||||
// Connection name
|
||||
let connectionNameOption = this._optionsMaps[ConnectionOptionSpecialType.connectionName];
|
||||
let connectionNameBuilder = DialogHelper.appendRow(this._tableContainer, connectionNameOption.displayName, 'connection-label', 'connection-input');
|
||||
this._connectionNameInputBox = new InputBox(connectionNameBuilder.getHTMLElement(), this._contextViewService, { ariaLabel: connectionNameOption.displayName });
|
||||
|
||||
let AdvancedLabel = localize('advanced', 'Advanced...');
|
||||
this._advancedButton = this.createAdvancedButton(this._tableContainer, AdvancedLabel);
|
||||
}
|
||||
|
||||
private validateUsername(value: string, isOptionRequired: boolean): boolean {
|
||||
let currentAuthType = this._authTypeSelectBox ? this.getMatchingAuthType(this._authTypeSelectBox.value) : undefined;
|
||||
if (!currentAuthType || currentAuthType === AuthenticationType.SqlLogin) {
|
||||
if (!value && isOptionRequired) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private createAdvancedButton(container: Builder, title: string): Button {
|
||||
let button;
|
||||
container.element('tr', {}, (rowContainer) => {
|
||||
rowContainer.element('td');
|
||||
rowContainer.element('td', { align: 'right' }, (cellContainer) => {
|
||||
cellContainer.div({ class: 'advanced-button' }, (divContainer) => {
|
||||
button = new Button(divContainer);
|
||||
button.label = title;
|
||||
button.onDidClick(() => {
|
||||
//open advanced page
|
||||
this._callbacks.onAdvancedProperties();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
private appendCheckbox(container: Builder, label: string, checkboxClass: string, cellContainerClass: string, rowContainerClass: string, isChecked: boolean): Checkbox {
|
||||
let checkbox: Checkbox;
|
||||
container.element('tr', { class: rowContainerClass }, (rowContainer) => {
|
||||
rowContainer.element('td');
|
||||
rowContainer.element('td', { class: cellContainerClass }, (inputCellContainer) => {
|
||||
checkbox = new Checkbox(inputCellContainer.getHTMLElement(), { label, checked: isChecked, ariaLabel: label });
|
||||
});
|
||||
});
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
// Theme styler
|
||||
this._toDispose.push(styler.attachInputBoxStyler(this._serverNameInputBox, this._themeService));
|
||||
this._toDispose.push(styler.attachEditableDropdownStyler(this._databaseNameInputBox, this._themeService));
|
||||
this._toDispose.push(styler.attachInputBoxStyler(this._connectionNameInputBox, this._themeService));
|
||||
this._toDispose.push(styler.attachInputBoxStyler(this._userNameInputBox, this._themeService));
|
||||
this._toDispose.push(styler.attachInputBoxStyler(this._passwordInputBox, this._themeService));
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._serverGroupSelectBox, this._themeService));
|
||||
this._toDispose.push(styler.attachButtonStyler(this._advancedButton, this._themeService));
|
||||
this._toDispose.push(styler.attachCheckboxStyler(this._rememberPasswordCheckBox, this._themeService));
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._azureAccountDropdown, this._themeService));
|
||||
|
||||
if (this._authTypeSelectBox) {
|
||||
// Theme styler
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._authTypeSelectBox, this._themeService));
|
||||
this._toDispose.push(this._authTypeSelectBox.onDidSelect(selectedAuthType => {
|
||||
this.onAuthTypeSelected(selectedAuthType.selected);
|
||||
this.setConnectButton();
|
||||
}));
|
||||
}
|
||||
|
||||
if (this._azureAccountDropdown) {
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._azureAccountDropdown, this._themeService));
|
||||
this._toDispose.push(this._azureAccountDropdown.onDidSelect(() => {
|
||||
this.onAzureAccountSelected();
|
||||
}));
|
||||
}
|
||||
|
||||
if (this._azureTenantDropdown) {
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._azureTenantDropdown, this._themeService));
|
||||
this._toDispose.push(this._azureTenantDropdown.onDidSelect((selectInfo) => {
|
||||
this.onAzureTenantSelected(selectInfo.index);
|
||||
}));
|
||||
}
|
||||
|
||||
if (this._refreshCredentialsLinkBuilder) {
|
||||
this._toDispose.push(this._refreshCredentialsLinkBuilder.on(DOM.EventType.CLICK, async () => {
|
||||
let account = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
|
||||
if (account) {
|
||||
await this._accountManagementService.refreshAccount(account);
|
||||
this.fillInAzureAccountOptions();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
this._toDispose.push(this._serverGroupSelectBox.onDidSelect(selectedGroup => {
|
||||
this.onGroupSelected(selectedGroup.selected);
|
||||
}));
|
||||
|
||||
this._toDispose.push(this._serverNameInputBox.onDidChange(serverName => {
|
||||
this.serverNameChanged(serverName);
|
||||
}));
|
||||
|
||||
this._toDispose.push(this._userNameInputBox.onDidChange(userName => {
|
||||
this.setConnectButton();
|
||||
}));
|
||||
|
||||
this._toDispose.push(this._passwordInputBox.onDidChange(passwordInput => {
|
||||
this._password = passwordInput;
|
||||
}));
|
||||
|
||||
this._toDispose.push(this._databaseNameInputBox.onFocus(() => {
|
||||
this._databaseDropdownExpanded = true;
|
||||
if (this.serverName) {
|
||||
this._databaseNameInputBox.values = [this._loadingDatabaseName];
|
||||
this._callbacks.onFetchDatabases(this.serverName, this.authenticationType, this.userName, this._password).then(databases => {
|
||||
if (databases) {
|
||||
this._databaseNameInputBox.values = databases.sort((a, b) => a.localeCompare(b));
|
||||
} else {
|
||||
this._databaseNameInputBox.values = [this._defaultDatabaseName];
|
||||
}
|
||||
}).catch(() => {
|
||||
this._databaseNameInputBox.values = [this._defaultDatabaseName];
|
||||
});
|
||||
} else {
|
||||
this._databaseNameInputBox.values = [this._defaultDatabaseName];
|
||||
}
|
||||
}));
|
||||
|
||||
this._toDispose.push(this._databaseNameInputBox.onValueChange(s => {
|
||||
if (s === this._defaultDatabaseName || s === this._loadingDatabaseName) {
|
||||
this._databaseNameInputBox.value = '';
|
||||
} else {
|
||||
this._databaseNameInputBox.value = s;
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
private onGroupSelected(selectedGroup: string) {
|
||||
if (selectedGroup === this._addNewServerGroup.name) {
|
||||
// Select previous non-AddGroup option in case AddServerGroup dialog is cancelled
|
||||
this._serverGroupSelectBox.selectWithOptionName(this._previousGroupOption);
|
||||
this._callbacks.onCreateNewServerGroup();
|
||||
} else {
|
||||
this._previousGroupOption = selectedGroup;
|
||||
}
|
||||
}
|
||||
|
||||
private setConnectButton(): void {
|
||||
let showUsernameAndPassword: boolean = true;
|
||||
if (this.authType) {
|
||||
showUsernameAndPassword = this.authType === AuthenticationType.SqlLogin;
|
||||
}
|
||||
showUsernameAndPassword ? this._callbacks.onSetConnectButton(!!this.serverName && !!this.userName) :
|
||||
this._callbacks.onSetConnectButton(!!this.serverName);
|
||||
}
|
||||
|
||||
private onAuthTypeSelected(selectedAuthType: string) {
|
||||
let currentAuthType = this.getMatchingAuthType(selectedAuthType);
|
||||
if (currentAuthType !== AuthenticationType.SqlLogin) {
|
||||
this._userNameInputBox.disable();
|
||||
this._passwordInputBox.disable();
|
||||
this._userNameInputBox.hideMessage();
|
||||
this._passwordInputBox.hideMessage();
|
||||
this._userNameInputBox.value = '';
|
||||
this._passwordInputBox.value = '';
|
||||
this._password = '';
|
||||
|
||||
this._rememberPasswordCheckBox.checked = false;
|
||||
this._rememberPasswordCheckBox.enabled = false;
|
||||
} else {
|
||||
this._userNameInputBox.enable();
|
||||
this._passwordInputBox.enable();
|
||||
this._rememberPasswordCheckBox.enabled = true;
|
||||
}
|
||||
|
||||
if (currentAuthType === AuthenticationType.AzureMFA) {
|
||||
this.fillInAzureAccountOptions();
|
||||
this._azureAccountDropdown.enable();
|
||||
let tableContainer = this._tableContainer.getContainer();
|
||||
tableContainer.classList.add('hide-username-password');
|
||||
tableContainer.classList.remove('hide-azure-accounts');
|
||||
} else {
|
||||
this._azureAccountDropdown.disable();
|
||||
let tableContainer = this._tableContainer.getContainer();
|
||||
tableContainer.classList.remove('hide-username-password');
|
||||
tableContainer.classList.add('hide-azure-accounts');
|
||||
this._azureAccountDropdown.hideMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private async fillInAzureAccountOptions(): Promise<void> {
|
||||
let oldSelection = this._azureAccountDropdown.value;
|
||||
this._azureAccountList = await this._accountManagementService.getAccountsForProvider(this._azureProviderId);
|
||||
let accountDropdownOptions = this._azureAccountList.map(account => account.key.accountId);
|
||||
if (accountDropdownOptions.length === 0) {
|
||||
// If there are no accounts add a blank option so that add account isn't automatically selected
|
||||
accountDropdownOptions.unshift('');
|
||||
}
|
||||
accountDropdownOptions.push(this._addAzureAccountMessage);
|
||||
this._azureAccountDropdown.setOptions(accountDropdownOptions);
|
||||
this._azureAccountDropdown.selectWithOptionName(oldSelection);
|
||||
await this.onAzureAccountSelected();
|
||||
}
|
||||
|
||||
private async updateRefreshCredentialsLink(): Promise<void> {
|
||||
let chosenAccount = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
|
||||
if (chosenAccount && chosenAccount.isStale) {
|
||||
this._tableContainer.getContainer().classList.remove('hide-refresh-link');
|
||||
} else {
|
||||
this._tableContainer.getContainer().classList.add('hide-refresh-link');
|
||||
}
|
||||
}
|
||||
|
||||
private async onAzureAccountSelected(): Promise<void> {
|
||||
// Reset the dropdown's validation message if the old selection was not valid but the new one is
|
||||
this.validateAzureAccountSelection(false);
|
||||
|
||||
// Open the add account dialog if needed, then select the added account
|
||||
if (this._azureAccountDropdown.value === this._addAzureAccountMessage) {
|
||||
let oldAccountIds = this._azureAccountList.map(account => account.key.accountId);
|
||||
await this._accountManagementService.addAccount(this._azureProviderId);
|
||||
|
||||
// Refresh the dropdown's list to include the added account
|
||||
await this.fillInAzureAccountOptions();
|
||||
|
||||
// If a new account was added find it and select it, otherwise select the first account
|
||||
let newAccount = this._azureAccountList.find(option => !oldAccountIds.some(oldId => oldId === option.key.accountId));
|
||||
if (newAccount) {
|
||||
this._azureAccountDropdown.selectWithOptionName(newAccount.key.accountId);
|
||||
} else {
|
||||
this._azureAccountDropdown.select(0);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateRefreshCredentialsLink();
|
||||
|
||||
// Display the tenant select box if needed
|
||||
const hideTenantsClassName = 'hide-azure-tenants';
|
||||
let selectedAccount = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
|
||||
if (selectedAccount && selectedAccount.properties.tenants && selectedAccount.properties.tenants.length > 1) {
|
||||
// There are multiple tenants available so let the user select one
|
||||
let options = selectedAccount.properties.tenants.map(tenant => tenant.displayName);
|
||||
this._azureTenantDropdown.setOptions(options);
|
||||
this._tableContainer.getContainer().classList.remove(hideTenantsClassName);
|
||||
this.onAzureTenantSelected(0);
|
||||
} else {
|
||||
if (selectedAccount && selectedAccount.properties.tenants && selectedAccount.properties.tenants.length === 1) {
|
||||
this._azureTenantId = selectedAccount.properties.tenants[0].id;
|
||||
} else {
|
||||
this._azureTenantId = undefined;
|
||||
}
|
||||
this._tableContainer.getContainer().classList.add(hideTenantsClassName);
|
||||
}
|
||||
}
|
||||
|
||||
private onAzureTenantSelected(tenantIndex: number): void {
|
||||
this._azureTenantId = undefined;
|
||||
let account = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
|
||||
if (account && account.properties.tenants) {
|
||||
let tenant = account.properties.tenants[tenantIndex];
|
||||
if (tenant) {
|
||||
this._azureTenantId = tenant.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private serverNameChanged(serverName: string) {
|
||||
this.setConnectButton();
|
||||
if (serverName.toLocaleLowerCase().includes('database.windows.net')) {
|
||||
this._callbacks.onSetAzureTimeOut();
|
||||
}
|
||||
}
|
||||
|
||||
public focusOnAdvancedButton() {
|
||||
this._advancedButton.focus();
|
||||
}
|
||||
|
||||
public focusOnServerGroup() {
|
||||
this._serverGroupSelectBox.focus();
|
||||
}
|
||||
|
||||
public updateServerGroup(connectionGroups: IConnectionProfileGroup[], groupName?: string) {
|
||||
this._serverGroupOptions = connectionGroups;
|
||||
this._serverGroupOptions.push(this._addNewServerGroup);
|
||||
this._serverGroupSelectBox.setOptions(this._serverGroupOptions.map(g => g.name));
|
||||
if (groupName) {
|
||||
this._serverGroupSelectBox.selectWithOptionName(groupName);
|
||||
this._previousGroupOption = this._serverGroupSelectBox.value;
|
||||
}
|
||||
}
|
||||
|
||||
public initDialog(connectionInfo: IConnectionProfile): void {
|
||||
this.fillInConnectionInputs(connectionInfo);
|
||||
}
|
||||
|
||||
public focusOnOpen(): void {
|
||||
this._handleClipboard();
|
||||
this._serverNameInputBox.focus();
|
||||
this.focusPasswordIfNeeded();
|
||||
this.clearValidationMessages();
|
||||
}
|
||||
|
||||
private clearValidationMessages(): void {
|
||||
this._serverNameInputBox.hideMessage();
|
||||
this._userNameInputBox.hideMessage();
|
||||
this._azureAccountDropdown.hideMessage();
|
||||
}
|
||||
|
||||
private getModelValue(value: string): string {
|
||||
return value ? value : '';
|
||||
}
|
||||
|
||||
public fillInConnectionInputs(connectionInfo: IConnectionProfile) {
|
||||
if (connectionInfo) {
|
||||
this._serverNameInputBox.value = this.getModelValue(connectionInfo.serverName);
|
||||
this._databaseNameInputBox.value = this.getModelValue(connectionInfo.databaseName);
|
||||
this._connectionNameInputBox.value = this.getModelValue(connectionInfo.connectionName);
|
||||
this._userNameInputBox.value = this.getModelValue(connectionInfo.userName);
|
||||
this._passwordInputBox.value = connectionInfo.password ? Constants.passwordChars : '';
|
||||
this._password = this.getModelValue(connectionInfo.password);
|
||||
this._saveProfile = connectionInfo.saveProfile;
|
||||
this._azureTenantId = connectionInfo.azureTenantId;
|
||||
let groupName: string;
|
||||
if (this._saveProfile) {
|
||||
if (!connectionInfo.groupFullName) {
|
||||
groupName = this.DefaultServerGroup.name;
|
||||
} else {
|
||||
groupName = connectionInfo.groupFullName.replace('root/', '');
|
||||
}
|
||||
} else {
|
||||
groupName = this.NoneServerGroup.name;
|
||||
}
|
||||
this._serverGroupSelectBox.selectWithOptionName(groupName);
|
||||
this._previousGroupOption = this._serverGroupSelectBox.value;
|
||||
|
||||
// To handle the empty password case
|
||||
if (this.getModelValue(connectionInfo.password) === '') {
|
||||
this._rememberPasswordCheckBox.checked = false;
|
||||
} else {
|
||||
this._rememberPasswordCheckBox.checked = connectionInfo.savePassword;
|
||||
}
|
||||
|
||||
if (connectionInfo.authenticationType !== null && connectionInfo.authenticationType !== undefined) {
|
||||
var authTypeDisplayName = this.getAuthTypeDisplayName(connectionInfo.authenticationType);
|
||||
this._authTypeSelectBox.selectWithOptionName(authTypeDisplayName);
|
||||
}
|
||||
|
||||
if (this._authTypeSelectBox) {
|
||||
this.onAuthTypeSelected(this._authTypeSelectBox.value);
|
||||
} else {
|
||||
let tableContainerElement = this._tableContainer.getContainer();
|
||||
tableContainerElement.classList.remove('hide-username-password');
|
||||
tableContainerElement.classList.add('hide-azure-accounts');
|
||||
}
|
||||
|
||||
if (this.authType === AuthenticationType.AzureMFA) {
|
||||
this.fillInAzureAccountOptions().then(async () => {
|
||||
this._azureAccountDropdown.selectWithOptionName(this.getModelValue(connectionInfo.userName));
|
||||
await this.onAzureAccountSelected();
|
||||
let tenantId = connectionInfo.azureTenantId;
|
||||
let account = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
|
||||
if (account && account.properties.tenants.length > 1) {
|
||||
let tenant = account.properties.tenants.find(tenant => tenant.id === tenantId);
|
||||
if (tenant) {
|
||||
this._azureTenantDropdown.selectWithOptionName(tenant.displayName);
|
||||
}
|
||||
this.onAzureTenantSelected(this._azureTenantDropdown.values.indexOf(this._azureTenantDropdown.value));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Disable connect button if -
|
||||
// 1. Authentication type is SQL Login and no username is provided
|
||||
// 2. No server name is provided
|
||||
this.setConnectButton();
|
||||
this.focusPasswordIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
private getAuthTypeDisplayName(authTypeName: string) {
|
||||
var displayName: string;
|
||||
var authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType];
|
||||
|
||||
if (authTypeOption) {
|
||||
authTypeOption.categoryValues.forEach(c => {
|
||||
if (c.name === authTypeName) {
|
||||
displayName = c.displayName;
|
||||
}
|
||||
});
|
||||
}
|
||||
return displayName;
|
||||
}
|
||||
|
||||
private getAuthTypeName(authTypeDisplayName: string) {
|
||||
var authTypeName: string;
|
||||
var authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType];
|
||||
authTypeOption.categoryValues.forEach(c => {
|
||||
if (c.displayName === authTypeDisplayName) {
|
||||
authTypeName = c.name;
|
||||
}
|
||||
});
|
||||
return authTypeName;
|
||||
}
|
||||
|
||||
public handleOnConnecting(): void {
|
||||
this._focusedBeforeHandleOnConnection = <HTMLElement>document.activeElement;
|
||||
this._advancedButton.enabled = false;
|
||||
|
||||
this._serverGroupSelectBox.disable();
|
||||
this._serverNameInputBox.disable();
|
||||
this._databaseNameInputBox.enabled = false;
|
||||
this._userNameInputBox.disable();
|
||||
this._passwordInputBox.disable();
|
||||
this._connectionNameInputBox.disable();
|
||||
this._rememberPasswordCheckBox.enabled = false;
|
||||
if (this._authTypeSelectBox) {
|
||||
this._authTypeSelectBox.disable();
|
||||
}
|
||||
}
|
||||
|
||||
public handleResetConnection(): void {
|
||||
this._advancedButton.enabled = true;
|
||||
|
||||
this._serverGroupSelectBox.enable();
|
||||
this._serverNameInputBox.enable();
|
||||
this._connectionNameInputBox.enable();
|
||||
this._databaseNameInputBox.enabled = true;
|
||||
let currentAuthType: AuthenticationType = undefined;
|
||||
if (this._authTypeSelectBox) {
|
||||
this._authTypeSelectBox.enable();
|
||||
currentAuthType = this.getMatchingAuthType(this._authTypeSelectBox.value);
|
||||
}
|
||||
|
||||
if (!currentAuthType || currentAuthType === AuthenticationType.SqlLogin) {
|
||||
this._userNameInputBox.enable();
|
||||
this._passwordInputBox.enable();
|
||||
this._rememberPasswordCheckBox.enabled = true;
|
||||
}
|
||||
|
||||
if (this._focusedBeforeHandleOnConnection) {
|
||||
this._focusedBeforeHandleOnConnection.focus();
|
||||
}
|
||||
}
|
||||
|
||||
public get connectionName(): string {
|
||||
return this._connectionNameInputBox.value;
|
||||
}
|
||||
|
||||
public get serverName(): string {
|
||||
return this._serverNameInputBox.value;
|
||||
}
|
||||
|
||||
public get databaseName(): string {
|
||||
return this._databaseNameInputBox.value;
|
||||
}
|
||||
|
||||
public get userName(): string {
|
||||
return this.authenticationType === AuthenticationType.AzureMFA ? this._azureAccountDropdown.value : this._userNameInputBox.value;
|
||||
}
|
||||
|
||||
public get password(): string {
|
||||
return this._password;
|
||||
}
|
||||
|
||||
public get authenticationType(): string {
|
||||
return this._authTypeSelectBox ? this.getAuthTypeName(this._authTypeSelectBox.value) : undefined;
|
||||
}
|
||||
|
||||
private validateAzureAccountSelection(showMessage: boolean = true): boolean {
|
||||
if (this.authType !== AuthenticationType.AzureMFA) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let selected = this._azureAccountDropdown.value;
|
||||
if (selected === '' || selected === this._addAzureAccountMessage) {
|
||||
if (showMessage) {
|
||||
this._azureAccountDropdown.showMessage({
|
||||
content: localize('connectionWidget.invalidAzureAccount', 'You must select an account'),
|
||||
type: MessageType.ERROR
|
||||
});
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
this._azureAccountDropdown.hideMessage();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private validateInputs(): boolean {
|
||||
let isFocused = false;
|
||||
let validateServerName = this._serverNameInputBox.validate();
|
||||
if (!validateServerName) {
|
||||
this._serverNameInputBox.focus();
|
||||
isFocused = true;
|
||||
}
|
||||
let validateUserName = this._userNameInputBox.validate();
|
||||
if (!validateUserName && !isFocused) {
|
||||
this._userNameInputBox.focus();
|
||||
isFocused = true;
|
||||
}
|
||||
let validatePassword = this._passwordInputBox.validate();
|
||||
if (!validatePassword && !isFocused) {
|
||||
this._passwordInputBox.focus();
|
||||
isFocused = true;
|
||||
}
|
||||
let validateAzureAccount = this.validateAzureAccountSelection();
|
||||
if (!validateAzureAccount && !isFocused) {
|
||||
this._azureAccountDropdown.focus();
|
||||
isFocused = true;
|
||||
}
|
||||
return validateServerName && validateUserName && validatePassword && validateAzureAccount;
|
||||
}
|
||||
|
||||
public connect(model: IConnectionProfile): boolean {
|
||||
let validInputs = this.validateInputs();
|
||||
if (validInputs) {
|
||||
model.connectionName = this.connectionName;
|
||||
model.serverName = this.serverName;
|
||||
model.databaseName = this.databaseName;
|
||||
model.userName = this.userName;
|
||||
model.password = this.password;
|
||||
model.authenticationType = this.authenticationType;
|
||||
model.savePassword = this._rememberPasswordCheckBox.checked;
|
||||
if (this._serverGroupSelectBox.value === this.DefaultServerGroup.name) {
|
||||
model.groupFullName = '';
|
||||
model.saveProfile = true;
|
||||
model.groupId = this.findGroupId(model.groupFullName);
|
||||
} else if (this._serverGroupSelectBox.value === this.NoneServerGroup.name) {
|
||||
model.groupFullName = '';
|
||||
model.saveProfile = false;
|
||||
} else if (this._serverGroupSelectBox.value !== this._addNewServerGroup.name) {
|
||||
model.groupFullName = this._serverGroupSelectBox.value;
|
||||
model.saveProfile = true;
|
||||
model.groupId = this.findGroupId(model.groupFullName);
|
||||
}
|
||||
if (this.authType === AuthenticationType.AzureMFA) {
|
||||
model.azureTenantId = this._azureTenantId;
|
||||
}
|
||||
}
|
||||
return validInputs;
|
||||
}
|
||||
|
||||
private findGroupId(groupFullName: string): string {
|
||||
let group: IConnectionProfileGroup;
|
||||
if (ConnectionProfileGroup.isRoot(groupFullName)) {
|
||||
group = this._serverGroupOptions.find(g => ConnectionProfileGroup.isRoot(g.name));
|
||||
if (group === undefined) {
|
||||
group = this._serverGroupOptions.find(g => g.name === this.DefaultServerGroup.name);
|
||||
}
|
||||
} else {
|
||||
group = this._serverGroupOptions.find(g => g.name === groupFullName);
|
||||
}
|
||||
return group ? group.id : undefined;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = lifecycle.dispose(this._toDispose);
|
||||
}
|
||||
|
||||
private getMatchingAuthType(displayName: string): AuthenticationType {
|
||||
const authType = this._authTypeMap[this._providerName];
|
||||
return authType ? authType.find(authType => this.getAuthTypeDisplayName(authType) === displayName) : undefined;
|
||||
}
|
||||
|
||||
public closeDatabaseDropdown(): void {
|
||||
this._databaseNameInputBox.blur();
|
||||
}
|
||||
|
||||
public get databaseDropdownExpanded(): boolean {
|
||||
return this._databaseDropdownExpanded;
|
||||
}
|
||||
|
||||
public set databaseDropdownExpanded(val: boolean) {
|
||||
this._databaseDropdownExpanded = val;
|
||||
}
|
||||
|
||||
private get authType(): AuthenticationType {
|
||||
let authDisplayName: string = this.getAuthTypeDisplayName(this.authenticationType);
|
||||
return this.getMatchingAuthType(authDisplayName);
|
||||
}
|
||||
|
||||
private focusPasswordIfNeeded(): void {
|
||||
if (this.authType && this.authType === AuthenticationType.SqlLogin && this.userName && !this.password) {
|
||||
this._passwordInputBox.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum AuthenticationType {
|
||||
SqlLogin = 'SqlLogin',
|
||||
Integrated = 'Integrated',
|
||||
AzureMFA = 'AzureMFA'
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#1E1E1E" d="M4.222 0h-2.222v.479c-.526.648-.557 1.57-.043 2.269l.043.059v3.203l-.4.296-.053.053c-.353.352-.547.822-.547 1.321s.194.967.549 1.32c.134.134.288.236.451.322v6.678h14v-16h-11.778z"/><path fill="#E8E8E8" d="M10.798 7l-1.83-2h6.032v2h-4.202zm-2.292-6h-3.207l1.337 1.52 1.87-1.52zm-5.506 8.531v1.469h12v-2h-10.813l-.024.021c-.3.299-.716.479-1.163.51zm0 5.469h12v-2h-12v2zm3.323-8h.631l-.347-.266-.284.266zm8.677-4v-2h-3.289l-1.743 2h5.032z"/><path fill="#F48771" d="M7.246 4.6l2.856-3.277-.405-.002-3.176 2.581-2.607-2.962c-.336-.221-.786-.2-1.082.096-.308.306-.319.779-.069 1.12l2.83 2.444-3.339 2.466c-.339.338-.339.887 0 1.225.339.337.888.337 1.226 0l3.063-2.867 3.33 2.555h.466l-3.093-3.379z"/></svg>
|
||||
|
After Width: | Height: | Size: 787 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#fff" d="M4.222 0h-2.222v.479c-.526.648-.557 1.57-.043 2.269l.043.059v3.203l-.4.296-.053.053c-.353.352-.547.822-.547 1.321s.194.967.549 1.32c.134.134.288.236.451.322v6.678h14v-16h-11.778z"/><path fill="#424242" d="M10.798 7l-1.83-2h6.032v2h-4.202zm-2.292-6h-3.207l1.337 1.52 1.87-1.52zm-5.506 8.531v1.469h12v-2h-10.813l-.024.021c-.3.299-.716.479-1.163.51zm0 5.469h12v-2h-12v2zm3.323-8h.631l-.347-.266-.284.266zm8.677-4v-2h-3.289l-1.743 2h5.032z"/><path fill="#A1260D" d="M7.246 4.6l2.856-3.277-.405-.002-3.176 2.581-2.607-2.962c-.336-.221-.786-.2-1.082.096-.308.306-.319.779-.069 1.12l2.83 2.444-3.339 2.466c-.339.338-.339.887 0 1.225.339.337.888.337 1.226 0l3.063-2.867 3.33 2.555h.466l-3.093-3.379z"/></svg>
|
||||
|
After Width: | Height: | Size: 784 B |
@@ -0,0 +1,136 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
.connection-label {
|
||||
width: 80px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.connection-input {
|
||||
width: 200px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.connection-dialog {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.connection-dialog .tabbedPanel {
|
||||
border-top-color: transparent;
|
||||
flex: 1 1;
|
||||
min-height: 120px;
|
||||
overflow: hidden;
|
||||
margin: 0px 11px;
|
||||
}
|
||||
|
||||
.connection-dialog .tabBody {
|
||||
overflow: hidden;
|
||||
flex: 1 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.connection-recent, .connection-saved {
|
||||
margin: 5px;
|
||||
flex: 1 1;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.no-recent-connections, .no-saved-connections {
|
||||
font-size: 12px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.connection-history-label {
|
||||
font-size: 15px;
|
||||
display: inline;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.recent-titles-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 5px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.connection-provider-info {
|
||||
overflow-y: hidden;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
.connection-recent-content {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.connection-recent-content .server-explorer-viewlet {
|
||||
flex: 1 1;
|
||||
}
|
||||
|
||||
.connection-table-content {
|
||||
width:100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.connection-saved-content {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.connection-type {
|
||||
flex: 0 0 auto;
|
||||
overflow: hidden;
|
||||
margin: 0px 13px;
|
||||
}
|
||||
|
||||
.vs-dark .connection-dialog .connection-history-actions .action-label.icon,
|
||||
.hc-black .connection-dialog .connection-history-actions .action-label.icon,
|
||||
.connection-dialog .connection-history-actions .action-label.icon {
|
||||
display: block;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
min-width: 20px;
|
||||
background-size: 16px;
|
||||
background-position: 2px center;
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 25px;
|
||||
}
|
||||
|
||||
.search-action.clear-search-results {
|
||||
background: url('clear-search-results.svg');
|
||||
}
|
||||
|
||||
.vs-dark .search-action.clear-search-results,
|
||||
.hc-black .search-action.clear-search-results {
|
||||
background: url('clear-search-results-dark.svg');
|
||||
}
|
||||
|
||||
.connection-details-title {
|
||||
font-size: 14px;
|
||||
margin: 5px 0px;
|
||||
padding: 5px 15px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.hide-azure-accounts .azure-account-row {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hide-username-password .username-password-row {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hide-refresh-link .azure-account-row.refresh-credentials-link {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hide-azure-tenants .azure-tenant-row {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
.advanced-button {
|
||||
width: 100px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { INewConnectionParams, IConnectionResult, IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
export const IConnectionDialogService = createDecorator<IConnectionDialogService>('connectionDialogService');
|
||||
export interface IConnectionDialogService {
|
||||
_serviceBrand: any;
|
||||
/**
|
||||
* Opens the connection dialog and returns the promise for successfully opening the dialog
|
||||
* @param connectionManagementService
|
||||
* @param params
|
||||
* @param model
|
||||
* @param connectionResult
|
||||
*/
|
||||
showDialog(connectionManagementService: IConnectionManagementService, params: INewConnectionParams, model: IConnectionProfile, connectionResult?: IConnectionResult): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Opens the connection dialog and returns the promise when connection is made
|
||||
* or dialog is closed
|
||||
* @param connectionManagementService
|
||||
* @param params
|
||||
* @param model
|
||||
* @param connectionResult
|
||||
*/
|
||||
openDialogAndWait(connectionManagementService: IConnectionManagementService, params?: INewConnectionParams, model?: IConnectionProfile, connectionResult?: IConnectionResult): Thenable<IConnectionProfile>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user