add unsupported version warning (#17219)

* add unsupported version warning

* comments
This commit is contained in:
Alan Ren
2021-10-01 18:17:04 -07:00
committed by GitHub
parent d5b43df6d6
commit 9f2ad8a04b
3 changed files with 36 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -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.")
}
}
});

View File

@@ -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<boolean>('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())