deephaven / deephaven-plugins

Deephaven Plugins
11 stars 14 forks source link

feat: ui.table context menu items #522

Closed mattrunyon closed 3 months ago

mattrunyon commented 4 months ago

Fixes #321

Use my branch of web-client-ui to test. The necessary changes are in an external package for the plugin, so don't need to do anything special w/ the plugins. https://github.com/deephaven/web-client-ui/pull/2083

Here's an example with a context menu item on the row and a sub-menu action item on the header

from deephaven import empty_table, time_table, ui

@ui.component
def my_comp():
    t = time_table("PT1S").update(["X=i", "Y=i"])

    return ui.table(
        t,
        context_items=[{ "title": "Test", "action": lambda d: print(d)}],
        context_column_header_items=[
            {
                "title": "Header",
                "actions": [{ "title": "Header-sub", "action": lambda d: print(d)}]
            }
        ]
    )

c = my_comp()
mattrunyon commented 4 months ago

I'm wondering if we should even have context_row_header_items in the spec. We don't currently have row headers in iris-grid, and if we did they would probably be row numbers. Those row numbers are meaningless to the server unless we have keyed rows and use the key as the row header

It's something that wouldn't be hard to add to UITable if we added support/reason for it in iris-grid. But right now there is no reason for it

dsmmcken commented 3 months ago

I feel strongly that the word "context menu" must appear in the name.

context_actions or context_items are not things. It's not just a "context", it's a "context menu". There's no such thing as context having meaning without the word menu beside it. It's a compound noun.

It's like ice cream. You wouldn't label something as ice cone. That's not a thing, it's an ice cream cone. It's a compound noun.

mattrunyon commented 3 months ago

context_menu_items and column_header_context_menu_items? context_menu_column_header_items to me sounds like the context menu has some column_header that I can put items in

Another option would be just context_menu_items and then a dict w/ keys cell and column_header and values for the items, but I think that's probably less Pythonic

dsmmcken commented 3 months ago

what about just context_menu and context_header_menu?

mattrunyon commented 3 months ago

Might be able to add async menu items to this PR if the callables returning callables PR merges first. Feels like that one is close