Add dont show prompt to azdata toasts (#12037)

* Add dont show prompt to azdata toasts

* Undo version change

* undo
This commit is contained in:
Charles Gagnon
2020-08-31 17:15:26 -07:00
committed by GitHub
parent a5b1e027c1
commit 02248fc065
3 changed files with 25 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ import { HttpClient } from './common/httpClient';
import Logger from './common/logger';
import { getErrorMessage, searchForCmd } from './common/utils';
import * as loc from './localizedConstants';
import { azdataConfigSection, debugConfigKey, requiredVersion as requiredVersion, installationReadmeUrl } from './constants';
import { azdataConfigSection, debugConfigKey, requiredVersion as requiredVersion, installationReadmeUrl, doNotPromptInstallMemento, doNotPromptUpdateMemento } from './constants';
export const azdataHostname = 'https://aka.ms';
export const azdataUri = 'azdata-msi';
@@ -256,17 +256,33 @@ export async function checkAndUpgradeAzdata(currentAzdata: IAzdataTool | undefin
* to install the correct version using opened documentation
* @param currentAzdata The current version of azdata to check.
*/
export async function manuallyInstallOrUpgradeAzdata(currentAzdata: IAzdataTool | undefined): Promise<void> {
export async function manuallyInstallOrUpgradeAzdata(context: vscode.ExtensionContext, currentAzdata: IAzdataTool | undefined): Promise<void> {
// Note - not localizing since this is temporary behavior
const dontShow = 'Don\'t Show Again';
if (currentAzdata === undefined) {
vscode.window.showInformationMessage(loc.installManually(requiredVersion, installationReadmeUrl), 'Ok');
const doNotPromptInstall = context.globalState.get(doNotPromptInstallMemento);
if (doNotPromptInstall) {
return;
}
const response = await vscode.window.showInformationMessage(loc.installManually(requiredVersion, installationReadmeUrl), 'OK', dontShow);
if (response === dontShow) {
context.globalState.update(doNotPromptInstallMemento, true);
}
Logger.show();
Logger.log(loc.installManually(requiredVersion, installationReadmeUrl));
} else {
const doNotPromptUpgrade = context.globalState.get(doNotPromptUpdateMemento);
if (doNotPromptUpgrade) {
return;
}
const requiredSemVersion = new SemVer(requiredVersion);
if (requiredSemVersion.compare(currentAzdata.cachedVersion) === 0) {
return; // if we have the required version then nothing more needs to be eon.
}
vscode.window.showInformationMessage(loc.installCorrectVersionManually(currentAzdata.cachedVersion.raw, requiredVersion, installationReadmeUrl), 'Ok');
const response = await vscode.window.showInformationMessage(loc.installCorrectVersionManually(currentAzdata.cachedVersion.raw, requiredVersion, installationReadmeUrl), 'OK', dontShow);
if (response === dontShow) {
context.globalState.update(doNotPromptUpdateMemento, true);
}
Logger.show();
Logger.log(loc.installCorrectVersionManually(currentAzdata.cachedVersion.raw, requiredVersion, installationReadmeUrl));
}