diff --git a/src/sql/platform/capabilities/common/capabilitiesService.ts b/src/sql/platform/capabilities/common/capabilitiesService.ts index 65e14257ce..713ba92836 100644 --- a/src/sql/platform/capabilities/common/capabilitiesService.ts +++ b/src/sql/platform/capabilities/common/capabilitiesService.ts @@ -23,6 +23,8 @@ export const clientCapabilities = { /** * The map containing the connection provider names and the owning extensions. * This is to workaround the issue that we don't have the ability to store and query the information from extension gallery. + * IMPORTANT : Every extension in this list is assumed to be directly installable (not 3rd party). If that changes then + * handleUnsupportedProvider needs to be updated to handle those cases. */ export const ConnectionProviderAndExtensionMap = new Map([ ['PGSQL', 'microsoft.azuredatastudio-postgresql'], diff --git a/src/sql/platform/connection/common/connectionManagement.ts b/src/sql/platform/connection/common/connectionManagement.ts index f6b7ae2cd1..11020422b0 100644 --- a/src/sql/platform/connection/common/connectionManagement.ts +++ b/src/sql/platform/connection/common/connectionManagement.ts @@ -324,10 +324,10 @@ export interface IConnectionManagementService { /** * Handle the unsupported provider scenario. - * @param providerName The provider name. + * @param providerId The provider ID * @returns Promise with a boolean value indicating whether the user has accepted the suggestion. */ - handleUnsupportedProvider(providerName: string): Promise; + handleUnsupportedProvider(providerId: string): Promise; } export enum RunQueryOnConnectionMode { diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index b807f115d0..5c99d584db 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -1658,17 +1658,28 @@ export class ConnectionManagementService extends Disposable implements IConnecti return connections; } - async handleUnsupportedProvider(providerName: string): Promise { - const extensionId = ConnectionProviderAndExtensionMap.get(providerName); + public async handleUnsupportedProvider(providerId: string): Promise { + const extensionId = ConnectionProviderAndExtensionMap.get(providerId); const message = extensionId ? nls.localize('connection.extensionNotInstalled', "The extension '{0}' is required in order to connect to this resource. Do you want to install it?", extensionId) : - nls.localize('connectionDialog.connectionProviderNotSupported', "The extension that supports provider type '{0}' is not currently installed. Do you want to view the extensions?", providerName); + nls.localize('connectionDialog.connectionProviderNotSupported', "The extension that supports provider type '{0}' is not currently installed. Do you want to view the extensions?", providerId); const result = await this._dialogService.confirm({ message: message, type: 'question' }); if (result.confirmed) { if (extensionId) { - await this._commandService.executeCommand('extension.open', extensionId); + const providerRegistered = new Promise(resolve => { + const eventHandler = this._capabilitiesService.onCapabilitiesRegistered(e => { + if (e.id === providerId) { + resolve(); + eventHandler.dispose(); + } + }); + }); + // Install the extension and then wait for the provider to be registered to ensure that everything is ready for the caller to use + await this._commandService.executeCommand('workbench.extensions.installExtension', extensionId); + await providerRegistered; + } else { await this._paneCompositePartService.openPaneComposite(ExtensionsViewletID, ViewContainerLocation.Sidebar); }