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

Add defaultPath option to set the default directory for file dialog #15282

Merged
merged 6 commits into from
Nov 2, 2023

Conversation

mmichilot
Copy link
Contributor

@mmichilot mmichilot commented Oct 19, 2023

Apologies for the duplicate pull request, decided to move changes into a separate branch

References

Adds the defaultPath option referenced in #12929

Code changes

Adds a new optional defaultPath option to IDirectoryOptions. This option is then passed to createFilteredFileBrowser where it uses defaultPath to change the directory of the model. The resulting file dialog opens to the given path instead of root.

Also added two new tests to verify defaultPath functionality.
Within a folder in root, a new file and folder are added as shown:

.
├── Untitled Folder/ <---- defaultPath
│   ├── Untitled File
│   └── Untitled Folder
├── Untitled File
└── Untitled Notebook

The tests check that the parent directory of the selected file/folder matches the given defaultPath.

User-facing changes

None

Backwards-incompatible changes

None

Additional Question(s)

There is a lint error regarding floating promises. Since model.cd() returns Promise<void> and doesn't throw an error, would it be safe to mark the call as intentionally not awaited using the void operator?

@jupyterlab-probot
Copy link

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

@mmichilot mmichilot changed the title Add defaultpath Add defaultPath option to set the default directory for file dialog Oct 19, 2023
@krassowski krassowski added this to the 4.1.0 milestone Oct 20, 2023
There was a floating promise in createFilteredFileBrowser as a result
of calling model.cd(). To fix the floating promise,
createdFilteredFileBrowser is async and respective changes propagated to
places it was used.
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 @mmichilot

@fcollonval
Copy link
Member

CI failures are not related

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.

Thank you @mmichilot

@krassowski krassowski merged commit c6e7a14 into jupyterlab:main Nov 2, 2023
75 of 79 checks passed
Copy link

welcome bot commented Nov 2, 2023

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

@krassowski krassowski changed the title Add defaultPath option to set the default directory for file dialog Add defaultPath option to set the default directory for file dialog Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants