mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
make connectiondialog react to provider event (#4544)
* make connectiondialog react to provider event * fix unit test error * code review comments
This commit is contained in:
@@ -89,7 +89,38 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
@IWorkspaceConfigurationService private _workspaceConfigurationService: IWorkspaceConfigurationService,
|
@IWorkspaceConfigurationService private _workspaceConfigurationService: IWorkspaceConfigurationService,
|
||||||
@IClipboardService private _clipboardService: IClipboardService,
|
@IClipboardService private _clipboardService: IClipboardService,
|
||||||
@ICommandService private _commandService: ICommandService
|
@ICommandService private _commandService: ICommandService
|
||||||
) { }
|
) {
|
||||||
|
this.initializeConnectionProviders();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the initial value for the connection provider and listen to the provider change event
|
||||||
|
*/
|
||||||
|
private initializeConnectionProviders() {
|
||||||
|
this.setConnectionProviders();
|
||||||
|
if (this._capabilitiesService) {
|
||||||
|
this._capabilitiesService.onCapabilitiesRegistered(() => {
|
||||||
|
this.setConnectionProviders();
|
||||||
|
if (this._connectionDialog) {
|
||||||
|
this._connectionDialog.updateConnectionProviders(this._providerTypes, this._providerNameToDisplayNameMap);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the available provider types using the values from capabilities service
|
||||||
|
*/
|
||||||
|
private setConnectionProviders() {
|
||||||
|
if (this._capabilitiesService) {
|
||||||
|
this._providerTypes = [];
|
||||||
|
this._providerNameToDisplayNameMap = {};
|
||||||
|
entries(this._capabilitiesService.providers).forEach(p => {
|
||||||
|
this._providerTypes.push(p[1].connection.displayName);
|
||||||
|
this._providerNameToDisplayNameMap[p[0]] = p[1].connection.displayName;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default provider with the following actions
|
* Gets the default provider with the following actions
|
||||||
@@ -350,13 +381,6 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
this._inputModel = model;
|
this._inputModel = model;
|
||||||
|
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
// only create the provider maps first time the dialog gets called
|
|
||||||
if (this._providerTypes.length === 0) {
|
|
||||||
entries(this._capabilitiesService.providers).forEach(p => {
|
|
||||||
this._providerTypes.push(p[1].connection.displayName);
|
|
||||||
this._providerNameToDisplayNameMap[p[0]] = p[1].connection.displayName;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.updateModelServerCapabilities(model);
|
this.updateModelServerCapabilities(model);
|
||||||
// If connecting from a query editor set "save connection" to false
|
// If connecting from a query editor set "save connection" to false
|
||||||
if (params && params.input && params.connectionType === ConnectionType.editor) {
|
if (params && params.input && params.connectionType === ConnectionType.editor) {
|
||||||
|
|||||||
@@ -102,6 +102,17 @@ export class ConnectionDialogWidget extends Modal {
|
|||||||
super(localize('connection', 'Connection'), TelemetryKeys.Connection, _partService, telemetryService, clipboardService, _workbenchThemeService, contextKeyService, { hasSpinner: true, hasErrors: true });
|
super(localize('connection', 'Connection'), TelemetryKeys.Connection, _partService, telemetryService, clipboardService, _workbenchThemeService, contextKeyService, { hasSpinner: true, hasErrors: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the available connection providers, this is called when new providers are registered
|
||||||
|
* So that the connection type dropdown always has up to date values
|
||||||
|
*/
|
||||||
|
public updateConnectionProviders(providerTypeOptions: string[],
|
||||||
|
providerNameToDisplayNameMap: { [providerDisplayName: string]: string }) {
|
||||||
|
this.providerTypeOptions = providerTypeOptions;
|
||||||
|
this.providerNameToDisplayNameMap = providerNameToDisplayNameMap;
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
public refresh(): void {
|
public refresh(): void {
|
||||||
let filteredProviderTypes = this.providerTypeOptions;
|
let filteredProviderTypes = this.providerTypeOptions;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user