-
-
Notifications
You must be signed in to change notification settings - Fork 46
Add an 'interface switcher' to the toolbar #158
Conversation
Thanks for submitting your first pull request! You are awesome! 🤗 |
I also wonder if we should trigger a save of the notebook first? Otherwise you might end up not seeing the proper notebook |
Thanks! We still depend on Line 90 in 0f7c026
So there could indeed be an interface switcher like this in the notebook toolbar.
Sounds good 👍 |
Also I'm wondering whether this plugin could actually go in the lab extension package? https://github.com/jupyterlab/retrolab/blob/main/packages/lab-extension/src/index.ts Then it would also be available in the JupyterLab UI: We could then remove the existing RetroLab icon from the notebook toolbar, since this would already be covered by the switch? |
@jtpio so if we move it to the labextension, we'll have to determine current setup (lab or retro) and adjust choices accordingly. That seems reasonable, I'll do that instead. |
We could yes, by checking whether there is an It would also be fine to have them all show up in both retro and lab to start with. |
@jtpio I can't seem to figure out how to test this in lab though :( |
I did refactor the code to suck less, and theoretically added code to behave differently when running in lab vs retro. Any idea how I can test it? |
app/index.js
Outdated
@@ -87,6 +87,9 @@ async function main() { | |||
require('@retrolab/docmanager-extension'), | |||
require('@retrolab/help-extension'), | |||
require('@retrolab/notebook-extension'), | |||
require('@retrolab/lab-extension').default.filter(({ id }) => |
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.
The lab-extension
package is a "normal" JupyterLab 3.0 prebuilt extension:
Lines 28 to 41 in 752e21f
labext_name = "@retrolab/lab-extension" | |
lab_extension_dest = os.path.join(HERE, PACKAGE_NAME, "labextension") | |
lab_extension_source = os.path.join(HERE, "packages", "lab-extension") | |
# Representative files that should exist after a successful build | |
jstargets = [ | |
os.path.join(lab_extension_dest, "package.json"), | |
os.path.join(main_bundle_dest, "bundle.js"), | |
] | |
package_data_spec = {PACKAGE_NAME: ["*", "templates/*", "static/**"]} | |
data_files_spec = [ | |
("share/jupyter/labextensions/%s" % labext_name, lab_extension_dest, "**"), |
So having the interface switcher in that package sounded like it would then be loaded automatically in both retro and lab, since retro also supports loading existing prebuilt JupyterLab extensions.
In that case we shouldn't need to manually include the package in this index.js
file.
commandLabel: 'Open in RetroLab', | ||
dropdownLabel: 'RetroLab', | ||
urlPrefix: `${baseUrl}retro/tree/`, | ||
current: app.name === 'RetroLab' |
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.
Maybe we could also add ILabShell
and IRetroShell
as optional
dependencies for the plugin, and check whether they are null
to know if the current interface is a JupyterLab-like or RetroLab-like interface?
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.
name
could indeed be overriden via the page config or directly in JS like here:
Thanks Yuvi for the update 👍 Since the For real testing, it would be great to start using end-to-end tools like Galata at some point: #135 |
Ah, I'll make these changes :) And to clarify, when I said 'I do not know how to test these' I was refering to not being able to get JupyterLab to reflect my changes at all! So I can't actually see if what I did worked... |
It seems to be showing fine in both retro and lab now when testing with the Binder link above: Although choosing one of the dropdown options doesn't seem to perform the switch. Need to check, but maybe you need to run |
@jtpio yay, running I'll change the way to detect which UI we are running by using |
@jtpio gentle bump - anything else needed here? |
Thanks Yuvi for the update. Checking with the Binder link above, it looks like choosing other interfaces has no effect? interface-switch-binder.mp4And it seems to be defaulting to JupyterLab. |
But using the commands from the command palette works fine. |
oh interesting - it works for me. I'll investigate it this week. |
Works on retrolab but can't get it to work on JupyterLab
It's automatically loaded by retrolab, since it's a labextension!
@yuvipanda I pushed an update in 3f49eea to show the appropriate notebook toolbar buttons depending on the current interface: interface-switch-buttons.mp4Using buttons instead of a dropdown to help simplify the state management. If you want to try it on Binder: https://mybinder.org/v2/gh/yuvipanda/retrolab/open-in?urlpath=retro/tree If it looks good to you we can merge and ship it right after in |
Awesome! This looks great to me, thank you for putting effort into it!!! |
Great, thanks for checking it out! Let's get it in then, I'll cut |
Fixes #157
Is how it looks. Can switch to lab or classic.