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

ui.table Context menu actions (.context_menu) #321

Closed
Tracked by #77
mofojed opened this issue Feb 28, 2024 · 2 comments · Fixed by #522
Closed
Tracked by #77

ui.table Context menu actions (.context_menu) #321

mofojed opened this issue Feb 28, 2024 · 2 comments · Fixed by #522
Assignees
Milestone

Comments

@mofojed
Copy link
Member

mofojed commented Feb 28, 2024

Dependent on #322
Once that's done, this should be fairly straightforward.

@mofojed mofojed mentioned this issue Feb 28, 2024
20 tasks
@mofojed mofojed changed the title ui.table Context menu actions ui.table Context menu actions (.context_menu) Feb 28, 2024
@mofojed mofojed added this to the April 2024 milestone Apr 15, 2024
@mofojed mofojed modified the milestones: April 2024, May 2024 May 28, 2024
@mofojed
Copy link
Member Author

mofojed commented May 28, 2024

Do it with statically defined menu items first, then work on #322 for asynchronously generated context menu items.
Verify design doc has cases for header vs. body menus.

@mofojed
Copy link
Member Author

mofojed commented May 28, 2024

Need to nail down the syntax (should be a prop instead of immutable fluent interface as it's currently defined, as per Don: https://github.com/deephaven/deephaven-plugins/blob/main/plugins/ui/DESIGN.md#context_menu)

Focus on just defining menu items for now, asynchronously building the menu using a callback can be done as a separate ticket after #322 is done.

mattrunyon added a commit that referenced this issue Jun 19, 2024
Fixes #322. Will be required for full completion of #321.

Currently a little hard to test, but this should demonstrate it if you
watch the JS debug logs on `WidgetHandler`.

Run this Python code.

- The `Normal` button should behave the same as latest dh.ui.
- The `Nested` button will return a callable as the direct result of the
callback function. This should allow us to do `const fn = await
callable(args);` basically. It is not called, but there is a log from
`WidgetHandler` after 5-10s that it was cleaned up. Or you can use the
`Memory` tab in dev tools and click the broom icon to trigger a manual
GC.
- The `Double Nested` button will return and wrap an object containing a
new callable. You can filter the browser logs for `WidgetUtils` and look
for `callable ID result string` which won't have the parsed function,
but will contain the object representing it as well as the other parts
of the returned object.
- The `Not serializable` button will basically do nothing except log an
error in the Python console. The returned result will include that it
was a serialization error to JS, but we do nothing with it.

```py
from deephaven import ui

@ui.component
def my_comp():
    on_press = ui.use_callback(lambda d: print(d), [])
    on_press_nested = ui.use_callback(lambda: print, [])
    on_press_double_nested = ui.use_callback(lambda: { "nestedFn": print, "some_val": 4 }, [])
    on_press_unserializable = ui.use_callback(lambda: set([1, 2, 3]), [])
    return [
        ui.button("Normal", on_press=on_press),
        ui.button("Nested", on_press=on_press_nested),
        ui.button("Double Nested", on_press=on_press_double_nested),
        ui.button("Not Serializable", on_press=on_press_unserializable)
    ]

c = my_comp()
```
mattrunyon added a commit that referenced this issue Jun 28, 2024
Fixes #321

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

```py
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()
```
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