Skip to content
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

Make session dialogs configurable #7618

Merged
merged 14 commits into from Dec 24, 2019

Conversation

blink1073
Copy link
Member

@blink1073 blink1073 commented Dec 11, 2019

References

Fixes #7616.

Code changes

  • Refactors ISessionContext to no longer contain any UI.
  • Adds an ISessionContextDialogs interface and token
  • Adds a default implementation of the restart and selectKernel dialogs.
  • In all places where the two dialogs were called, allow for optional override of the dialogs, defaulting to the base implementation.

User-facing changes

None

Backwards-incompatible changes

  • ISessionContext no longer has restart() or selectKernel() methods.
  • Those wishing to perform UI on an ISessionContext should allow the dialogs to be overridden and ultimately depend on the ISessionContextDialogs token.
  • Users of the concrete class are now responsible for calling the selectKernel() dialog if initialize() resolves to true.

@blink1073 blink1073 added this to the 2.0 milestone Dec 11, 2019
@jupyterlab-dev-mode
Copy link

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

@jasongrout
Copy link
Contributor

Unfortunately, needs rebase.

@@ -51,7 +51,7 @@ export interface ISessionContext extends IObservableDisposable {
* #### Notes
* This includes starting up an initial kernel if needed.
*/
initialize(): Promise<void>;
initialize(): Promise<boolean>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a docstring that says what this boolean is?

@@ -531,7 +534,8 @@ function activateNotebookHandler(
launcher: ILauncher | null,
restorer: ILayoutRestorer | null,
mainMenu: IMainMenu | null,
settingRegistry: ISettingRegistry | null
settingRegistry: ISettingRegistry | null,
sessionDialogs: ISessionContextDialogs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing | null

Copy link
Member

@afshin afshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but a second opinion would probably be beneficial.

👍

@blink1073 blink1073 closed this Dec 23, 2019
@blink1073 blink1073 reopened this Dec 23, 2019
@@ -732,7 +698,7 @@ export class SessionContext implements ISessionContext {
this._session.dispose();
}
this._session = session;
this._prevKernelName = session.kernel?.name;
this._prevKernelName = session.kernel?.name || '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? ''

return new ToolbarButton({
iconClassName: 'jp-RefreshIcon',
onClick: () => {
void sessionContext.restart();
void (dialogs || sessionContextDialogs).restart(sessionContext);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dialogs ?? sessionContextDialogs

<Private.KernelNameComponent sessionContext={sessionContext} />
<Private.KernelNameComponent
sessionContext={sessionContext}
dialogs={dialogs || sessionContextDialogs}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dialogs ??

): Promise<IConsoleTracker> {
const manager = app.serviceManager;
const { commands, shell } = app;
const category = 'Console';
sessionDialogs = sessionDialogs || sessionContextDialogs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| -> ??

@@ -136,11 +138,13 @@ async function activateConsole(
rendermime: IRenderMimeRegistry,
settingRegistry: ISettingRegistry,
launcher: ILauncher | null,
status: ILabStatus | null
status: ILabStatus | null,
sessionDialogs: ISessionContextDialogs | null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could just make this have a default value: sessionDialogs = sessionContextDialogs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, no, that won't work if null is explicitly being passed in...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the supplied value is null I believe that wouldn't work

@jasongrout
Copy link
Contributor

This looks pretty good to me reading through it. I had a couple of suggestions, but nothing that would block this (but apparently you've already addressed them, so yeah). The test failure looks legit.

@blink1073 blink1073 mentioned this pull request Dec 23, 2019
Steven Silvester added 9 commits December 23, 2019 18:18
lint

update notebook example

offer the option to keep no kernel

integrity

lint

fix up merge conflicts

lint

update tests

Update tests

Select a kernel if necessary in the console
@blink1073
Copy link
Member Author

Weird, the issues with the linux usage test went away after a rebase.

@blink1073 blink1073 merged commit 47de94a into jupyterlab:master Dec 24, 2019
@lock lock bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Jan 24, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2020
@blink1073 blink1073 deleted the session-dialogs branch March 29, 2020 09:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg:apputils status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow the client session dialogs to be customized
3 participants