jupyter-server-proxy icon indicating copy to clipboard operation
jupyter-server-proxy copied to clipboard

Allow configuring jupyterlab launcher category

Open dylex opened this issue 1 year ago • 4 comments

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 avatar Feb 20 '24 20:02 dylex

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".

dylex avatar Feb 21 '24 02:02 dylex

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.

yuvipanda avatar Apr 03 '24 18:04 yuvipanda

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:

  • it may also be that the path would need some massaging with e.g. new URL(launcher_entry.icon_url, PageConfig.getBaseUrl())
  • the svg might need viewbox
  • the img might need a width and height

bollwyvl avatar Apr 03 '24 20:04 bollwyvl

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!

dylex avatar Apr 03 '24 20:04 dylex

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 avatar May 27 '24 18:05 imcovangent

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.

imcovangent avatar Jun 03 '24 09:06 imcovangent

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 avatar Jun 11 '24 23:06 yuvipanda

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

yuvipanda avatar Jun 12 '24 00:06 yuvipanda

@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.

yuvipanda avatar Jun 13 '24 20:06 yuvipanda