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

SwanFileBrowser extension for jupyterlab #199

Closed
wants to merge 5 commits into from

Conversation

omazapa
Copy link
Contributor

@omazapa omazapa commented Nov 23, 2021

Hi Guys,

This is the SwanFileBrowser extension.

This extension replaces the default FileBrowser and allows you to control directories that are projects.

@krishnan-r
Copy link
Contributor

Hi @omazapa
This PR also adds this commit: 104d570 which version bumps SwanShare. Is this intentional?

@diocas
Copy link
Contributor

diocas commented Nov 25, 2021

Hi @omazapa This PR also adds this commit: 104d570 which version bumps SwanShare. Is this intentional?

It's probably because it was part of master, but there were issues and I removed it. Sorry.

@@ -0,0 +1,34 @@
import { URLExt } from '@jupyterlab/coreutils';

Copy link
Contributor

Choose a reason for hiding this comment

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

What's this file for? Is it a copy from upstream? Any modification you did?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file has the function that allows requesting our backend extensions.
it is not a copy of an upstream function,
I took it from the extension example like this https://github.com/jupyterlab-contrib/search-replace/blob/master/src/handler.ts
I don't remember which one :C

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this file? Isn't there an equivalent in the upstream that we can import?

@omazapa omazapa force-pushed the swanfilebrowser branch 2 times, most recently from c7503fb to 249cbe7 Compare November 30, 2021 14:27
@omazapa
Copy link
Contributor Author

omazapa commented Nov 30, 2021

Thanks a lot @etejedor for your review :D

* This file is the entry point for the extension where is defined the commands such as
* 'filebrowser:copy', 'filebrowser:cut', 'filebrowser:open' etc..
* Those commands are reimplemented using our class SwanFileBrowser instead the default Jupyter FileBrowser.
* This extension replaces the default FileBrowser, then we need to redefined the commands provided by the default FileBrowser
Copy link
Contributor

Choose a reason for hiding this comment

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

to redefined -> to redefine

Copy link
Contributor

@diocas diocas left a comment

Choose a reason for hiding this comment

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

Some questions and comments :)
Important: comment the code with the exact information from upstream to allow us to compare upstream with your code.
And the objective is to copy the code (when we need to) and try to keep it as similar as possible with upstream.

ft,
this.translator,
this._hiddenColumns,
swan_item.is_project === true && swan_item.type === 'directory'
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of passing this boolean, since you already pass item, I would keep all methods the same and just put the project logic inside updateItemNode only.

const modified = DOMUtils.findElement(dragImage, ITEM_MODIFIED_CLASS);
console.log('-----drag');
console.log(node);
const isProject = node.getAttribute('is_project');
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this attribute added?

const isProject = node.getAttribute('is_project');
let icon = null;
if (isProject === 'true') {
icon = DOMUtils.findElement(dragImage, ITEM_PROJECT_ICON_CLASS);
Copy link
Contributor

Choose a reason for hiding this comment

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

I also don't see where ITEM_PROJECT_ICON_CLASS is being added? In updateItemNode I see you adding ITEM_ICON_CLASS to a Project as well.
I would suggest we keep ITEM_ICON_CLASS and again modify just the absolutely necessary.

@@ -0,0 +1,2391 @@
/**
* File taken from https://github.com/jupyterlab/jupyterlab/blob/master/packages/filebrowser/src/listing.ts
* for Jupyterlab version 3.0.x.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the hash instead of the branch tag. I wanted to compare with upstream and I'm seeing other changes in the file, if I had a commit hash I would be able to see exactly the same file.

* -> onUpdateRequest
* -> updateItemNode
*/
export class SwanDirListing extends Widget {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to create a SwanDirListing instead of just using the one that comes in upstream (DirListing)?
I would suggest we change just the absolutely minimum.

We only copy this file so that we can show the project folder icon, right? I got the impression we could just cast the model to ISwanModel inside updateItemNode (to do the if that changes the icon), and leave everything else exactly as is.

@@ -0,0 +1,34 @@
import { URLExt } from '@jupyterlab/coreutils';

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this file? Isn't there an equivalent in the upstream that we can import?

return rvalue;
});
} catch (reason) {
console.error(`Error on GET 'api/contents'+ ${cwd}.\n${reason}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the + ?

console.log(message);
});
}
await this.kernelSpecSetPathRequest(this.path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this? I'm not sure we do... I though wether changing the spec manager from another tab would be possible, but Lab doesn't allow you to have more than one window open, right?

If we do need it, we should do it bellow when we also cd to '.'.

@diocas
Copy link
Contributor

diocas commented Aug 17, 2023

Closing as superseded by #209

@diocas diocas closed this Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants