diff --git a/extensions/azdata/src/azdata.ts b/extensions/azdata/src/azdata.ts index af36fabcd3..e4dfde4cad 100644 --- a/extensions/azdata/src/azdata.ts +++ b/extensions/azdata/src/azdata.ts @@ -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 { +export async function manuallyInstallOrUpgradeAzdata(context: vscode.ExtensionContext, currentAzdata: IAzdataTool | undefined): Promise { + // 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)); } diff --git a/extensions/azdata/src/constants.ts b/extensions/azdata/src/constants.ts index 68df09fd6c..7d768308da 100644 --- a/extensions/azdata/src/constants.ts +++ b/extensions/azdata/src/constants.ts @@ -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'; diff --git a/extensions/azdata/src/extension.ts b/extensions/azdata/src/extension.ts index a70c0893b1..d1da40b1f4 100644 --- a/extensions/azdata/src/extension.ts +++ b/extensions/azdata/src/extension.ts @@ -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 { +export async function activate(context: vscode.ExtensionContext): Promise { 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: {