Skip to content

Commit

Permalink
Add done button
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Oct 4, 2023
1 parent 03597e6 commit a62665d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export namespace Interpreters {
export const terminalDeactivatePrompt = l10n.t(
'Deactivating virtual environments may not work by default due to a technical limitation in our activation approach, but it can be resolved with a few simple steps.',
);
export const deactivateDoneButton = l10n.t('Done, it works');
export const activatedCondaEnvLaunch = l10n.t(
'We noticed VS Code was launched from an activated conda environment, would you like to select it?',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class TerminalDeactivateLimitationPrompt implements IExtensionSingleActiv
if (!notificationPromptEnabled.value) {
return;
}
const prompts = [Common.seeInstructions, Common.doNotShowAgain];
const prompts = [Common.seeInstructions, Interpreters.deactivateDoneButton, Common.doNotShowAgain];
const selection = await this.appShell.showWarningMessage(Interpreters.terminalDeactivatePrompt, ...prompts);
if (!selection) {
return;
Expand All @@ -74,7 +74,7 @@ export class TerminalDeactivateLimitationPrompt implements IExtensionSingleActiv
const url = `https://aka.ms/AAmx2ft`;
this.browserService.launch(url);
}
if (selection === prompts[1]) {
if (selection === prompts[1] || selection === prompts[2]) {
await notificationPromptEnabled.updateValue(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ suite('Terminal Deactivation Limitation Prompt', () => {
let notificationEnabled: IPersistentState<boolean>;
let browserService: IBrowserService;
let interpreterService: IInterpreterService;
const prompts = [Common.seeInstructions, Common.doNotShowAgain];
const prompts = [Common.seeInstructions, Interpreters.deactivateDoneButton, Common.doNotShowAgain];
const expectedMessage = Interpreters.terminalDeactivatePrompt;

setup(async () => {
Expand Down Expand Up @@ -184,6 +184,28 @@ suite('Terminal Deactivation Limitation Prompt', () => {
verify(notificationEnabled.updateValue(false)).once();
});

test('Disable notification if `Done, it works` is clicked', async () => {
const resource = Uri.file('a');
const terminal = ({
creationOptions: {
cwd: resource,
},
} as unknown) as Terminal;
when(notificationEnabled.value).thenReturn(true);
when(interpreterService.getActiveInterpreter(anything())).thenResolve(({
type: PythonEnvType.Virtual,
} as unknown) as PythonEnvironment);
when(shell.showWarningMessage(expectedMessage, ...prompts)).thenReturn(
Promise.resolve(Interpreters.deactivateDoneButton),
);

await deactivatePrompt.activate();
terminalWriteEvent.fire({ data: 'Please deactivate me', terminal });
await sleep(1);

verify(notificationEnabled.updateValue(false)).once();
});

test('Open link to workaround if `See instructions` is clicked', async () => {
const resource = Uri.file('a');
const terminal = ({
Expand Down

0 comments on commit a62665d

Please sign in to comment.