Skip to content

Conversation

@tpatel
Copy link
Contributor

@tpatel tpatel commented May 5, 2023

References

Fixes #14332

Code changes

Changes to filebrowser-extension:

  • New sortNotebooksFirst setting
  • New menu item shown when right-clicking on the filebrowser header

Changes to filebrowser:

  • Expose a sortNotebooksFirst property storing the setting internally as _sortNotebooksFirst that propagates changes to the listing
  • The listing exposes a setNotebooksFirstSorting method storing the setting internally as _sortNotebooksFirst. Modifying it triggers a sorting operation.
  • Updated the sorting method to take into account the two sorting behaviors.

User-facing changes

New setting in the filebrowser header setting menu (which opens when right-clicking on the header).

image

The behavior is:

  • When disabled, the file browser sorts the directories above all other files (doesn't modify the current behavior)
  • When enabled, the file browsers sorts the directories above everything, then the notebooks above other files (matches the Notebook V6 behavior).

Backwards-incompatible changes

None

closes jupyterlab#14332

- When disabled, the file browser sorts the directories above all other files (doesn't modify the current behavior)
- When enabled, the file browsers sorts the directories abover everything, then all notebooks above other files (matches the Notebook V6 behavior)
@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@welcome
Copy link

welcome bot commented May 5, 2023

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@jtpio jtpio added this to the 4.0.0 milestone May 5, 2023
@jtpio
Copy link
Member

jtpio commented May 5, 2023

Thanks @tpatel for working on this!

tpatel added 2 commits May 5, 2023 16:24
* comments, console.log
* fixed fallback sorting to be alphabetical ascending (instead of descending)
* better menu label
* added a test
Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

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

Looking good!

Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
@tpatel tpatel marked this pull request as ready for review May 8, 2023 12:38
Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

Thanks @tpatel

I have some questions. But generally this looks good, thanks!

}

set sortNotebooksFirst(value: boolean) {
if (this.listing.setNotebooksFirstSorting) {
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for testing for setNotebooksFirstSorting?

As the listing is of type DirListing (no interface used), it will always exist, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't find why the setColumnVisibility was being checked. I believe it should always exist but I was a bit confused and went on the safe side. Do you have more info about this?

https://github.com/jupyterlab/jupyterlab/blob/d47d50bbeb2db80df09489eb7c9588c29a140d22/packages/filebrowser/src/browser.ts#L164C7-L171

Copy link
Member

Choose a reason for hiding this comment

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

Given how downstream swaps listing, maybe it should become an interface? (this is not a discussion for this PR though). I just wanted to highlight that unfold extension goes pretty far with the modifications and depending on the version of DirListing it would load the guard may actually be useful (well at least if this lands in 4.x rather than 4.0). We also wanted to modify listing in jupyterlab-git but can probably make dedicated APIs for that use case.

Copy link
Member

Choose a reason for hiding this comment

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

Probably this condition was indeed added to make it easier for downstream applications to customize the file browser.

Thanks for providing the extra context, agree we can track follow-ups in other issues 👍

Copy link
Member

Choose a reason for hiding this comment

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

Ok then I'll agree we should keep the safe guard test. But I still would like to switch to a getter/setter pattern. @tpatel, you could replace the safeguard condition by

if (this.notebooksFirstSorted !== undefined)

Copy link
Member

@jtpio jtpio May 15, 2023

Choose a reason for hiding this comment

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

switch to a getter/setter pattern

Would it be possible to address this in a separate PR? And address this for showLastModifiedColumn or showFileSizeColumn as well for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it makes sense to address moving both methods to the getter/setter pattern in a separate PR to avoid being in a state with two different patterns 👍

tpatel and others added 2 commits May 10, 2023 09:59
Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
@jtpio
Copy link
Member

jtpio commented May 14, 2023

It would be great to get this one in so it makes it to the final 4.0 release, and would directly benefit Notebook 7.

Leaving it open until tomorrow in case @krassowski or @fcollonval have any more feedback.

@jtpio jtpio modified the milestones: 4.0.0, 4.0.x May 15, 2023
Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

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

Thanks!

As discussed during the JupyterLab weekly meeting today, it would be great to get this PR in so it can be used in Notebook 7.

This can be seen as a new feature to be included in a 4.1 release. But this can also be considered a "bug fix" for feature parity with the classic notebook.

Also having it opt-in like it is the case in this PR makes it easier to ship in a 4.0.x release.

@jtpio jtpio merged commit 1c55f92 into jupyterlab:main May 22, 2023
@welcome
Copy link

welcome bot commented May 22, 2023

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

@tpatel tpatel deleted the sort-notebooks-first branch May 22, 2023 13:00
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

For notebook v7: tree view should be able to sort notebook ahead of other files.

4 participants