-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Direct users to the Jupyter extension when using Run in Interactive window #21072
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { inject, injectable } from 'inversify'; | ||
import { IExtensionSingleActivationService } from '../activation/types'; | ||
import { IApplicationShell, ICommandManager } from '../common/application/types'; | ||
import { Common, Interpreters } from '../common/utils/localize'; | ||
import { Commands, JUPYTER_EXTENSION_ID } from '../common/constants'; | ||
import { IDisposable, IDisposableRegistry } from '../common/types'; | ||
import { sendTelemetryEvent } from '../telemetry'; | ||
import { EventName } from '../telemetry/constants'; | ||
|
||
@injectable() | ||
export class RequireJupyterPrompt implements IExtensionSingleActivationService { | ||
public readonly supportedWorkspaceTypes = { untrustedWorkspace: false, virtualWorkspace: true }; | ||
|
||
constructor( | ||
@inject(IApplicationShell) private readonly appShell: IApplicationShell, | ||
@inject(ICommandManager) private readonly commandManager: ICommandManager, | ||
@inject(IDisposableRegistry) private readonly disposables: IDisposable[], | ||
) {} | ||
|
||
public async activate(): Promise<void> { | ||
this.disposables.push(this.commandManager.registerCommand(Commands.InstallJupyter, () => this.showPrompt())); | ||
} | ||
|
||
private async showPrompt() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shoudln't this be a modal dialog, as this is a blocking action. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way we're showing it I think a modal dialog can be too harsh when user has already selected to "Install Jupyter".: If "Run in Interactive window" was not a submenu and user clicked it and expected to run directly, I could see why we would show the modal dialog. cc/ @luabud @karthiknadig |
||
const prompts = [Common.bannerLabelYes, Common.bannerLabelNo]; | ||
const telemetrySelections: ['Yes', 'No'] = ['Yes', 'No']; | ||
const selection = await this.appShell.showInformationMessage(Interpreters.requireJupyter, ...prompts); | ||
sendTelemetryEvent(EventName.REQUIRE_JUPYTER_PROMPT, undefined, { | ||
selection: selection ? telemetrySelections[prompts.indexOf(selection)] : undefined, | ||
}); | ||
if (!selection) { | ||
return; | ||
} | ||
if (selection === prompts[0]) { | ||
await this.commandManager.executeCommand( | ||
'workbench.extensions.installExtension', | ||
JUPYTER_EXTENSION_ID, | ||
undefined, | ||
); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be enabled only when workspace is trusted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I was only copying what Jupyter does though: https://github.com/microsoft/vscode-jupyter/blob/e9b886aa1fe65a4bf6ea8aff15caa31c30e23954/package.json#L786-L790