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

View File

@@ -6,4 +6,6 @@
export const azdataConfigSection = 'azdata';
export const debugConfigKey = 'logDebugInfo';
export const requiredVersion = '20.1.1';
export const doNotPromptInstallMemento = 'azdata.doNotPromptInstall';
export const doNotPromptUpdateMemento = 'azdata.doNotPromptUpdate';
export const installationReadmeUrl = 'https://github.com/microsoft/Azure-data-services-on-Azure-Arc/blob/Aug-2020/scenarios-new/001-install-client-tools.md';

View File

@@ -3,16 +3,17 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as azdataExt from 'azdata-ext';
import { findAzdata, IAzdataTool, manuallyInstallOrUpgradeAzdata } from './azdata';
import * as loc from './localizedConstants';
let localAzdata: IAzdataTool | undefined = undefined;
export async function activate(): Promise<azdataExt.IExtension> {
export async function activate(context: vscode.ExtensionContext): Promise<azdataExt.IExtension> {
localAzdata = await checkForAzdata();
// Don't block on this since we want the extension to finish activating without user actions
manuallyInstallOrUpgradeAzdata(localAzdata)
manuallyInstallOrUpgradeAzdata(context, localAzdata)
.catch(err => console.log(err));
return {
azdata: {