-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fix rename for tree view (Jupyter 3.6.x) #47
base: master
Are you sure you want to change the base?
Conversation
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.
@skbitsp thank you for working on this. A bit more work is needed to merge this:
- JupyterLab 3 is nearing end of maintenance in two months time (JupyterLab 3 — May 15, 2024 end of maintenance jupyterlab/jupyterlab#15921, https://blog.jupyter.org/jupyterlab-3-end-of-maintenance-879778927db2) and since this extension currently supports JupyterLab 4 I don't think we can merge code which only works on 3.x.
- while adding a
CustomDirListing
sounds all right, it should not use the private methods ofDirListing
; ideally theDirListing
in core JupyterLab would be amended so that it either works out of the box without a need for subclassing (preferred), or so that only public/protected attributes/methods are accessed in therename()
override. - this PR includes a bunch of code which is not needed, and includes
@ts-nocheck
and@ts-ignore
which goes against the quality requirements
/** | ||
* Format bytes to human readable string. | ||
*/ | ||
export function formatFileSize( |
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.
Why is it added?
/** | ||
* Get the index of the node at a client position, or `-1`. | ||
*/ | ||
export function hitTestNodes( |
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.
This is not used anywhere.
/** | ||
* Sort a list of items by sort state as a new array. | ||
*/ | ||
export function sort( |
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.
This is not used anywhere.
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 have copied the entire Private namespace as used in JL 3 - hence the additional functions.
|
||
const oldModelPath = this._model.path; | ||
let modelPath = oldModelPath; | ||
// @ts-ignore |
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.
Why is @ts-ignore
needed here?
This PR is only meant as a reference for users using this extension (hence created a Though this is not the ideal way and the solution should come from the code JL side, this works fine as a quick workaround to unblock oursleves. |
I'm still encountering this issue with JupyterLab 4.x:
Curious if this will be fixed in the future? Thanks |
@daugraph This PR was not merged and is not mergeable in the current state, which is why you still see the issue. As described before, someone would need to make changes in JupyterLab and then open a PR to jupyterlab-unfold against the |
Thanks, I'll take a look first. |
This code change addresses an issue where the rename functionality was not working correctly in the JupyterLab tree view extension. The problem stemmed from the fact that the model.path attribute in the extension contained the complete path, while in operating systems, only the parent path is typically considered as the path. To resolve this issue, the rename method of DirListing—the class extended by the tree view extension was overridden.
In the tree view extension, the model.path attribute contains the complete path, whereas it typically should represent only the parent path. This discrepancy caused the rename functionality to fail in the tree view. To fix this, the code was modified to customize the DirListing class, taking a patch from JupyterLab version we are importing (3.6.*). By overriding the rename method, we ensure that the correct path is used for renaming files and folders.
Tested on local