Enable the support for post-connection behaviors for openConnectionDialog (#2455)

* Enable the support for post-connection behaviors for openConnectionDialog.

* Fixed bugs.

* Make everything in IConnectionCompletionOptions optional except saveConnection.

* showConnectionDialogOnError & showFirewallRuleOnError default to true.

* Use types.isUndefinedOrNull to do value checking.

* Minor changes.
This commit is contained in:
Vincent Feng
2018-09-08 01:08:18 +08:00
committed by GitHub
parent 10f05e75ce
commit ba91140ea5
6 changed files with 55 additions and 8 deletions

View File

@@ -14,6 +14,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import * as TaskUtilities from 'sql/workbench/common/taskUtilities';
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { isUndefinedOrNull } from 'vs/base/common/types';
@extHostNamedCustomer(SqlMainContext.MainThreadConnectionManagement)
export class MainThreadConnectionManagement implements MainThreadConnectionManagementShape {
@@ -51,13 +52,27 @@ export class MainThreadConnectionManagement implements MainThreadConnectionManag
}
public async $openConnectionDialog(providers: string[], initialConnectionProfile?: IConnectionProfile): Promise<sqlops.connection.Connection> {
public async $openConnectionDialog(providers: string[], initialConnectionProfile?: IConnectionProfile, connectionCompletionOptions?: sqlops.IConnectionCompletionOptions): Promise<sqlops.connection.Connection> {
let connectionProfile = await this._connectionDialogService.openDialogAndWait(this._connectionManagementService, { connectionType: 1, providers: providers }, initialConnectionProfile);
return connectionProfile ? {
const connection = connectionProfile ? {
connectionId: connectionProfile.id,
options: connectionProfile.options,
providerName: connectionProfile.providerName
} : undefined;
if (connectionCompletionOptions) {
// Somehow, connectionProfile.saveProfile is false even if initialConnectionProfile.saveProfile is true, reset the flag here.
connectionProfile.saveProfile = initialConnectionProfile.saveProfile;
await this._connectionManagementService.connectAndSaveProfile(connectionProfile, undefined, {
saveTheConnection: isUndefinedOrNull(connectionCompletionOptions.saveConnection) ? true : connectionCompletionOptions.saveConnection,
showDashboard: isUndefinedOrNull(connectionCompletionOptions.showDashboard) ? false : connectionCompletionOptions.showDashboard,
params: undefined,
showConnectionDialogOnError: isUndefinedOrNull(connectionCompletionOptions.showConnectionDialogOnError) ? true : connectionCompletionOptions.showConnectionDialogOnError,
showFirewallRuleOnError: isUndefinedOrNull(connectionCompletionOptions.showFirewallRuleOnError) ? true : connectionCompletionOptions.showFirewallRuleOnError
});
}
return connection;
}
public async $listDatabases(connectionId: string): Promise<string[]> {