mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
show proper message when extension is not installed for a connection provider (#19377)
* show extension not installed error * extension provider mapping * fix tests
This commit is contained in:
@@ -20,6 +20,16 @@ export const clientCapabilities = {
|
|||||||
hostVersion: HOST_VERSION
|
hostVersion: HOST_VERSION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
export const ConnectionProviderAndExtensionMap = new Map<string, string>([
|
||||||
|
['PGSQL', 'microsoft.azuredatastudio-postgresql'],
|
||||||
|
['KUSTO', 'microsoft.kusto'],
|
||||||
|
['LOGANALYTICS', 'microsoft.azuremonitor']
|
||||||
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The connection string options for connection provider.
|
* The connection string options for connection provider.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -43,7 +43,11 @@ import { AsyncServerTree } from 'sql/workbench/services/objectExplorer/browser/a
|
|||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
import { ConnectionBrowseTab } from 'sql/workbench/services/connection/browser/connectionBrowseTab';
|
import { ConnectionBrowseTab } from 'sql/workbench/services/connection/browser/connectionBrowseTab';
|
||||||
import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserver';
|
import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserver';
|
||||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ConnectionProviderAndExtensionMap, ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
|
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||||
|
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||||
|
import { VIEWLET_ID as ExtensionsViewletID } from 'vs/workbench/contrib/extensions/common/extensions';
|
||||||
|
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||||
|
|
||||||
export interface OnShowUIResponse {
|
export interface OnShowUIResponse {
|
||||||
selectedProviderDisplayName: string;
|
selectedProviderDisplayName: string;
|
||||||
@@ -124,7 +128,10 @@ export class ConnectionDialogWidget extends Modal {
|
|||||||
@ILogService logService: ILogService,
|
@ILogService logService: ILogService,
|
||||||
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService,
|
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService,
|
||||||
@IConfigurationService private _configurationService: IConfigurationService,
|
@IConfigurationService private _configurationService: IConfigurationService,
|
||||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService
|
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
||||||
|
@INotificationService private _notificationService: INotificationService,
|
||||||
|
@IViewletService private _viewletService: IViewletService,
|
||||||
|
@ICommandService private _commandService: ICommandService
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
localize('connection', "Connection"),
|
localize('connection', "Connection"),
|
||||||
@@ -392,10 +399,37 @@ export class ConnectionDialogWidget extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onConnectionClick(element: IConnectionProfile, connect: boolean = false): void {
|
private onConnectionClick(element: IConnectionProfile, connect: boolean = false): void {
|
||||||
if (connect) {
|
const isProviderAvailable = this._capabilitiesService.providers[element.providerName] !== undefined;
|
||||||
this.connect(element);
|
if (isProviderAvailable) {
|
||||||
} else {
|
if (connect) {
|
||||||
this._onFillinConnectionInputs.fire(element);
|
this.connect(element);
|
||||||
|
} else {
|
||||||
|
this._onFillinConnectionInputs.fire(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const extensionId = ConnectionProviderAndExtensionMap.get(element.providerName);
|
||||||
|
if (extensionId) {
|
||||||
|
this._notificationService.prompt(Severity.Error,
|
||||||
|
localize('connectionDialog.extensionNotInstalled', "The extension '{0}' is required in order to connect to this resource. Please install it and try again.", extensionId),
|
||||||
|
[{
|
||||||
|
label: localize('connectionDialog.viewExtension', "View Extension"),
|
||||||
|
run: async () => {
|
||||||
|
this.close();
|
||||||
|
await this._commandService.executeCommand('extension.open', extensionId);
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
} else {
|
||||||
|
this._notificationService.prompt(Severity.Error,
|
||||||
|
localize('connectionDialog.connectionProviderNotSupported', "The extension that supports provider type '{0}' is not currently installed. Please install it and try again.", element.providerName),
|
||||||
|
[{
|
||||||
|
label: localize('connectionDialog.viewExtensions', "View Extensions"),
|
||||||
|
run: async () => {
|
||||||
|
this.close();
|
||||||
|
await this._viewletService.openViewlet(ExtensionsViewletID, true);
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ suite('ConnectionDialogService tests', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
testConnectionDialog = new TestConnectionDialogWidget(providerDisplayNames, providerNameToDisplayMap['MSSQL'], providerNameToDisplayMap, testInstantiationService, mockConnectionManagementService.object, undefined, undefined, viewDescriptorService, new TestThemeService(), new TestLayoutService(), new NullAdsTelemetryService(), new MockContextKeyService(), undefined, new NullLogService(), new TestTextResourcePropertiesService(new TestConfigurationService), new TestConfigurationService(), new TestCapabilitiesService());
|
testConnectionDialog = new TestConnectionDialogWidget(providerDisplayNames, providerNameToDisplayMap['MSSQL'], providerNameToDisplayMap, testInstantiationService, mockConnectionManagementService.object, undefined, undefined, viewDescriptorService, new TestThemeService(), new TestLayoutService(), new NullAdsTelemetryService(), new MockContextKeyService(), undefined, new NullLogService(), new TestTextResourcePropertiesService(new TestConfigurationService), new TestConfigurationService(), new TestCapabilitiesService(), undefined, undefined, undefined);
|
||||||
testConnectionDialog.render();
|
testConnectionDialog.render();
|
||||||
testConnectionDialog['renderBody'](DOM.createStyleSheet());
|
testConnectionDialog['renderBody'](DOM.createStyleSheet());
|
||||||
(connectionDialogService as any)._connectionDialog = testConnectionDialog;
|
(connectionDialogService as any)._connectionDialog = testConnectionDialog;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ suite('ConnectionDialogWidget tests', () => {
|
|||||||
new TestCapabilitiesService());
|
new TestCapabilitiesService());
|
||||||
let providerDisplayNames = ['Mock SQL Server'];
|
let providerDisplayNames = ['Mock SQL Server'];
|
||||||
let providerNameToDisplayMap = { 'MSSQL': 'Mock SQL Server' };
|
let providerNameToDisplayMap = { 'MSSQL': 'Mock SQL Server' };
|
||||||
connectionDialogWidget = new TestConnectionDialogWidget(providerDisplayNames, providerNameToDisplayMap['MSSQL'], providerNameToDisplayMap, cmInstantiationService, mockConnectionManagementService.object, undefined, undefined, viewDescriptorService, new TestThemeService(), new TestLayoutService(), new NullAdsTelemetryService(), new MockContextKeyService(), undefined, new NullLogService(), new TestTextResourcePropertiesService(new TestConfigurationService()), new TestConfigurationService(), new TestCapabilitiesService());
|
connectionDialogWidget = new TestConnectionDialogWidget(providerDisplayNames, providerNameToDisplayMap['MSSQL'], providerNameToDisplayMap, cmInstantiationService, mockConnectionManagementService.object, undefined, undefined, viewDescriptorService, new TestThemeService(), new TestLayoutService(), new NullAdsTelemetryService(), new MockContextKeyService(), undefined, new NullLogService(), new TestTextResourcePropertiesService(new TestConfigurationService()), new TestConfigurationService(), new TestCapabilitiesService(), undefined, undefined, undefined);
|
||||||
element = DOM.createStyleSheet();
|
element = DOM.createStyleSheet();
|
||||||
connectionDialogWidget.render();
|
connectionDialogWidget.render();
|
||||||
connectionDialogWidget['renderBody'](element);
|
connectionDialogWidget['renderBody'](element);
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ import { ITextResourcePropertiesService } from 'vs/editor/common/services/textRe
|
|||||||
import { IViewDescriptorService } from 'vs/workbench/common/views';
|
import { IViewDescriptorService } from 'vs/workbench/common/views';
|
||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
|
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||||
|
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||||
|
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||||
|
|
||||||
export class TestConnectionDialogWidget extends ConnectionDialogWidget {
|
export class TestConnectionDialogWidget extends ConnectionDialogWidget {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -36,8 +39,11 @@ export class TestConnectionDialogWidget extends ConnectionDialogWidget {
|
|||||||
@ILogService logService: ILogService,
|
@ILogService logService: ILogService,
|
||||||
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService,
|
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService,
|
||||||
@IConfigurationService configurationService: IConfigurationService,
|
@IConfigurationService configurationService: IConfigurationService,
|
||||||
@ICapabilitiesService capabilitiesService: ICapabilitiesService
|
@ICapabilitiesService capabilitiesService: ICapabilitiesService,
|
||||||
|
@INotificationService notificationService: INotificationService,
|
||||||
|
@IViewletService viewletService: IViewletService,
|
||||||
|
@ICommandService commandService: ICommandService
|
||||||
) {
|
) {
|
||||||
super(providerDisplayNameOptions, selectedProviderType, providerNameToDisplayNameMap, _instantiationService, _connectionManagementService, _contextMenuService, _contextViewService, themeService, layoutService, telemetryService, contextKeyService, clipboardService, logService, textResourcePropertiesService, configurationService, capabilitiesService);
|
super(providerDisplayNameOptions, selectedProviderType, providerNameToDisplayNameMap, _instantiationService, _connectionManagementService, _contextMenuService, _contextViewService, themeService, layoutService, telemetryService, contextKeyService, clipboardService, logService, textResourcePropertiesService, configurationService, capabilitiesService, notificationService, viewletService, commandService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user