mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 09:35:37 -05:00
CMS Extension - 2 (#4908)
* first set of changes to experiment the registration of cms related apis * Adding cms service entry to workbench * Adding basic functionality for add remove reg servers and group * Returning relative path as part of RegServerResult as string * initial extension * cleaned building with connecting to server * get list of registered servers * progress with registered servers tree * cms base node with server selection * removed unused services * replaced azure stuff with cms * removed cmsResourceService * list servers progress * Removing the cms apis from core. Having mssql extension expose them for cms extension * create server working fine * initial expansion and nodes * Propogating the backend name changes to apis * initial cms extension working * cached connection needs change in api * connect without dashboard in proposed * Fixing some missing sqlops references * add registered server bug found * added refresh context menu option * added payload * server description not disabled after reject connection * added more context actions and action icons * added empty resource and error when same name server is added * fixed connection issues with cms and normal connections * added initial tests * added cms icons * removed azure readme * test script revert * fix build tests * added more cms tests * fixed test script * fixed silent error when expanding servers * added more cms tests * removed cmsdialog from api * cms dialog without object * fixed theming issues * initial connection dialog done * can make connections * PM asks for strings and icons * removed search * removed unused code and fixed 1 test * fix connection management tests * changed icons * format file * fixed hygiene * initial cr comments * refactored cms connection dialog * fixed bug when switching dialogs * localized connection provider options * fixed cms provider name * code review comments * localized options in cms and mssql * localized more options
This commit is contained in:
@@ -61,7 +61,7 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
|
||||
return this._proxy.$getUriForConnection(connectionId);
|
||||
}
|
||||
|
||||
public $connect(connectionProfile: azdata.IConnectionProfile): Thenable<azdata.ConnectionResult> {
|
||||
return this._proxy.$connect(connectionProfile);
|
||||
public $connect(connectionProfile: azdata.IConnectionProfile, saveConnection: boolean = false, showDashboard: boolean = false): Thenable<azdata.ConnectionResult> {
|
||||
return this._proxy.$connect(connectionProfile, saveConnection, showDashboard);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,8 @@ export class MainThreadConnectionManagement implements MainThreadConnectionManag
|
||||
}
|
||||
|
||||
public async $openConnectionDialog(providers: string[], initialConnectionProfile?: IConnectionProfile, connectionCompletionOptions?: azdata.IConnectionCompletionOptions): Promise<azdata.connection.Connection> {
|
||||
let connectionProfile = await this._connectionDialogService.openDialogAndWait(this._connectionManagementService, { connectionType: 1, providers: providers }, initialConnectionProfile);
|
||||
let connectionProfile = await this._connectionDialogService.openDialogAndWait(this._connectionManagementService,
|
||||
{ connectionType: 1, providers: providers }, initialConnectionProfile, undefined);
|
||||
const connection = connectionProfile ? {
|
||||
connectionId: connectionProfile.id,
|
||||
options: connectionProfile.options,
|
||||
@@ -110,12 +111,12 @@ export class MainThreadConnectionManagement implements MainThreadConnectionManag
|
||||
return connection;
|
||||
}
|
||||
|
||||
public $connect(connectionProfile: IConnectionProfile): Thenable<azdata.ConnectionResult> {
|
||||
public $connect(connectionProfile: IConnectionProfile, saveConnection: boolean = false, showDashboard: boolean = false): Thenable<azdata.ConnectionResult> {
|
||||
let profile = new ConnectionProfile(this._capabilitiesService, connectionProfile);
|
||||
profile.id = generateUuid();
|
||||
return this._connectionManagementService.connectAndSaveProfile(profile, undefined, {
|
||||
saveTheConnection: true,
|
||||
showDashboard: true,
|
||||
saveTheConnection: saveConnection,
|
||||
showDashboard: showDashboard,
|
||||
params: undefined,
|
||||
showConnectionDialogOnError: true,
|
||||
showFirewallRuleOnError: true
|
||||
|
||||
@@ -569,8 +569,8 @@ export function createApiFactory(
|
||||
getUriForConnection(connectionId: string): Thenable<string> {
|
||||
return extHostConnectionManagement.$getUriForConnection(connectionId);
|
||||
},
|
||||
connect(connectionProfile: sqlops.IConnectionProfile): Thenable<sqlops.ConnectionResult> {
|
||||
return extHostConnectionManagement.$connect(connectionProfile);
|
||||
connect(connectionProfile: sqlops.IConnectionProfile, saveConnection: boolean, showDashboard: boolean): Thenable<sqlops.ConnectionResult> {
|
||||
return extHostConnectionManagement.$connect(connectionProfile, saveConnection, showDashboard);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -956,7 +956,7 @@ export function createApiFactory(
|
||||
nb: nb,
|
||||
AzureResource: sqlExtHostTypes.AzureResource,
|
||||
extensions: extensions,
|
||||
TreeItem: sqlExtHostTypes.TreeItem,
|
||||
TreeItem: sqlExtHostTypes.TreeItem
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -577,7 +577,7 @@ export interface MainThreadConnectionManagementShape extends IDisposable {
|
||||
$listDatabases(connectionId: string): Thenable<string[]>;
|
||||
$getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
|
||||
$getUriForConnection(connectionId: string): Thenable<string>;
|
||||
$connect(connectionProfile: azdata.IConnectionProfile): Thenable<azdata.ConnectionResult>;
|
||||
$connect(connectionProfile: azdata.IConnectionProfile, saveConnection: boolean, showDashboard: boolean): Thenable<azdata.ConnectionResult>;
|
||||
}
|
||||
|
||||
export interface MainThreadCredentialManagementShape extends IDisposable {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IConnectionComponentCallbacks } from 'sql/workbench/services/connection/browser/connectionDialogService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||
import { ConnectionController } from 'sql/workbench/services/connection/browser/connectionController';
|
||||
import { CmsConnectionWidget } from 'sql/workbench/services/connection/browser/cmsConnectionWidget';
|
||||
|
||||
/**
|
||||
* Connection Controller for CMS Connections
|
||||
*/
|
||||
export class CmsConnectionController extends ConnectionController {
|
||||
|
||||
constructor(container: HTMLElement,
|
||||
connectionManagementService: IConnectionManagementService,
|
||||
connectionProperties: ConnectionProviderProperties,
|
||||
callback: IConnectionComponentCallbacks,
|
||||
providerName: string,
|
||||
authTypeChanged: boolean = false,
|
||||
@IInstantiationService _instantiationService: IInstantiationService) {
|
||||
super(container, connectionManagementService, connectionProperties, callback, providerName, _instantiationService);
|
||||
let specialOptions = this._providerOptions.filter(
|
||||
(property) => (property.specialValueType !== null && property.specialValueType !== undefined));
|
||||
this._connectionWidget = this._instantiationService.createInstance(CmsConnectionWidget, 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, authTypeChanged);
|
||||
}
|
||||
|
||||
public showUiComponent(container: HTMLElement, authTypeChanged: boolean = false): void {
|
||||
this._databaseCache = new Map<string, string[]>();
|
||||
this._connectionWidget.createConnectionWidget(container, authTypeChanged);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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/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/accounts/common/interfaces';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
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 { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
import { ConnectionWidget, AuthenticationType } from 'sql/workbench/services/connection/browser/connectionWidget';
|
||||
|
||||
/**
|
||||
* Connection Widget clas for CMS Connections
|
||||
*/
|
||||
export class CmsConnectionWidget extends ConnectionWidget {
|
||||
|
||||
private _serverDescriptionInputBox: InputBox;
|
||||
protected _authTypeMap: { [providerName: string]: AuthenticationType[] } = {
|
||||
[Constants.cmsProviderName]: [AuthenticationType.SqlLogin, AuthenticationType.Integrated, AuthenticationType.AzureMFA]
|
||||
};
|
||||
|
||||
constructor(options: azdata.ConnectionOption[],
|
||||
callbacks: IConnectionComponentCallbacks,
|
||||
providerName: string,
|
||||
authTypeChanged: boolean = false,
|
||||
@IThemeService _themeService: IThemeService,
|
||||
@IContextViewService _contextViewService: IContextViewService,
|
||||
@ILayoutService _layoutService: ILayoutService,
|
||||
@IConnectionManagementService _connectionManagementService: IConnectionManagementService,
|
||||
@ICapabilitiesService _capabilitiesService: ICapabilitiesService,
|
||||
@IClipboardService _clipboardService: IClipboardService,
|
||||
@IConfigurationService _configurationService: IConfigurationService,
|
||||
@IAccountManagementService _accountManagementService: IAccountManagementService
|
||||
) {
|
||||
super(options, callbacks, providerName, _themeService, _contextViewService, _layoutService, _connectionManagementService, _capabilitiesService,
|
||||
_clipboardService, _configurationService, _accountManagementService);
|
||||
let authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType];
|
||||
if (authTypeOption) {
|
||||
if (OS === OperatingSystem.Windows || authTypeChanged) {
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
protected registerListeners(): void {
|
||||
super.registerListeners();
|
||||
if (this._serverDescriptionInputBox) {
|
||||
this._toDispose.push(styler.attachInputBoxStyler(this._serverDescriptionInputBox, this._themeService));
|
||||
}
|
||||
}
|
||||
|
||||
protected fillInConnectionForm(authTypeChanged: boolean = false): void {
|
||||
// Server Name
|
||||
this.addServerNameOption();
|
||||
|
||||
// Authentication type
|
||||
this.addAuthenticationTypeOption(authTypeChanged);
|
||||
|
||||
// Login Options
|
||||
this.addLoginOptions();
|
||||
|
||||
// Connection Name
|
||||
this.addConnectionNameOptions();
|
||||
|
||||
// Server Description
|
||||
this.addServerDescriptionOption();
|
||||
|
||||
// Advanced Options
|
||||
this.addAdvancedOptions();
|
||||
}
|
||||
|
||||
protected addAuthenticationTypeOption(authTypeChanged: boolean = false): void {
|
||||
super.addAuthenticationTypeOption();
|
||||
let authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType];
|
||||
let newAuthTypes = authTypeOption.categoryValues;
|
||||
if (authTypeChanged) {
|
||||
newAuthTypes = authTypeOption.categoryValues.filter((option) => option.name !== AuthenticationType.SqlLogin);
|
||||
}
|
||||
if (this._authTypeSelectBox) {
|
||||
this._authTypeSelectBox.setOptions(newAuthTypes.map(c => c.displayName));
|
||||
} else {
|
||||
this._authTypeSelectBox = new SelectBox(newAuthTypes.map(c => c.displayName), authTypeOption.defaultValue, this._contextViewService, undefined, { ariaLabel: authTypeOption.displayName });
|
||||
}
|
||||
}
|
||||
|
||||
private addServerDescriptionOption(): void {
|
||||
// Registered Server Description
|
||||
let serverDescriptionOption = this._optionsMaps['serverDescription'];
|
||||
if (serverDescriptionOption) {
|
||||
serverDescriptionOption.displayName = localize('serverDescription', 'Server Description (optional)');
|
||||
let serverDescriptionBuilder = DialogHelper.appendRow(this._tableContainer, serverDescriptionOption.displayName, 'connection-label', 'connection-input', 'server-description-input');
|
||||
this._serverDescriptionInputBox = new InputBox(serverDescriptionBuilder, this._contextViewService, { type: 'textarea', flexibleHeight: true });
|
||||
this._serverDescriptionInputBox.setHeight('75px');
|
||||
}
|
||||
}
|
||||
|
||||
public createConnectionWidget(container: HTMLElement, authTypeChanged: boolean = false): void {
|
||||
this._container = DOM.append(container, DOM.$('div.connection-table'));
|
||||
this._tableContainer = DOM.append(this._container, DOM.$('table.connection-table-content'));
|
||||
this.fillInConnectionForm(authTypeChanged);
|
||||
this.registerListeners();
|
||||
if (this._authTypeSelectBox) {
|
||||
this.onAuthTypeSelected(this._authTypeSelectBox.value);
|
||||
}
|
||||
|
||||
DOM.addDisposableListener(container, 'paste', e => {
|
||||
this._handleClipboard();
|
||||
});
|
||||
}
|
||||
|
||||
public handleOnConnecting(): void {
|
||||
super.handleOnConnecting();
|
||||
if (this._serverDescriptionInputBox) {
|
||||
this._serverDescriptionInputBox.disable();
|
||||
}
|
||||
}
|
||||
|
||||
public handleResetConnection(): void {
|
||||
super.handleResetConnection();
|
||||
if (this._serverDescriptionInputBox) {
|
||||
this._serverDescriptionInputBox.enable();
|
||||
}
|
||||
}
|
||||
|
||||
public get registeredServerDescription(): string {
|
||||
return this._serverDescriptionInputBox.value;
|
||||
}
|
||||
|
||||
public connect(model: IConnectionProfile): boolean {
|
||||
let validInputs = super.connect(model);
|
||||
if (this._serverDescriptionInputBox) {
|
||||
model.options.registeredServerDescription = this._serverDescriptionInputBox.value;
|
||||
model.options.registeredServerName = this._connectionNameInputBox.value;
|
||||
}
|
||||
return validInputs;
|
||||
}
|
||||
}
|
||||
@@ -19,21 +19,21 @@ import { ConnectionWidget } from 'sql/workbench/services/connection/browser/conn
|
||||
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: azdata.ConnectionOption[];
|
||||
private _providerName: string;
|
||||
protected _callback: IConnectionComponentCallbacks;
|
||||
protected _connectionWidget: ConnectionWidget;
|
||||
protected _providerOptions: azdata.ConnectionOption[];
|
||||
/* key: uri, value : list of databases */
|
||||
private _databaseCache = new Map<string, string[]>();
|
||||
protected _databaseCache = new Map<string, string[]>();
|
||||
|
||||
constructor(container: HTMLElement,
|
||||
connectionManagementService: IConnectionManagementService,
|
||||
connectionProperties: ConnectionProviderProperties,
|
||||
callback: IConnectionComponentCallbacks,
|
||||
providerName: string,
|
||||
@IInstantiationService private _instantiationService: IInstantiationService) {
|
||||
@IInstantiationService protected _instantiationService: IInstantiationService) {
|
||||
this._container = container;
|
||||
this._connectionManagementService = connectionManagementService;
|
||||
this._callback = callback;
|
||||
@@ -53,7 +53,7 @@ export class ConnectionController implements IConnectionComponentController {
|
||||
this._providerName = providerName;
|
||||
}
|
||||
|
||||
private onFetchDatabases(serverName: string, authenticationType: string, userName?: string, password?: string): Promise<string[]> {
|
||||
protected onFetchDatabases(serverName: string, authenticationType: string, userName?: string, password?: string): Promise<string[]> {
|
||||
let tempProfile = this._model;
|
||||
tempProfile.serverName = serverName;
|
||||
tempProfile.authenticationType = authenticationType;
|
||||
@@ -90,14 +90,14 @@ export class ConnectionController implements IConnectionComponentController {
|
||||
});
|
||||
}
|
||||
|
||||
private onCreateNewServerGroup(): void {
|
||||
protected onCreateNewServerGroup(): void {
|
||||
this._connectionManagementService.showCreateServerGroupDialog({
|
||||
onAddGroup: (groupName) => this._connectionWidget.updateServerGroup(this.getAllServerGroups(), groupName),
|
||||
onClose: () => this._connectionWidget.focusOnServerGroup()
|
||||
});
|
||||
}
|
||||
|
||||
private handleonSetAzureTimeOut(): void {
|
||||
protected handleonSetAzureTimeOut(): void {
|
||||
let timeoutPropertyName = 'connectTimeout';
|
||||
let timeoutOption = this._model.options[timeoutPropertyName];
|
||||
if (timeoutOption === undefined || timeoutOption === null) {
|
||||
@@ -105,7 +105,7 @@ export class ConnectionController implements IConnectionComponentController {
|
||||
}
|
||||
}
|
||||
|
||||
private handleOnAdvancedProperties(): void {
|
||||
protected handleOnAdvancedProperties(): void {
|
||||
if (!this._advancedController) {
|
||||
this._advancedController = this._instantiationService.createInstance(AdvancedPropertiesController, () => this._connectionWidget.focusOnAdvancedButton());
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ 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 { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
@@ -30,6 +29,7 @@ import { trim } from 'vs/base/common/strings';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { CmsConnectionController } from 'sql/workbench/services/connection/browser/cmsConnectionController';
|
||||
|
||||
export interface IConnectionValidateResult {
|
||||
isValid: boolean;
|
||||
@@ -45,7 +45,7 @@ export interface IConnectionComponentCallbacks {
|
||||
}
|
||||
|
||||
export interface IConnectionComponentController {
|
||||
showUiComponent(container: HTMLElement): void;
|
||||
showUiComponent(container: HTMLElement, didChange?: boolean): void;
|
||||
initDialog(providers: string[], model: IConnectionProfile): void;
|
||||
validateConnection(): IConnectionValidateResult;
|
||||
fillInConnectionInputs(connectionInfo: IConnectionProfile): void;
|
||||
@@ -69,9 +69,11 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
private _providerNameToDisplayNameMap: { [providerDisplayName: string]: string } = {};
|
||||
private _providerTypes: string[] = [];
|
||||
private _currentProviderType: string = 'Microsoft SQL Server';
|
||||
private _previousProviderType: string = undefined;
|
||||
private _connecting: boolean = false;
|
||||
private _connectionErrorTitle = localize('connectionError', 'Connection error');
|
||||
private _dialogDeferredPromise: Deferred<IConnectionProfile>;
|
||||
private _toDispose = [];
|
||||
|
||||
/**
|
||||
* This is used to work around the interconnectedness of this code
|
||||
@@ -123,7 +125,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
/**
|
||||
* 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
|
||||
* 2. If so, filters provider parameter 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
|
||||
@@ -169,13 +171,15 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
profile.serverName = trim(profile.serverName);
|
||||
|
||||
// append the port to the server name for SQL Server connections
|
||||
if (this.getCurrentProviderName() === Constants.mssqlProviderName) {
|
||||
if (this.getCurrentProviderName() === Constants.mssqlProviderName ||
|
||||
this.getCurrentProviderName() === Constants.cmsProviderName) {
|
||||
let portPropertyName: string = 'port';
|
||||
let portOption: string = profile.options[portPropertyName];
|
||||
if (portOption && portOption.indexOf(',') === -1) {
|
||||
profile.serverName = profile.serverName + ',' + portOption;
|
||||
}
|
||||
profile.options[portPropertyName] = undefined;
|
||||
profile.providerName = Constants.mssqlProviderName;
|
||||
}
|
||||
|
||||
// Disable password prompt during reconnect if connected with an empty password
|
||||
@@ -273,9 +277,21 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
// 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);
|
||||
if (providerName === Constants.cmsProviderName) {
|
||||
this._connectionControllerMap[providerName] =
|
||||
this._instantiationService.createInstance(CmsConnectionController,
|
||||
this._container, this._connectionManagementService,
|
||||
this._capabilitiesService.getCapabilities(providerName).connection, {
|
||||
onSetConnectButton: (enable: boolean) => this.handleSetConnectButtonEnable(enable)
|
||||
}, providerName, this._inputModel ? this._inputModel.options.authTypeChanged : false);
|
||||
} else {
|
||||
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];
|
||||
}
|
||||
@@ -291,7 +307,12 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
this._model.providerName = this.getCurrentProviderName();
|
||||
|
||||
this._model = new ConnectionProfile(this._capabilitiesService, this._model);
|
||||
this.uiController.showUiComponent(input.container);
|
||||
if (this._inputModel && this._inputModel.options) {
|
||||
this.uiController.showUiComponent(input.container,
|
||||
this._inputModel.options.authTypeChanged);
|
||||
} else {
|
||||
this.uiController.showUiComponent(input.container);
|
||||
}
|
||||
}
|
||||
|
||||
private handleInitDialog() {
|
||||
@@ -373,11 +394,11 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
params?: INewConnectionParams,
|
||||
model?: IConnectionProfile,
|
||||
connectionResult?: IConnectionResult): Thenable<void> {
|
||||
|
||||
this._connectionManagementService = connectionManagementService;
|
||||
|
||||
this._params = params;
|
||||
this._inputModel = model;
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.updateModelServerCapabilities(model);
|
||||
// If connecting from a query editor set "save connection" to false
|
||||
@@ -403,15 +424,26 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
this._connectionDialog.databaseDropdownExpanded = this.uiController.databaseDropdownExpanded;
|
||||
this.handleOnCancel(this._connectionDialog.newConnectionParams);
|
||||
});
|
||||
this._connectionDialog.onConnect((profile) => this.handleOnConnect(this._connectionDialog.newConnectionParams, profile));
|
||||
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._previousProviderType = this._currentProviderType;
|
||||
}
|
||||
this._connectionDialog.newConnectionParams = params;
|
||||
|
||||
// if provider changed
|
||||
if ((this._previousProviderType !== this._currentProviderType) ||
|
||||
// or if currentProvider not set correctly yet
|
||||
!(this._currentProviderType === Constants.cmsProviderDisplayName && params.providers && params.providers.length > 1)) {
|
||||
this._previousProviderType = undefined;
|
||||
this._connectionDialog.updateProvider(this._providerNameToDisplayNameMap[this.getDefaultProviderName()]);
|
||||
} else {
|
||||
this._connectionDialog.newConnectionParams = params;
|
||||
}
|
||||
return new Promise<void>(() => {
|
||||
this._connectionDialog.open(this._connectionManagementService.getRecentConnections(params.providers).length > 0);
|
||||
this.uiController.focusOnOpen();
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* 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';
|
||||
@@ -19,7 +18,7 @@ import { RecentConnectionTreeController, RecentConnectionActionsProvider } from
|
||||
import { SavedConnectionTreeController } from 'sql/workbench/parts/connection/browser/savedConnectionTreeController';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys';
|
||||
import { ClearRecentConnectionsAction } from 'sql/workbench/parts/connection/common/connectionActions';
|
||||
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
@@ -77,8 +76,8 @@ export class ConnectionDialogWidget extends Modal {
|
||||
public onShowUiComponent: Event<OnShowUIResponse> = this._onShowUiComponent.event;
|
||||
|
||||
private _onFillinConnectionInputs = new Emitter<IConnectionProfile>();
|
||||
public onFillinConnectionInputs: Event<IConnectionProfile> = this._onFillinConnectionInputs.event;
|
||||
|
||||
public onFillinConnectionInputs: Event<IConnectionProfile> = this._onFillinConnectionInputs.event;
|
||||
private _onResetConnection = new Emitter<void>();
|
||||
public onResetConnection: Event<void> = this._onResetConnection.event;
|
||||
|
||||
@@ -120,6 +119,8 @@ export class ConnectionDialogWidget extends Modal {
|
||||
if (validProviderNames && validProviderNames.length > 0) {
|
||||
filteredProviderTypes = filteredProviderTypes.filter(x => validProviderNames.find(v => this.providerNameToDisplayNameMap[v] === x) !== undefined);
|
||||
}
|
||||
} else {
|
||||
filteredProviderTypes = filteredProviderTypes.filter(x => x !== Constants.cmsProviderDisplayName);
|
||||
}
|
||||
this._providerTypeSelectBox.setOptions(filteredProviderTypes);
|
||||
}
|
||||
@@ -440,6 +441,10 @@ export class ConnectionDialogWidget extends Modal {
|
||||
this.onProviderTypeSelected(displayName);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose.forEach(obj => obj.dispose());
|
||||
}
|
||||
|
||||
public set databaseDropdownExpanded(val: boolean) {
|
||||
this._databaseDropdownExpanded = val;
|
||||
}
|
||||
|
||||
@@ -37,13 +37,9 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
||||
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
|
||||
export class ConnectionWidget {
|
||||
private _container: HTMLElement;
|
||||
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;
|
||||
@@ -55,22 +51,26 @@ export class ConnectionWidget {
|
||||
private readonly _azureProviderId = 'azurePublicCloud';
|
||||
private _azureTenantId: string;
|
||||
private _azureAccountList: azdata.Account[];
|
||||
private _advancedButton: Button;
|
||||
private _callbacks: IConnectionComponentCallbacks;
|
||||
private _authTypeSelectBox: SelectBox;
|
||||
private _toDispose: lifecycle.IDisposable[];
|
||||
private _optionsMaps: { [optionType: number]: azdata.ConnectionOption };
|
||||
private _tableContainer: HTMLElement;
|
||||
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');
|
||||
protected _container: HTMLElement;
|
||||
protected _serverGroupSelectBox: SelectBox;
|
||||
protected _authTypeSelectBox: SelectBox;
|
||||
protected _toDispose: lifecycle.IDisposable[];
|
||||
protected _optionsMaps: { [optionType: number]: azdata.ConnectionOption };
|
||||
protected _tableContainer: HTMLElement;
|
||||
protected _providerName: string;
|
||||
protected _authTypeMap: { [providerName: string]: AuthenticationType[] } = {
|
||||
[Constants.mssqlProviderName]: [AuthenticationType.SqlLogin, AuthenticationType.Integrated, AuthenticationType.AzureMFA]
|
||||
};
|
||||
protected _connectionNameInputBox: InputBox;
|
||||
protected _databaseNameInputBox: Dropdown;
|
||||
protected _advancedButton: Button;
|
||||
public DefaultServerGroup: IConnectionProfileGroup = {
|
||||
id: '',
|
||||
name: localize('defaultServerGroup', '<Default>'),
|
||||
@@ -96,8 +96,8 @@ export class ConnectionWidget {
|
||||
constructor(options: azdata.ConnectionOption[],
|
||||
callbacks: IConnectionComponentCallbacks,
|
||||
providerName: string,
|
||||
@IThemeService private _themeService: IThemeService,
|
||||
@IContextViewService private _contextViewService: IContextViewService,
|
||||
@IThemeService protected _themeService: IThemeService,
|
||||
@IContextViewService protected _contextViewService: IContextViewService,
|
||||
@ILayoutService private _layoutService: ILayoutService,
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
||||
@@ -125,13 +125,13 @@ export class ConnectionWidget {
|
||||
this._providerName = providerName;
|
||||
}
|
||||
|
||||
public createConnectionWidget(container: HTMLElement): void {
|
||||
public createConnectionWidget(container: HTMLElement, authTypeChanged: boolean = false): 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._container = DOM.append(container, DOM.$('div.connection-table'));
|
||||
this._tableContainer = DOM.append(this._container, DOM.$('table.connection-table-content'));
|
||||
this.fillInConnectionForm();
|
||||
this.fillInConnectionForm(authTypeChanged);
|
||||
this.registerListeners();
|
||||
if (this._authTypeSelectBox) {
|
||||
this.onAuthTypeSelected(this._authTypeSelectBox.value);
|
||||
@@ -142,7 +142,7 @@ export class ConnectionWidget {
|
||||
});
|
||||
}
|
||||
|
||||
private _handleClipboard(): void {
|
||||
protected _handleClipboard(): void {
|
||||
if (this._configurationService.getValue<boolean>('connection.parseClipboardForConnectionString')) {
|
||||
let paste = this._clipboardService.readText();
|
||||
this._connectionManagementService.buildConnectionInfo(paste, this._providerName).then(e => {
|
||||
@@ -157,7 +157,37 @@ export class ConnectionWidget {
|
||||
}
|
||||
}
|
||||
|
||||
private fillInConnectionForm(): void {
|
||||
protected fillInConnectionForm(authTypeChanged: boolean = false): void {
|
||||
// Server Name
|
||||
this.addServerNameOption();
|
||||
|
||||
// Authentication type
|
||||
this.addAuthenticationTypeOption(authTypeChanged);
|
||||
|
||||
// Login Options
|
||||
this.addLoginOptions();
|
||||
|
||||
// Database
|
||||
this.addDatabaseOption();
|
||||
|
||||
// Server Group
|
||||
this.addServerGroupOption();
|
||||
|
||||
// Connection Name
|
||||
this.addConnectionNameOptions();
|
||||
|
||||
// Advanced Options
|
||||
this.addAdvancedOptions();
|
||||
}
|
||||
|
||||
protected addAuthenticationTypeOption(authTypeChanged: boolean = false): void {
|
||||
if (this._optionsMaps[ConnectionOptionSpecialType.authType]) {
|
||||
let authType = DialogHelper.appendRow(this._tableContainer, this._optionsMaps[ConnectionOptionSpecialType.authType].displayName, 'connection-label', 'connection-input');
|
||||
DialogHelper.appendInputSelectBox(authType, this._authTypeSelectBox);
|
||||
}
|
||||
}
|
||||
|
||||
protected addServerNameOption(): void {
|
||||
// Server name
|
||||
let serverNameOption = this._optionsMaps[ConnectionOptionSpecialType.serverName];
|
||||
let serverName = DialogHelper.appendRow(this._tableContainer, serverNameOption.displayName, 'connection-label', 'connection-input');
|
||||
@@ -174,13 +204,9 @@ export class ConnectionWidget {
|
||||
},
|
||||
ariaLabel: serverNameOption.displayName
|
||||
});
|
||||
}
|
||||
|
||||
// Authentication type
|
||||
if (this._optionsMaps[ConnectionOptionSpecialType.authType]) {
|
||||
let authType = DialogHelper.appendRow(this._tableContainer, this._optionsMaps[ConnectionOptionSpecialType.authType].displayName, 'connection-label', 'connection-input');
|
||||
DialogHelper.appendInputSelectBox(authType, this._authTypeSelectBox);
|
||||
}
|
||||
|
||||
protected addLoginOptions(): void {
|
||||
// Username
|
||||
let self = this;
|
||||
let userNameOption = this._optionsMaps[ConnectionOptionSpecialType.userName];
|
||||
@@ -211,35 +237,46 @@ export class ConnectionWidget {
|
||||
this._refreshCredentialsLink = DOM.append(refreshCredentials, DOM.$('a'));
|
||||
this._refreshCredentialsLink.href = '#';
|
||||
this._refreshCredentialsLink.innerText = localize('connectionWidget.refreshAzureCredentials', 'Refresh account credentials');
|
||||
|
||||
// Azure tenant picker
|
||||
let tenantLabel = localize('connection.azureTenantDropdownLabel', 'Azure AD tenant');
|
||||
let tenantDropdown = DialogHelper.appendRow(this._tableContainer, tenantLabel, 'connection-label', 'connection-input', ['azure-account-row', 'azure-tenant-row']);
|
||||
this._azureTenantDropdown = new SelectBox([], undefined, this._contextViewService, tenantDropdown, { ariaLabel: tenantLabel });
|
||||
DialogHelper.appendInputSelectBox(tenantDropdown, this._azureTenantDropdown);
|
||||
}
|
||||
|
||||
private addDatabaseOption(): void {
|
||||
// Database
|
||||
let databaseOption = this._optionsMaps[ConnectionOptionSpecialType.databaseName];
|
||||
let databaseName = DialogHelper.appendRow(this._tableContainer, databaseOption.displayName, 'connection-label', 'connection-input');
|
||||
|
||||
this._databaseNameInputBox = new Dropdown(databaseName, this._contextViewService, this._layoutService, {
|
||||
values: [this._defaultDatabaseName, this._loadingDatabaseName],
|
||||
strictSelection: false,
|
||||
placeholder: this._defaultDatabaseName,
|
||||
maxHeight: 125,
|
||||
ariaLabel: databaseOption.displayName,
|
||||
actionLabel: localize('connectionWidget.toggleDatabaseNameDropdown', 'Select Database Toggle Dropdown')
|
||||
});
|
||||
if (databaseOption) {
|
||||
let databaseName = DialogHelper.appendRow(this._tableContainer, databaseOption.displayName, 'connection-label', 'connection-input');
|
||||
this._databaseNameInputBox = new Dropdown(databaseName, this._contextViewService, this._layoutService, {
|
||||
values: [this._defaultDatabaseName, this._loadingDatabaseName],
|
||||
strictSelection: false,
|
||||
placeholder: this._defaultDatabaseName,
|
||||
maxHeight: 125,
|
||||
ariaLabel: databaseOption.displayName,
|
||||
actionLabel: localize('connectionWidget.toggleDatabaseNameDropdown', 'Select Database Toggle Dropdown')
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private addServerGroupOption(): void {
|
||||
// Server group
|
||||
let serverGroup = DialogHelper.appendRow(this._tableContainer, this._serverGroupDisplayString, 'connection-label', 'connection-input');
|
||||
DialogHelper.appendInputSelectBox(serverGroup, this._serverGroupSelectBox);
|
||||
if (this._serverGroupSelectBox) {
|
||||
let serverGroup = DialogHelper.appendRow(this._tableContainer, this._serverGroupDisplayString, 'connection-label', 'connection-input');
|
||||
DialogHelper.appendInputSelectBox(serverGroup, this._serverGroupSelectBox);
|
||||
}
|
||||
}
|
||||
|
||||
protected addConnectionNameOptions(): void {
|
||||
// Connection name
|
||||
let connectionNameOption = this._optionsMaps[ConnectionOptionSpecialType.connectionName];
|
||||
connectionNameOption.displayName = localize('connectionName', 'Name (optional)');
|
||||
let connectionNameBuilder = DialogHelper.appendRow(this._tableContainer, connectionNameOption.displayName, 'connection-label', 'connection-input');
|
||||
this._connectionNameInputBox = new InputBox(connectionNameBuilder, this._contextViewService, { ariaLabel: connectionNameOption.displayName });
|
||||
}
|
||||
|
||||
protected addAdvancedOptions(): void {
|
||||
let AdvancedLabel = localize('advanced', 'Advanced...');
|
||||
this._advancedButton = this.createAdvancedButton(this._tableContainer, AdvancedLabel);
|
||||
}
|
||||
@@ -254,7 +291,7 @@ export class ConnectionWidget {
|
||||
return false;
|
||||
}
|
||||
|
||||
private createAdvancedButton(container: HTMLElement, title: string): Button {
|
||||
protected createAdvancedButton(container: HTMLElement, title: string): Button {
|
||||
let rowContainer = DOM.append(container, DOM.$('tr'));
|
||||
DOM.append(rowContainer, DOM.$('td'));
|
||||
let cellContainer = DOM.append(rowContainer, DOM.$('td'));
|
||||
@@ -276,17 +313,49 @@ export class ConnectionWidget {
|
||||
return new Checkbox(checkboxContainer, { label, checked: isChecked, ariaLabel: label });
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
protected 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._serverGroupSelectBox) {
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._serverGroupSelectBox, this._themeService));
|
||||
this._toDispose.push(this._serverGroupSelectBox.onDidSelect(selectedGroup => {
|
||||
this.onGroupSelected(selectedGroup.selected);
|
||||
}));
|
||||
}
|
||||
if (this._databaseNameInputBox) {
|
||||
this._toDispose.push(styler.attachEditableDropdownStyler(this._databaseNameInputBox, this._themeService));
|
||||
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;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (this._authTypeSelectBox) {
|
||||
// Theme styler
|
||||
@@ -321,10 +390,6 @@ export class ConnectionWidget {
|
||||
}));
|
||||
}
|
||||
|
||||
this._toDispose.push(this._serverGroupSelectBox.onDidSelect(selectedGroup => {
|
||||
this.onGroupSelected(selectedGroup.selected);
|
||||
}));
|
||||
|
||||
this._toDispose.push(this._serverNameInputBox.onDidChange(serverName => {
|
||||
this.serverNameChanged(serverName);
|
||||
}));
|
||||
@@ -336,33 +401,6 @@ export class ConnectionWidget {
|
||||
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) {
|
||||
@@ -376,7 +414,7 @@ export class ConnectionWidget {
|
||||
}
|
||||
|
||||
private setConnectButton(): void {
|
||||
let showUsernameAndPassword: boolean = true;
|
||||
let showUsernameAndPassword: boolean;
|
||||
if (this.authType) {
|
||||
showUsernameAndPassword = this.authType === AuthenticationType.SqlLogin;
|
||||
}
|
||||
@@ -384,7 +422,7 @@ export class ConnectionWidget {
|
||||
this._callbacks.onSetConnectButton(!!this.serverName);
|
||||
}
|
||||
|
||||
private onAuthTypeSelected(selectedAuthType: string) {
|
||||
protected onAuthTypeSelected(selectedAuthType: string) {
|
||||
let currentAuthType = this.getMatchingAuthType(selectedAuthType);
|
||||
if (currentAuthType !== AuthenticationType.SqlLogin) {
|
||||
this._userNameInputBox.disable();
|
||||
@@ -504,16 +542,20 @@ export class ConnectionWidget {
|
||||
}
|
||||
|
||||
public focusOnServerGroup() {
|
||||
this._serverGroupSelectBox.focus();
|
||||
if (this._serverGroupSelectBox) {
|
||||
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;
|
||||
if (this._serverGroupSelectBox) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,13 +583,15 @@ export class ConnectionWidget {
|
||||
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;
|
||||
if (this._databaseNameInputBox) {
|
||||
this._databaseNameInputBox.value = this.getModelValue(connectionInfo.databaseName);
|
||||
}
|
||||
let groupName: string;
|
||||
if (this._saveProfile) {
|
||||
if (!connectionInfo.groupFullName) {
|
||||
@@ -558,8 +602,10 @@ export class ConnectionWidget {
|
||||
} else {
|
||||
groupName = this.NoneServerGroup.name;
|
||||
}
|
||||
this._serverGroupSelectBox.selectWithOptionName(groupName);
|
||||
this._previousGroupOption = this._serverGroupSelectBox.value;
|
||||
if (this._serverGroupSelectBox) {
|
||||
this._serverGroupSelectBox.selectWithOptionName(groupName);
|
||||
this._previousGroupOption = this._serverGroupSelectBox.value;
|
||||
}
|
||||
|
||||
// To handle the empty password case
|
||||
if (this.getModelValue(connectionInfo.password) === '') {
|
||||
@@ -604,7 +650,7 @@ export class ConnectionWidget {
|
||||
}
|
||||
}
|
||||
|
||||
private getAuthTypeDisplayName(authTypeName: string) {
|
||||
protected getAuthTypeDisplayName(authTypeName: string) {
|
||||
let displayName: string;
|
||||
let authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType];
|
||||
|
||||
@@ -632,14 +678,17 @@ export class ConnectionWidget {
|
||||
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._serverGroupSelectBox) {
|
||||
this._serverGroupSelectBox.disable();
|
||||
}
|
||||
if (this._databaseNameInputBox) {
|
||||
this._databaseNameInputBox.enabled = false;
|
||||
}
|
||||
if (this._authTypeSelectBox) {
|
||||
this._authTypeSelectBox.disable();
|
||||
}
|
||||
@@ -647,11 +696,9 @@ export class ConnectionWidget {
|
||||
|
||||
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();
|
||||
@@ -667,6 +714,14 @@ export class ConnectionWidget {
|
||||
if (this._focusedBeforeHandleOnConnection) {
|
||||
this._focusedBeforeHandleOnConnection.focus();
|
||||
}
|
||||
|
||||
if (this._serverGroupSelectBox) {
|
||||
this._serverGroupSelectBox.enable();
|
||||
}
|
||||
|
||||
if (this._databaseNameInputBox) {
|
||||
this._databaseNameInputBox.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public get connectionName(): string {
|
||||
@@ -678,7 +733,7 @@ export class ConnectionWidget {
|
||||
}
|
||||
|
||||
public get databaseName(): string {
|
||||
return this._databaseNameInputBox.value;
|
||||
return this._databaseNameInputBox ? this._databaseNameInputBox.value : undefined;
|
||||
}
|
||||
|
||||
public get userName(): string {
|
||||
@@ -742,24 +797,26 @@ export class ConnectionWidget {
|
||||
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);
|
||||
model.connectionName = this.connectionName;
|
||||
model.databaseName = this.databaseName;
|
||||
if (this._serverGroupSelectBox) {
|
||||
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;
|
||||
@@ -814,7 +871,7 @@ export class ConnectionWidget {
|
||||
}
|
||||
}
|
||||
|
||||
enum AuthenticationType {
|
||||
export enum AuthenticationType {
|
||||
SqlLogin = 'SqlLogin',
|
||||
Integrated = 'Integrated',
|
||||
AzureMFA = 'AzureMFA'
|
||||
|
||||
Reference in New Issue
Block a user