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

Close the browser tab when clicking on "Close and Shut Down Notebook" #6937

Merged
merged 12 commits into from
Jun 22, 2023

Conversation

jtpio
Copy link
Member

@jtpio jtpio commented Jun 20, 2023

Fixes #6934
Fixes #1159

This mimics the behavior of the Classic Notebook:

close-and-halt.mp4

In Notebook 7:

notebook-7-close-and-halt.mp4

Changes

  • Add new semantic command to the closeAndCleaners
  • Move the close and cleaners down in the file menu. Related to Notebook v7 menus should match the v6 ones whenever possible #6398
  • Keep the same "Close and Halt" name in the menu entry as in the classic UI
  • Update reference snapshots
  • Add UI test to check the browser tab is closed when clicking on the menu item

@jtpio jtpio added this to the 7.0 milestone Jun 20, 2023
@github-actions
Copy link
Contributor

Binder 👈 Launch a Binder on branch jtpio/notebook/close-and-shutdown

@jtpio
Copy link
Member Author

jtpio commented Jun 20, 2023

bot please update playwright snapshots

@jtpio jtpio closed this Jun 20, 2023
@jtpio jtpio reopened this Jun 20, 2023
@jtpio jtpio marked this pull request as ready for review June 20, 2023 08:11
@jtpio
Copy link
Member Author

jtpio commented Jun 20, 2023

cc @gutow for awareness

@jtpio jtpio requested a review from andrii-i June 20, 2023 08:11
@jtpio jtpio changed the title Close the browser tab when clicking on "Close and Shut Down Notebook" Close the browser tab when clicking on "Close and Halt" Jun 20, 2023
Copy link
Contributor

@andrii-i andrii-i 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 and works well, thank you for working on this @jtpio.

I believe there is spaceto improve user experience further beyond adding parity with nbclassic:

  1. It's not clear what exactly "Close and Halt" and "Shut Down" items do and what is the difference between them. Please find suggestions below on renaming "Close and Halt" into "Close Notebook and Shutdown Kernel". "Shut Down" should then be renamed into "Shut Down Server". I think this can be done within this PR but can also be taken care of separately.
  2. "Close and Halt" terminates kernel of the notebook and "Shut Down" terminates server with all kernels. When this happens all unsaved data is lost. Therefore these buttons are destructive and can lead to data loss. To remedy this, we could ask a user to confirm his action via modal/popup window. We should then also add "..." to the end of both options to indicate that selecting the item will lead to further options or require additional input. It would probably be best to do it in a separate PR after Notebook 7 launch, please let me know if you agree with the approach and I can create an issue to track it.


const id = 'notebook:close-and-halt';
commands.addCommand(id, {
label: trans.__('Close and Halt'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
label: trans.__('Close and Halt'),
label: trans.__('Close Notebook and Shutdown Kernel'),

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 going with this suggestion then we'll likely need to use Shut Down instead of Shutdown for consistency with the other menu entries.

@@ -155,4 +155,24 @@ test.describe('Notebook', () => {
const imageName = 'notebooktools-right-panel.png';
expect(await panel.screenshot()).toMatchSnapshot(imageName);
});

test('Clicking on "Close and Halt" should close the browser tab', async ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
test('Clicking on "Close and Halt" should close the browser tab', async ({
test('Clicking on "Close Notebook and Shutdown Kernel" should close the browser tab', async ({

);
await page.goto(`notebooks/${tmpPath}/${notebook}`);

const menuPath = 'File>Close and Halt';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const menuPath = 'File>Close and Halt';
const menuPath = 'File>Close Notebook and Shutdown Kernel';

@jtpio
Copy link
Member Author

jtpio commented Jun 21, 2023

  1. It's not clear what exactly "Close and Halt" and "Shut Down" items do and what is the difference between them. Please find suggestions below on renaming "Close and Halt" into "Close Notebook and Shutdown Kernel". "Shut Down" should then be renamed into "Shut Down Server". I think this can be done within this PR but can also be taken care of separately.

Good question. JupyterLab uses "Close and Shut Down Notebook", while for the Classic Notebook it's "Close and Halt". This PR went with "Close and Halt" so it looks the same as the classic notebook and also taking into consideration #6398 (for example if folks have screenshots showing these menu entries in the course materials).

However for consistency with JupyterLab it would be fine to go with "Close and Shut Down Notebook" yes, no strong opinion.

2. To remedy this, we could ask a user to confirm his action via modal/popup window

Normally there is already a dialog (see the second screencast):

image

@andrii-i
Copy link
Contributor

However for consistency with JupyterLab it would be fine to go with "Close and Shut Down Notebook" yes, no strong opinion.

From my point of view, "Close and Shut Down Notebook" is significantly more clear in explaining its function. "Close and Shut Down Notebook" still describes what happens with kernel better vs for example "Close and Halt Notebook" as "halt" implies pausing. Also we already use "Shut Down" for process termination so with "halt" we would be introducing a second term for the same action. We could also check in with other contributors during the call today.

Normally there is already a dialog (see the second screencast)

Yes, somehow missed this.

@jtpio
Copy link
Member Author

jtpio commented Jun 21, 2023

From my point of view, "Close and Shut Down Notebook" is significantly more clear in explaining its function. "Close and Shut Down Notebook" still describes what happens with kernel better vs for example "Close and Halt Notebook" as "halt" implies pausing. Also we already use "Shut Down" for process termination so with "halt" we would be introducing a second

Yes that sounds fine too. Users familiar with the Close and Halt entry from the classic notebook would probably be not too confused if it's now name Close and Shut Down Notebook now anyway.

Co-Authored-By: Andrii Ieroshenko <ieroshenkoa@gmail.com>
@jtpio
Copy link
Member Author

jtpio commented Jun 21, 2023

bot please update playwright snapshots

@jtpio jtpio closed this Jun 21, 2023
@jtpio jtpio reopened this Jun 21, 2023
@jtpio
Copy link
Member Author

jtpio commented Jun 21, 2023

FYI @andrii-i I updated the PR to take your suggestions in consideration.

@jtpio jtpio changed the title Close the browser tab when clicking on "Close and Halt" Close the browser tab when clicking on "Close and Shut Down Notebook" Jun 21, 2023
@jtpio
Copy link
Member Author

jtpio commented Jun 22, 2023

Merging as the comments above have been addressed.

Thanks @andrii-i for the review!

@jtpio jtpio merged commit 77f87de into jupyter:main Jun 22, 2023
25 checks passed
@jtpio jtpio deleted the close-and-shutdown branch June 22, 2023 07:41
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants