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

Don't display .ipynb in notebook title #160

Closed
yuvipanda opened this issue Jun 8, 2021 · 3 comments · Fixed by #296
Closed

Don't display .ipynb in notebook title #160

yuvipanda opened this issue Jun 8, 2021 · 3 comments · Fixed by #296
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@yuvipanda
Copy link
Contributor

Problem

Notebook files always have the .ipynb extension, so we should not display them. Classic notebook does not.

Classic Notebook:

image

Retrolab:

image

Proposed Solution

Trip .ipynb when displaying name of notebook

@yuvipanda yuvipanda added the enhancement New feature or request label Jun 8, 2021
@jtpio
Copy link
Member

jtpio commented Jun 9, 2021

Thanks @yuvipanda for the suggestion.

Notebook files always have the .ipynb extension, so we should not display them. Classic notebook does not.

I think it would be fine to indeed not display the extension. And it saves some space in the top area.

One thing to keep in mind too is that RetroLab doesn't need or claim to be a strict copy of the classic notebook UI, so some differences such as this one would be fine.

@yuvipanda
Copy link
Contributor Author

One thing to keep in mind too is that RetroLab doesn't need or claim to be a strict copy of the classic notebook UI, so some differences such as this one would be fine.

oh yeah, absolutely. Just looking for inspiration :)

@jtpio
Copy link
Member

jtpio commented Nov 2, 2021

Based on the discussion from other issues (for example https://github.com/jupyterlab/retrolab/issues/259) and the notebook discussion, maybe we'll want to do this to match the classic UI.

The plugin handling the title is defined here:

/**
* A plugin to display and rename the title of a file
*/
const title: JupyterFrontEndPlugin<void> = {
id: '@retrolab/application-extension:title',
autoStart: true,
requires: [IRetroShell],
optional: [IDocumentManager, IRouter],
activate: (
app: JupyterFrontEnd,
shell: IRetroShell,
docManager: IDocumentManager | null,
router: IRouter | null
) => {
const widget = new Widget();
widget.id = 'jp-title';
app.shell.add(widget, 'top', { rank: 10 });
const addTitle = async () => {
const current = shell.currentWidget;
if (!current || !(current instanceof DocumentWidget)) {
return;
}
if (widget.node.children.length > 0) {
return;
}
const h = document.createElement('h1');
h.textContent = current.title.label;
widget.node.appendChild(h);
widget.node.style.marginLeft = '10px';
if (!docManager) {
return;
}
widget.node.onclick = async () => {
const result = await renameDialog(docManager, current.context.path);
// activate the current widget to bring the focus
if (current) {
current.activate();
}
if (result === null) {
return;
}
const newPath = current.context.path ?? result.path;
const basename = PathExt.basename(newPath);
h.textContent = basename;
if (!router) {
return;
}
const matches = router.current.path.match(TREE_PATTERN) ?? [];
const [, route, path] = matches;
if (!route || !path) {
return;
}
const encoded = encodeURIComponent(newPath);
router.navigate(`/retro/${route}/${encoded}`, {
skipRouting: true
});
};
};
shell.currentChanged.connect(addTitle);
addTitle();
}
};

It is also activated and used for text files. Classic shows the extension for other files than notebooks:

image

So we probably need to special case .ipynb in the plugin, and also make sure renaming is still supported.

Marking as good first issue if someone would like to take a look, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants