mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
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:
32
src/sql/sqlops.d.ts
vendored
32
src/sql/sqlops.d.ts
vendored
@@ -209,6 +209,38 @@ declare module 'sqlops' {
|
|||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for the actions that could happen after connecting is complete
|
||||||
|
*/
|
||||||
|
export interface IConnectionCompletionOptions {
|
||||||
|
/**
|
||||||
|
* Save the connection to MRU and settings (only save to setting if profile.saveProfile is set to true)
|
||||||
|
* Default is true.
|
||||||
|
*/
|
||||||
|
saveConnection: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, open the dashboard after connection is complete.
|
||||||
|
* If undefined / false, dashboard won't be opened after connection completes.
|
||||||
|
* Default is false.
|
||||||
|
*/
|
||||||
|
showDashboard?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If undefined / true, open the connection dialog if connection fails.
|
||||||
|
* If false, connection dialog won't be opened even if connection fails.
|
||||||
|
* Default is true.
|
||||||
|
*/
|
||||||
|
showConnectionDialogOnError?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If undefined / true, open the connection firewall rule dialog if connection fails.
|
||||||
|
* If false, connection firewall rule dialog won't be opened even if connection fails.
|
||||||
|
* Default is true.
|
||||||
|
*/
|
||||||
|
showFirewallRuleOnError?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ConnectionInfoSummary {
|
export interface ConnectionInfoSummary {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
src/sql/sqlops.proposed.d.ts
vendored
2
src/sql/sqlops.proposed.d.ts
vendored
@@ -1259,6 +1259,6 @@ declare module 'sqlops' {
|
|||||||
* returns the connection otherwise returns undefined
|
* returns the connection otherwise returns undefined
|
||||||
* @param callback
|
* @param callback
|
||||||
*/
|
*/
|
||||||
export function openConnectionDialog(provider?: string[], initialConnectionProfile?: IConnectionProfile): Thenable<connection.Connection>;
|
export function openConnectionDialog(providers?: string[], initialConnectionProfile?: IConnectionProfile, connectionCompletionOptions?: IConnectionCompletionOptions): Thenable<connection.Connection>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
|
|||||||
return this._proxy.$getCredentials(connectionId);
|
return this._proxy.$getCredentials(connectionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public $openConnectionDialog(providers?: string[], initialConnectionProfile?: sqlops.IConnectionProfile): Thenable<sqlops.connection.Connection> {
|
public $openConnectionDialog(providers?: string[], initialConnectionProfile?: sqlops.IConnectionProfile, connectionCompletionOptions?: sqlops.IConnectionCompletionOptions): Thenable<sqlops.connection.Connection> {
|
||||||
return this._proxy.$openConnectionDialog(providers, initialConnectionProfile);
|
return this._proxy.$openConnectionDialog(providers, initialConnectionProfile, connectionCompletionOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public $listDatabases(connectionId: string): Thenable<string[]> {
|
public $listDatabases(connectionId: string): Thenable<string[]> {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
|
|||||||
import * as TaskUtilities from 'sql/workbench/common/taskUtilities';
|
import * as TaskUtilities from 'sql/workbench/common/taskUtilities';
|
||||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||||
|
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||||
|
|
||||||
@extHostNamedCustomer(SqlMainContext.MainThreadConnectionManagement)
|
@extHostNamedCustomer(SqlMainContext.MainThreadConnectionManagement)
|
||||||
export class MainThreadConnectionManagement implements MainThreadConnectionManagementShape {
|
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);
|
let connectionProfile = await this._connectionDialogService.openDialogAndWait(this._connectionManagementService, { connectionType: 1, providers: providers }, initialConnectionProfile);
|
||||||
return connectionProfile ? {
|
const connection = connectionProfile ? {
|
||||||
connectionId: connectionProfile.id,
|
connectionId: connectionProfile.id,
|
||||||
options: connectionProfile.options,
|
options: connectionProfile.options,
|
||||||
providerName: connectionProfile.providerName
|
providerName: connectionProfile.providerName
|
||||||
} : undefined;
|
} : 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[]> {
|
public async $listDatabases(connectionId: string): Promise<string[]> {
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ export function createApiFactory(
|
|||||||
getCredentials(connectionId: string): Thenable<{ [name: string]: string }> {
|
getCredentials(connectionId: string): Thenable<{ [name: string]: string }> {
|
||||||
return extHostConnectionManagement.$getCredentials(connectionId);
|
return extHostConnectionManagement.$getCredentials(connectionId);
|
||||||
},
|
},
|
||||||
openConnectionDialog(providers?: string[], initialConnectionProfile?: sqlops.IConnectionProfile): Thenable<sqlops.connection.Connection> {
|
openConnectionDialog(providers?: string[], initialConnectionProfile?: sqlops.IConnectionProfile, connectionCompletionOptions?: sqlops.IConnectionCompletionOptions): Thenable<sqlops.connection.Connection> {
|
||||||
return extHostConnectionManagement.$openConnectionDialog(providers, initialConnectionProfile);
|
return extHostConnectionManagement.$openConnectionDialog(providers, initialConnectionProfile, connectionCompletionOptions);
|
||||||
},
|
},
|
||||||
listDatabases(connectionId: string): Thenable<string[]> {
|
listDatabases(connectionId: string): Thenable<string[]> {
|
||||||
return extHostConnectionManagement.$listDatabases(connectionId);
|
return extHostConnectionManagement.$listDatabases(connectionId);
|
||||||
|
|||||||
@@ -503,7 +503,7 @@ export interface MainThreadConnectionManagementShape extends IDisposable {
|
|||||||
$getActiveConnections(): Thenable<sqlops.connection.Connection[]>;
|
$getActiveConnections(): Thenable<sqlops.connection.Connection[]>;
|
||||||
$getCurrentConnection(): Thenable<sqlops.connection.Connection>;
|
$getCurrentConnection(): Thenable<sqlops.connection.Connection>;
|
||||||
$getCredentials(connectionId: string): Thenable<{ [name: string]: string }>;
|
$getCredentials(connectionId: string): Thenable<{ [name: string]: string }>;
|
||||||
$openConnectionDialog(providers: string[], initialConnectionProfile?: sqlops.IConnectionProfile): Thenable<sqlops.connection.Connection>;
|
$openConnectionDialog(providers: string[], initialConnectionProfile?: sqlops.IConnectionProfile, connectionCompletionOptions?: sqlops.IConnectionCompletionOptions): Thenable<sqlops.connection.Connection>;
|
||||||
$listDatabases(connectionId: string): Thenable<string[]>;
|
$listDatabases(connectionId: string): Thenable<string[]>;
|
||||||
$getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
|
$getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
|
||||||
$getUriForConnection(connectionId: string): Thenable<string>;
|
$getUriForConnection(connectionId: string): Thenable<string>;
|
||||||
|
|||||||
Reference in New Issue
Block a user