jupyterhub / jupyter-server-proxy

Jupyter notebook server extension to proxy web services.
https://jupyter-server-proxy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
347 stars 148 forks source link

Allow configuring jupyterlab launcher category #453

Closed dylex closed 3 months ago

dylex commented 6 months ago

This lets you set which row of the launcher the icon ends up on (Notebook, Console, or Other). Just pass a configured launcher_entry.category through to launcher.add, defaulting to Notebook. Also adds documentation for existing path_info which was missing.

dylex commented 6 months ago

I guess I should add (and probably document) that for obscure jupyterlab reasons, the icon_path setting will only work when category is either "Kernel" or "Console".

yuvipanda commented 5 months ago

Apologies for the late review! I haven't tested this, but if we add another line to the docs about the icon limitation, I think this is ready to go as is.

bollwyvl commented 5 months ago

the icon_path setting will only work

Non-kernel icons in more recent jupyter clients are SVG so that they can be themed e.g. a black icon on a dark theme would disappear.

It's certainly possible to generate new SVG icons that answer the contract on the fly. Even PNG/JPEG/etc. can be encapsulated when the command is registered; very naively:

commands.addCommand(CommandIDs.open, {
  label: (args) => (args as IOpenArgs).title,
  icon: new LabIcon({
    svgstr: `<svg><foreignObject><img src="${launcher_entry.icon_url}"/></foreignObject></svg>`
  }),
  ...
})

...though they won't somehow magically be theme-aware.

Some gotchas:

dylex commented 5 months ago

I looked into the other icons a little, and it seemed more complicated. I think @bollwyvl's suggestion could be made to work in a generic way. I can try to take a look at some point, but probably not for this PR.

I also just noticed there was an old draft PR #244 to provide this same functionality in a similar way -- hopefully not stepping on anyone's toes!

imcovangent commented 3 months ago

Hello!

This is exactly what I was looking for! :) Plus I also wanted to add rank and make the SVG icon work. You can find that here: https://github.com/imcovangent/jupyter-server-proxy/tree/category_and_rank

I'm not sure what the proper way is to include this. I have now forked dylex:category and created a new branch that builds upon this PR, but adds the rank argument as well. And it includes a fix for the icons.

What is best? I make this a PR on dylex or make it directly a (new?) PR here?

Or do I wait for this PR to complete and then make a new PR? Please advice @dylex @yuvipanda

imcovangent commented 3 months ago

Any feedback on this @dylex or @yuvipanda ? Else I will open a new PR here from my branch. I'd love to see my additions in the next release.

yuvipanda commented 3 months ago

I just tested this, and it works. It has the limitation that the icon doesn't show up if you don't put it in Notebook, but that could be fixed in another PR.

yuvipanda commented 3 months ago

@imcovangent I opened a PR from your fork in https://github.com/jupyterhub/jupyter-server-proxy/pull/477, will test that too

yuvipanda commented 3 months ago

@imcovangent if we can make the SVG setup from you work, I'm happy to review, merge it and then get a new release out.