mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Feature/ext connection dialog (#2201)
* Connection Dialog API for extensions
This commit is contained in:
@@ -59,6 +59,7 @@ export interface IConnectionResult {
|
||||
errorCode: number;
|
||||
callStack: string;
|
||||
errorHandled?: boolean;
|
||||
connectionProfile?: IConnectionProfile;
|
||||
}
|
||||
|
||||
export interface IConnectionCallbacks {
|
||||
@@ -130,15 +131,15 @@ export interface IConnectionManagementService {
|
||||
|
||||
onConnectionChangedNotification(handle: number, changedConnInfo: sqlops.ChangedConnectionInfo);
|
||||
|
||||
getConnectionGroups(): ConnectionProfileGroup[];
|
||||
getConnectionGroups(providers?: string[]): ConnectionProfileGroup[];
|
||||
|
||||
getRecentConnections(): ConnectionProfile[];
|
||||
getRecentConnections(providers?: string[]): ConnectionProfile[];
|
||||
|
||||
clearRecentConnectionsList(): void;
|
||||
|
||||
clearRecentConnection(connectionProfile: IConnectionProfile): void;
|
||||
|
||||
getActiveConnections(): ConnectionProfile[];
|
||||
getActiveConnections(providers?: string[]): ConnectionProfile[];
|
||||
|
||||
saveProfileGroup(profile: IConnectionProfileGroup): Promise<string>;
|
||||
|
||||
@@ -270,7 +271,24 @@ export interface IConnectionManagementService {
|
||||
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>;
|
||||
}
|
||||
|
||||
export interface IServerGroupDialogCallbacks {
|
||||
@@ -304,6 +322,7 @@ export interface INewConnectionParams {
|
||||
runQueryOnCompletion?: RunQueryOnConnectionMode;
|
||||
querySelection?: sqlops.ISelectionData;
|
||||
showDashboard?: boolean;
|
||||
providers?: string[];
|
||||
}
|
||||
|
||||
export interface IConnectableInput {
|
||||
|
||||
@@ -627,12 +627,12 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
}
|
||||
}
|
||||
|
||||
public getConnectionGroups(): ConnectionProfileGroup[] {
|
||||
return this._connectionStore.getConnectionProfileGroups();
|
||||
public getConnectionGroups(providers?: string[]): ConnectionProfileGroup[] {
|
||||
return this._connectionStore.getConnectionProfileGroups(false, providers);
|
||||
}
|
||||
|
||||
public getRecentConnections(): ConnectionProfile[] {
|
||||
return this._connectionStore.getRecentlyUsedConnections();
|
||||
public getRecentConnections(providers?: string[]): ConnectionProfile[] {
|
||||
return this._connectionStore.getRecentlyUsedConnections(providers);
|
||||
}
|
||||
|
||||
|
||||
@@ -644,7 +644,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
this._connectionStore.removeConnectionToMemento(connectionProfile, Constants.recentConnections);
|
||||
}
|
||||
|
||||
public getActiveConnections(): ConnectionProfile[] {
|
||||
public getActiveConnections(providers?: string[]): ConnectionProfile[] {
|
||||
return this._connectionStatusManager.getActiveConnectionProfiles();
|
||||
}
|
||||
|
||||
@@ -1002,14 +1002,14 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
let connectionMngInfo = this._connectionStatusManager.findConnection(uri);
|
||||
if (connectionMngInfo && connectionMngInfo.deleted) {
|
||||
this._connectionStatusManager.deleteConnection(uri);
|
||||
resolve({ connected: connectResult, errorMessage: undefined, errorCode: undefined, callStack: undefined, errorHandled: true });
|
||||
resolve({ connected: connectResult, errorMessage: undefined, errorCode: undefined, callStack: undefined, errorHandled: true, connectionProfile: connection });
|
||||
} else {
|
||||
if (errorMessage) {
|
||||
// Connection to the server failed
|
||||
this._connectionStatusManager.deleteConnection(uri);
|
||||
resolve({ connected: connectResult, errorMessage: errorMessage, errorCode: errorCode, callStack: callStack });
|
||||
resolve({ connected: connectResult, errorMessage: errorMessage, errorCode: errorCode, callStack: callStack, connectionProfile: connection });
|
||||
} else {
|
||||
resolve({ connected: connectResult, errorMessage: errorMessage, errorCode: errorCode, callStack: callStack });
|
||||
resolve({ connected: connectResult, errorMessage: errorMessage, errorCode: errorCode, callStack: callStack, connectionProfile: connection });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -193,9 +193,14 @@ export class ConnectionStatusManager {
|
||||
/**
|
||||
* Get a list of the active connection profiles managed by the status manager
|
||||
*/
|
||||
public getActiveConnectionProfiles(): ConnectionProfile[] {
|
||||
public getActiveConnectionProfiles(providers?: string[]): ConnectionProfile[] {
|
||||
let profiles = Object.values(this._connections).map((connectionInfo: ConnectionManagementInfo) => connectionInfo.connectionProfile);
|
||||
// Remove duplicate profiles that may be listed multiple times under different URIs by filtering for profiles that don't have the same ID as an earlier profile in the list
|
||||
return profiles.filter((profile, index) => profiles.findIndex(otherProfile => otherProfile.id === profile.id) === index);
|
||||
profiles = profiles.filter((profile, index) => profiles.findIndex(otherProfile => otherProfile.id === profile.id) === index);
|
||||
|
||||
if (providers) {
|
||||
profiles = profiles.filter(f => providers.includes(f.providerName));
|
||||
}
|
||||
return profiles;
|
||||
}
|
||||
}
|
||||
@@ -213,13 +213,16 @@ export class ConnectionStore {
|
||||
*
|
||||
* @returns {sqlops.ConnectionInfo} the array of connections, empty if none are found
|
||||
*/
|
||||
public getRecentlyUsedConnections(): ConnectionProfile[] {
|
||||
public getRecentlyUsedConnections(providers?: string[]): ConnectionProfile[] {
|
||||
let configValues: IConnectionProfile[] = this._memento[Constants.recentConnections];
|
||||
if (!configValues) {
|
||||
configValues = [];
|
||||
}
|
||||
|
||||
configValues = configValues.filter(c => !!(c));
|
||||
if (providers && providers.length > 0) {
|
||||
configValues = configValues.filter(c => providers.includes(c.providerName));
|
||||
}
|
||||
return this.convertConfigValuesToConnectionProfiles(configValues);
|
||||
}
|
||||
|
||||
@@ -429,10 +432,13 @@ export class ConnectionStore {
|
||||
});
|
||||
}
|
||||
|
||||
public getConnectionProfileGroups(withoutConnections?: boolean): ConnectionProfileGroup[] {
|
||||
public getConnectionProfileGroups(withoutConnections?: boolean, providers?: string[]): ConnectionProfileGroup[] {
|
||||
let profilesInConfiguration: ConnectionProfile[];
|
||||
if (!withoutConnections) {
|
||||
profilesInConfiguration = this._connectionConfig.getConnections(true);
|
||||
if (providers && providers.length > 0) {
|
||||
profilesInConfiguration = profilesInConfiguration.filter(x => providers.includes(x.providerName));
|
||||
}
|
||||
}
|
||||
let groups = this._connectionConfig.getAllGroups();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user