-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Read only status notification on ctrl+s #15317
Read only status notification on ctrl+s #15317
Conversation
Thanks for making a pull request to jupyterlab! |
Kicking CI which failed due to |
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.
Could you look at how hard adding an integration test would be here? I does not need to include a snapshot as there is a dedicated page.notifications
galata helper which could be used, as in:
jupyterlab/galata/test/jupyterlab/announcements.test.ts
Lines 15 to 26 in c6e7a14
test('Announcements requires user agreement', async ({ page }) => { | |
const notifications = await page.notifications; | |
expect(notifications).toHaveLength(1); | |
expect(notifications[0].message).toEqual( | |
'Would you like to receive official Jupyter news?\nPlease read the privacy policy.' | |
); | |
expect(notifications[0].options.actions).toHaveLength(3); | |
expect(notifications[0].options.actions[0].label).toEqual( | |
'Open privacy policy' | |
); | |
}); |
@krassowski, I'm a little lost trying to figure out how to make a test notebook read only. Do you have any suggestions on how I should do this? |
Good question. I think you that setting immutable attribute could work on CI but this would annoy anyone running tests locally as it would require a manual/OS-specific step before running the test. Probably the best option would be adding a mock that forces the "writable" attribute to false. You can follow the existing mocks such as jupyterlab/galata/src/galata.ts Lines 573 to 625 in 453adc4
|
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.
The test looks good, thank you! Two suggestions/questions on:
- showing just file name not path
- throwing an error if command gets executed when it should not be.
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.
Should it just show the base name? Or is showing the full path valuable here?
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.
I see it as being a tradeoff between full path being more explicit vs just the file name potentially being more tidy. Personally I would lean towards the more explicit option. You probably have a better understanding of JLab users though, so I'm happy to defer to your opinion. It's also worth noting that the same function and input are being used for the notification for the save-all and save commands though. I could see the full path being better for the save-all notification even if we update the save notification to just use the base name.
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
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.
Thanks @andrewfulton9
References
adds feature described in #15046
depends on lumino #644 to function
Code changes
Uses contextual information passed from lumino commands
_executeKeyBinding
viaargs
to modify execution if the save is called from a keybinding to raise a notification notifying a user that the file is read-only and can't be savedUser-facing changes
If a user trys to save read-only document with the keybinding "ctr+s", a notification will briefly pop up notifying them that the document is read-only and cannot be saved.
read-only.notification.mp4
Backwards-incompatible changes
None that I am aware