Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Ability to customize retrolab interface #350

Closed
holzschu opened this issue Feb 12, 2022 · 5 comments
Closed

Ability to customize retrolab interface #350

holzschu opened this issue Feb 12, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@holzschu
Copy link

Problem

I'm running retrolab on a computer where the user cannot run terminals (it's an iPad). To avoid user confusion, I would like the ability to remove the "New Terminal" button (and "New Console", too). In Jupyterlab, setting terminals_enabled to False will remove the "New Terminal" button in the Launcher tab. I haven't found a similar feature in retrolab (I think it's because the buttons are generated directly in Javascript, which makes a very compact system, at the expanse of customization).

Proposed Solution

I would like to suggest introducing a way to disable individual buttons in the interface. Possibly through a variable, that the user could set in a configuration file?

Additional context

Current user interface:
image

Desired user interface (after customization):
image

@holzschu holzschu added the enhancement New feature or request label Feb 12, 2022
@welcome
Copy link

welcome bot commented Feb 12, 2022

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@jtpio
Copy link
Member

jtpio commented Feb 13, 2022

Thanks @holzschu for opening this.

These two buttons are defined in separate plugins here:

/**
* Plugin to add a "New Console" button to the file browser toolbar.
*/
const newConsole: JupyterFrontEndPlugin<void> = {
id: '@retrolab/tree-extension:new-console',
requires: [IFileBrowserFactory, ITranslator],
autoStart: true,
activate: (
app: JupyterFrontEnd,
filebrowser: IFileBrowserFactory,
translator: ITranslator
) => {
const { commands } = app;
const browser = filebrowser.defaultBrowser;
const trans = translator.load('retrolab');
const newConsoleCommand = 'tree:new-console';
commands.addCommand(newConsoleCommand, {
label: trans.__('New Console'),
icon: consoleIcon,
execute: () => {
return commands.execute('console:create');
}
});
const newConsole = new CommandToolbarButton({
commands,
id: newConsoleCommand
});
browser.toolbar.insertItem(2, 'new-console', newConsole);
}
};
/**
* Plugin to add a "New Terminal" button to the file browser toolbar.
*/
const newTerminal: JupyterFrontEndPlugin<void> = {
id: '@retrolab/tree-extension:new-terminal',
requires: [IFileBrowserFactory, ITranslator],
autoStart: true,
activate: (
app: JupyterFrontEnd,
filebrowser: IFileBrowserFactory,
translator: ITranslator
) => {
const { commands } = app;
const browser = filebrowser.defaultBrowser;
const trans = translator.load('retrolab');
const newTerminalCommand = 'tree:new-terminal';
commands.addCommand(newTerminalCommand, {
label: trans.__('New Terminal'),
icon: terminalIcon,
execute: () => {
return commands.execute('terminal:create-new');
}
});
const newTerminal = new CommandToolbarButton({
commands,
id: newTerminalCommand
});
browser.toolbar.insertItem(3, 'new-terminal', newTerminal);
}
};

So it should be possible to disable them with:

jupyter labextension disable @retrolab/tree-extension:new-console
jupyter labextension disable @retrolab/tree-extension:new-terminal

@holzschu
Copy link
Author

Well I'll be damned! It works! I'm in awe.
For a more permanent solution, I ended up creating the config file Library/etc/jupyter/labconfig/page_config.json, which contains:

{
  "disabledExtensions": {
    "@retrolab/tree-extension:new-console": true,
    "@retrolab/tree-extension:new-terminal": true
  }
}

(which is the same, but stored as settings). Thank you so much!

While we're on the topic of customization, is there a way to add extra buttons to the top toolbar for a notebook? I would need two extra buttons to account for the specificities of iOS.

image

@jtpio
Copy link
Member

jtpio commented Feb 14, 2022

which is the same, but stored as settings

Yes that also works.

While we're on the topic of customization, is there a way to add extra buttons to the top toolbar for a notebook? I would need two extra buttons to account for the specificities of iOS.

Yes this is possible via an extension: https://jupyterlab.readthedocs.io/en/latest/extension/notebook.html#adding-a-button-to-the-toolbar. There is an example in the extension examples repo: https://github.com/jupyterlab/extension-examples/tree/master/toolbar-button

@jtpio
Copy link
Member

jtpio commented Apr 4, 2022

Closing as fixed by jupyter/notebook#6336

In the next Notebook v7 pre-release it will be possible to more easily customize the file browser toolbar items via the settings system, just like in JupyterLab.

@holzschu feel free to open new issues in the notebook directly if you think this needs to be iterated on more. Thanks!

@jtpio jtpio closed this as completed Apr 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants