diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 5699343647..10b3295f81 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -976,4 +976,16 @@ declare module 'azdata' { expiresOn?: number } } + + export interface ConnectionInfoSummary { + /** + * Indicates whether the server version is supported by ADS. The default value is true. If the value is false, ADS will show a warning message. + */ + isSupportedVersion?: boolean; + + /** + * The messages that will be appended to the Azure Data Studio's warning message about unsupported versions. + */ + unsupportedVersionMessage?: string; + } } diff --git a/src/sql/workbench/contrib/connection/browser/connection.contribution.ts b/src/sql/workbench/contrib/connection/browser/connection.contribution.ts index 2dd38f9351..dce70d2ae5 100644 --- a/src/sql/workbench/contrib/connection/browser/connection.contribution.ts +++ b/src/sql/workbench/contrib/connection/browser/connection.contribution.ts @@ -197,6 +197,11 @@ configurationRegistry.registerConfiguration({ 'type': 'boolean', 'default': true, 'description': localize('connection.parseClipboardForConnectionStringDescription', "Attempt to parse the contents of the clipboard when the connection dialog is opened or a paste is performed.") + }, + 'connection.showUnsupportedServerVersionWarning': { + 'type': 'boolean', + 'default': true, + 'description': localize('connection.showUnsupportedServerVersionWarning', "Whether to show the warning message when user connects to a server version that is not supported by Azure Data Studio.") } } }); diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index 2b2963253e..cfe2f212bd 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -42,7 +42,7 @@ import { ILogService } from 'vs/platform/log/common/log'; import * as interfaces from 'sql/platform/connection/common/interfaces'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { Memento, MementoObject } from 'vs/workbench/common/memento'; -import { INotificationService } from 'vs/platform/notification/common/notification'; +import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { entries } from 'sql/base/common/collections'; import { values } from 'vs/base/common/collections'; import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; @@ -72,6 +72,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti private _mementoObj: MementoObject; private _connectionStore: ConnectionStore; private _connectionStatusManager: ConnectionStatusManager; + private _connectionsGotUnsupportedVersionWarning: string[] = []; private static readonly CONNECTION_MEMENTO = 'ConnectionManagement'; private static readonly _azureResources: AzureResource[] = @@ -1045,6 +1046,23 @@ export class ConnectionManagementService extends Disposable implements IConnecti if (this._connectionStatusManager.isDefaultTypeUri(info.ownerUri)) { this._connectionGlobalStatus.setStatusToConnected(info.connectionSummary); } + + const connectionUniqueId = connection.connectionProfile.getConnectionInfoId(); + if (info.isSupportedVersion === false + && this._connectionsGotUnsupportedVersionWarning.indexOf(connectionUniqueId) === -1 + && this._configurationService.getValue('connection.showUnsupportedServerVersionWarning')) { + const warningMessage = nls.localize('connection.unsupportedServerVersionWarning', "The server version is not supported by Azure Data Studio, you may still connect to it but some features in Azure Data Studio might not work as expected."); + this._connectionsGotUnsupportedVersionWarning.push(connectionUniqueId); + this._notificationService.prompt(Severity.Warning, + `${warningMessage} ${info.unsupportedVersionMessage ?? ''}`, [ + { + label: nls.localize('connection.neverShowUnsupportedVersionWarning', "Don't show again"), + run: () => { + this._configurationService.updateValue('connection.showUnsupportedServerVersionWarning', false).catch(e => errors.onUnexpectedError(e)); + } + } + ]); + } } else { connection.connectHandler(false, info.errorMessage, info.errorNumber, info.messages); this._telemetryService.createErrorEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryError.DatabaseConnectionError, info.errorNumber.toString())