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

Add a "Hub Control Panel" menu item if running inside a JupyterHub #79

Merged
merged 3 commits into from
Feb 5, 2024

Conversation

yuvipanda
Copy link
Contributor

@yuvipanda yuvipanda commented Feb 4, 2024

Based on #78

I wanted to provide a "Hub Control Panel" menu item only when running in
a JupyterHub. To do this, we need to figure out when we are running in
a JupyterHub. There were two ways to do this:

  1. Expose an API endpoint as a Jupyter Server extension, and then talk to this
    from a purely static JS code to figure out if we were on the hub, and if so,
    where the hub control panel is
  2. Render the html as a jinja2 template from a Jupyter Server extension, leaving
    websockify for jupyter-server-proxy to handle

After some poking around (and trying a 3rd approach that's more complex), (2) seems
the right path.

image

A "Hub Control Panel" button is now added if we are running inside a hub,
but not added if we are not running inside a hub. I've tried to stick to
how other projects does it to whatever extent I can.

I'm also very excited because this gives us other extension opportunities
in the future :)

Fixes #57

Copy link

github-actions bot commented Feb 4, 2024

Binder 👈 Launch a binder notebook on this branch for commit d153460

I will automatically update this comment whenever this PR is modified

Binder 👈 Launch a binder notebook on this branch for commit 831fe1f

Binder 👈 Launch a binder notebook on this branch for commit 0fadd16

I want to provide a button to the Hub Control Panel
when we are running under a JupyterHub. This requires conditional
rendering in some way - either we render the initial HTML as
a template, or setup an API endpoint that JS can use.

This PR templatizes the initial rendering. The following changes
are made:

1. Convert into a Jupyter Server extension. This gives us the
   flexibility we need here.
2. Inherit a handler directly from jupyter_server_proxy, enabling
   us to use the *same* URL for both the initial HTTP rendering
   and the websockify!

However, this means we lose the launcher icon - let's try
mitigate that somehow.
This is simpler than inheriting from the proxying handler
from jupyter_server_proxy directly, and more importantly keeps
our launcher entry simple and existing!
setup.py Outdated Show resolved Hide resolved
@manics manics merged commit a0f7620 into main Feb 5, 2024
6 checks passed
@manics manics deleted the server branch February 5, 2024 23:26
@unode
Copy link

unode commented Feb 6, 2024

Thanks @yuvipanda ! Long journey but totally worth it.

@yuvipanda
Copy link
Contributor Author

Thank you for your patience, @unode!

@yuvipanda yuvipanda added the enhancement New feature or request label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a link to the hub control panel
3 participants