-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Ask user to switch to prerelease * NLS files
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import '../common/extensions'; | ||
import { inject, injectable, named } from 'inversify'; | ||
import { IExtensionSingleActivationService } from '../activation/types'; | ||
import { IApplicationEnvironment, IApplicationShell } from '../common/application/types'; | ||
import { GLOBAL_MEMENTO, IMemento } from '../common/types'; | ||
import * as localize from '../common/utils/localize'; | ||
import { JVSC_EXTENSION_ID } from '../common/constants'; | ||
import * as vscode from 'vscode'; | ||
|
||
const PRERELEASE_DONT_ASK_FLAG = 'dontAskForPrereleaseUpgrade'; | ||
|
||
@injectable() | ||
export class PreReleaseChecker implements IExtensionSingleActivationService { | ||
constructor( | ||
@inject(IApplicationEnvironment) private readonly appEnv: IApplicationEnvironment, | ||
@inject(IApplicationShell) private readonly appShell: IApplicationShell, | ||
@inject(IMemento) @named(GLOBAL_MEMENTO) private globalState: vscode.Memento | ||
) {} | ||
public async activate(): Promise<void> { | ||
// Ask user if the version is not prerelease | ||
const isPreRelease = this.appEnv.packageJson.__metadata?.preRelease == true; | ||
const dontAsk = this.globalState.get(PRERELEASE_DONT_ASK_FLAG, false); | ||
if (!isPreRelease && this.appEnv.channel === 'insiders' && !dontAsk) { | ||
const yes = localize.DataScience.usingNonPrereleaseYes(); | ||
const no = localize.DataScience.usingNonPrereleaseNo(); | ||
const dontAskAgain = localize.DataScience.usingNonPrereleaseNoAndDontAskAgain(); | ||
void this.appShell | ||
.showWarningMessage(localize.DataScience.usingNonPrerelease(), yes, no, dontAskAgain) | ||
.then((answer) => { | ||
if (answer === yes) { | ||
return vscode.commands.executeCommand( | ||
'workbench.extensions.installExtension', | ||
JVSC_EXTENSION_ID, | ||
{ | ||
installPreReleaseVersion: true | ||
} | ||
); | ||
} else if (answer == dontAskAgain) { | ||
return this.globalState.update(PRERELEASE_DONT_ASK_FLAG, true); | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters