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

Replace a side-pane widget without replacing the plugin #10137

Open
martinRenou opened this issue Apr 22, 2021 · 8 comments
Open

Replace a side-pane widget without replacing the plugin #10137

martinRenou opened this issue Apr 22, 2021 · 8 comments
Milestone

Comments

@martinRenou
Copy link
Member

Problem

I am willing to use this extension: https://github.com/youngthejames/jupyterlab_filetree and to have it replace the core filebrowser extension.

I am aware one can disable another plugin using "disabledExtensions": ["@jupyterlab/filebrowser-extension"], and it seems to do what it says. But doing this brings multiple issues as other extensions are using the core filebrowser plugins.

So I am wondering if one could simply replace a widget instead of an entire extension.

Proposed Solution

Maybe something like:

app.shell.replace(oldwidget, mywidget);
@jtpio
Copy link
Member

jtpio commented Apr 22, 2021

It's possible that #9667 might already help a bit by making the plugins more reusable and easy to replace.

I am aware one can disable another plugin using "disabledExtensions": ["@jupyterlab/filebrowser-extension"]

It should also be possible to disable single plugins (instead of the whole extension), for example the browser plugin defined here:

const browser: JupyterFrontEndPlugin<void> = {
activate: activateBrowser,
id: '@jupyterlab/filebrowser-extension:browser',
requires: [
IFileBrowserFactory,
IDocumentManager,
ILabShell,
ILayoutRestorer,
ISettingRegistry,
ITranslator
],
optional: [ITreePathUpdater, ICommandPalette, IMainMenu],
autoStart: true
};

With:

{
  "disabledExtensions": ["@jupyterlab/filebrowser-extension:browser"]
}

@martinRenou
Copy link
Member Author

Thanks! Disabling only "@jupyterlab/filebrowser-extension:browser" seems to be what I needed :)

@jtpio
Copy link
Member

jtpio commented Apr 23, 2021

Nice!

Do you think the docs should be a bit more clear about how to replace existing plugins? If so maybe this section would be the one to expand on?

https://jupyterlab.readthedocs.io/en/stable/extension/extension_dev.html#disabledextensions

@jtpio jtpio added this to the Reference milestone Apr 23, 2021
@martinRenou
Copy link
Member Author

I guess the docs are fine. It was just unclear to me which plugin I needed to disable for my special case.

@echarles
Copy link
Member

Do you think the docs should be a bit more clear about how to replace existing plugins? If so maybe this section would be the one to expand on?

I would say a concrete example would help. A list of steps with commands to run. To have a concrete extension, a new one could be added in https://github.com/jupyterlab/extension-examples

@jtpio
Copy link
Member

jtpio commented Apr 23, 2021

To have a concrete extension, a new one could be added in https://github.com/jupyterlab/extension-examples

Sounds good. Maybe that example could have a smaller scope than replacing the file browser. For example replacing the jupyter logo in the top left corner by something else:

image

Since the logo is added as a plugin here:

const JupyterLogo: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab/application-extension:logo',
autoStart: true,
requires: [ILabShell],
activate: (app: JupyterFrontEnd, shell: ILabShell) => {
const logo = new Widget();
jupyterIcon.element({
container: logo.node,
elementPosition: 'center',
margin: '2px 2px 2px 8px',
height: 'auto',
width: '16px'
});
logo.id = 'jp-MainLogo';
shell.add(logo, 'top', { rank: 0 });
}
};

@echarles
Copy link
Member

For example replacing the jupyter logo in the top left corner by something else:

That would be awesome! and a very useful case.

@jtpio
Copy link
Member

jtpio commented Apr 23, 2021

Opened jupyterlab/extension-examples#156

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

No branches or pull requests

3 participants