mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 09:59:47 -05:00
Feature/ext connection dialog (#2201)
* Connection Dialog API for extensions
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import { ExtHostConnectionManagementShape, SqlMainContext, MainThreadConnectionManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import * as sqlops from 'sqlops';
|
||||
|
||||
export class ExtHostConnectionManagement extends ExtHostConnectionManagementShape {
|
||||
@@ -31,6 +32,10 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
|
||||
return this._proxy.$getCredentials(connectionId);
|
||||
}
|
||||
|
||||
public $openConnectionDialog(providers?: string[]): Thenable<sqlops.connection.Connection> {
|
||||
return this._proxy.$openConnectionDialog(providers);
|
||||
}
|
||||
|
||||
public $listDatabases(connectionId: string): Thenable<string[]> {
|
||||
return this._proxy.$listDatabases(connectionId);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { SqlExtHostContext, SqlMainContext, ExtHostConnectionManagementShape, Ma
|
||||
import * as sqlops from 'sqlops';
|
||||
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IConnectionManagementService, IConnectionDialogService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IObjectExplorerService } from 'sql/parts/objectExplorer/common/objectExplorerService';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import * as TaskUtilities from 'sql/workbench/common/taskUtilities';
|
||||
@@ -25,7 +25,8 @@ export class MainThreadConnectionManagement implements MainThreadConnectionManag
|
||||
extHostContext: IExtHostContext,
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
|
||||
@IWorkbenchEditorService private _workbenchEditorService: IWorkbenchEditorService
|
||||
@IWorkbenchEditorService private _workbenchEditorService: IWorkbenchEditorService,
|
||||
@IConnectionDialogService private _connectionDialogService: IConnectionDialogService,
|
||||
) {
|
||||
if (extHostContext) {
|
||||
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostConnectionManagement);
|
||||
@@ -49,6 +50,16 @@ export class MainThreadConnectionManagement implements MainThreadConnectionManag
|
||||
return Promise.resolve(this._connectionManagementService.getActiveConnectionCredentials(connectionId));
|
||||
}
|
||||
|
||||
|
||||
public async $openConnectionDialog(providers: string[]): Promise<sqlops.connection.Connection> {
|
||||
let connectionProfile = await this._connectionDialogService.openDialogAndWait(this._connectionManagementService, { connectionType: 1, providers: providers });
|
||||
return connectionProfile ? {
|
||||
connectionId: connectionProfile.id,
|
||||
options: connectionProfile.options,
|
||||
providerName: connectionProfile.providerName
|
||||
} : undefined;
|
||||
}
|
||||
|
||||
public async $listDatabases(connectionId: string): Promise<string[]> {
|
||||
let connection = this._connectionManagementService.getActiveConnections().find(profile => profile.id === connectionId);
|
||||
let connectionUri = this._connectionManagementService.getConnectionUri(connection);
|
||||
|
||||
@@ -104,6 +104,9 @@ export function createApiFactory(
|
||||
getCredentials(connectionId: string): Thenable<{ [name: string]: string }> {
|
||||
return extHostConnectionManagement.$getCredentials(connectionId);
|
||||
},
|
||||
openConnectionDialog(providers?: string[]): Thenable<sqlops.connection.Connection> {
|
||||
return extHostConnectionManagement.$openConnectionDialog(providers);
|
||||
},
|
||||
listDatabases(connectionId: string): Thenable<string[]> {
|
||||
return extHostConnectionManagement.$listDatabases(connectionId);
|
||||
},
|
||||
|
||||
@@ -33,7 +33,9 @@ export abstract class ExtHostAccountManagementShape {
|
||||
$refresh(handle: number, account: sqlops.Account): Thenable<sqlops.Account> { throw ni(); }
|
||||
}
|
||||
|
||||
export abstract class ExtHostConnectionManagementShape { }
|
||||
export abstract class ExtHostConnectionManagementShape {
|
||||
$onConnectionOpened(handleId: string, connection: sqlops.connection.Connection): void { throw ni; }
|
||||
}
|
||||
|
||||
export abstract class ExtHostDataProtocolShape {
|
||||
|
||||
@@ -491,6 +493,7 @@ export interface MainThreadConnectionManagementShape extends IDisposable {
|
||||
$getActiveConnections(): Thenable<sqlops.connection.Connection[]>;
|
||||
$getCurrentConnection(): Thenable<sqlops.connection.Connection>;
|
||||
$getCredentials(connectionId: string): Thenable<{ [name: string]: string }>;
|
||||
$openConnectionDialog(providers: string[]): Thenable<sqlops.connection.Connection>;
|
||||
$listDatabases(connectionId: string): Thenable<string[]>;
|
||||
$getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
|
||||
$getUriForConnection(connectionId: string): Thenable<string>;
|
||||
|
||||
Reference in New Issue
Block a user