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

Jupyter logo "dashboard" link goes to default app, breaking out of classic #167

Closed
mcrutch opened this issue Oct 18, 2022 · 8 comments · Fixed by #168
Closed

Jupyter logo "dashboard" link goes to default app, breaking out of classic #167

mcrutch opened this issue Oct 18, 2022 · 8 comments · Fixed by #168

Comments

@mcrutch
Copy link
Contributor

mcrutch commented Oct 18, 2022

Could be intended, could be no one thought about it because they still have classic as their default

Scenario:

  • Start Jupyter with: jupyter server or jupyter lab (or jupyter notebook if using notebook v7 + nbclassic)
  • visit NBClassic
  • Top-left Jupyter logo goes to the launched UI rather than classic

This means if you are using classic, and open a notebook, the only way back to the tree view is the file->open menu, but anyone who has been using classic a long time is probably used to that logo going back to the /tree view. This affects anyone today with Notebook v6 with lab being the default ui in their environment, so this has been going on a while in some places, but just noticed this myself.

is this desired/intended behavior or has this just been overlooked since "notebook" was the default for so long? This is the line in the template that makes it so:

<div id="ipython_notebook" class="nav navbar-brand"><a href="{{default_url}}

@echarles
Copy link
Member

I guess this is not intended and clicking the top left logo should return to the nbclassic tree view, whatever command is used.

Maybe the fix is easy, but it sounds like it deserves enough care to cover all cases. Depending on the installe packages (notebook 7 or not...), the used command, and also the special case of Notebook 6.5.x that reuses the NbClassic static assets, we must be sure the correct link is generated.

A not so nice way, thought easy, way to handle that would be to inject an additional property in the jinja context that would be populated with the needed URL based on the some condition.

@mcrutch
Copy link
Contributor Author

mcrutch commented Oct 19, 2022

Did not know about the Notebook v6 dependency on NBClassic, interesting.

I thought about this some more and had another concern for after the NBv7 transition. At least currently, NBClassic relies on "Notebook" to provide the terminal and possibly other UI components. Is that planned to always be the case? Because that situation would be even harder if not impossible to address since you are actually executing in the Jupyterlab/Notebookv7 code branches, not NBClassic at that point.

Stream of consciousness here:
I haven't looked to find what else default_url in the jinja templates is used, but could it be possible to override this in NBClassic end points when Jupyter isn't started with nblassic as a paramter, so if you are viewing a page generated by nbclassic it is set to the path of nbclassic, or would that be too unclean/have unintended consequences?

@echarles
Copy link
Member

echarles commented Oct 19, 2022

when Jupyter isn't started with nblassic as a paramter, so if you are viewing a page generated by nbclassic it is set to the path of nbclassic, or would that be too unclean/have unintended consequences?

We can know if jupyter nbclassic is used as https://github.com/jupyter/nbclassic/blob/7e55b21ddb84777945fdd5b34b0f8ad325d882ff/nbclassic/__init__.py is invoked. We can set a flag there that can be read later one and injected in the jinja template. That is a theory and an practical implementation could confirm that.

@mcrutch
Copy link
Contributor Author

mcrutch commented Oct 19, 2022

I did a proof of concept to make it only affect NBClassic not Notebook v6, but it is a bit hacky at the moment. I only used what was currently available to the templates:
main...mcrutch:nbclassic:fix/nbclassic-base-url

@echarles
Copy link
Member

{%- if nbclassic_path()|length > 0 -%}{{base_url}}{{nbclassic_path() | replace("/","",1)}}{%- else -%}{{default_url}}{%- endif -%}

not sure to fully understand.

  • If jupyter nbclassic is NOT invoked nbclassic_path() will be empty.
  • If jupyter nbclassic is invoked and notebook < 7, nbclassic_path() will ALSO be empty.

How can you ensure you know what command is invoked. I trust you when you say POC is working for you, just trying to understand. I am not against adding an additional property like nbclassic_entrypoint_invoked (or any relevant name) to understand easier what is going that. That property would be True or False.

@mcrutch
Copy link
Contributor Author

mcrutch commented Oct 19, 2022

Yeah, my first cut ONLY affected nbclassic with Notebook v7 because my goal was to not break v6 at all and just to see how it could work.
I did make another swing at it though. This just always builds the path to populate that link nut if it is somehow not set, it exhibits the existing behavior as a safety net. I tested this with both notebook 6 and notebook 7, starting jupyter multiple ways. This even "fixes" Notebook v6 no matter how it is launched (jupyter lab, jupyter server, etc...)
main...mcrutch:nbclassic:fix/nbclassic-base-url

Pre-setup:

  • Configured with base_url of /Jupyter/

Test 1:

Test 2:

Test 3:

@echarles
Copy link
Member

Super! Would you mind opening a PR with your last diff. I will then review and test with various setups and commands.

@mcrutch
Copy link
Contributor Author

mcrutch commented Oct 19, 2022

Oops Meant to go back and to squash the old commits, but that can be done on merge

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 a pull request may close this issue.

2 participants