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

Embed widget should load workspace settings #1964

Closed
bmingles opened this issue Apr 25, 2024 · 1 comment · Fixed by #2068
Closed

Embed widget should load workspace settings #1964

bmingles opened this issue Apr 25, 2024 · 1 comment · Fixed by #2068
Assignees
Labels
enhancement New feature or request web-client-ui
Milestone

Comments

@bmingles
Copy link
Contributor

Some deephaven ui components need formatter settings from the Redux store (e.g. Picker).

As-is, the following query crashes in embed widget:

# import deephaven.ui as ui
# from deephaven.ui import use_state
from deephaven import ui
from deephaven import time_table
from deephaven.plot.figure import Figure
import datetime

default_value=5
initial_row_count=20

column_types = time_table("PT2S", start_time=datetime.datetime.now() - datetime.timedelta(seconds=initial_row_count)).update([
    "Int=new Integer(i)",
    "Double=new Double(i+i/10)",
    "Sin=Math.sin(i)",
    "Cos=Math.cos(i)",
])

@ui.component
def picker():
    value, set_value = ui.use_state(default_value)

    print("Test", value)

    text = ui.text(value, key="text1")

    # Picker for selecting values
    pick = ui.picker(
        column_types,
        key_column="Int",
        label_column="Int",
        label="Picker",
        selection_mode="multiple",
        on_change=set_value,
        selected_key=value,
    )

    # Display picker and output in a flex column
    return ui.flex(
        pick,
        text,
        direction="column",
        margin=10,
        min_height=0, # necessary to avoid overflowing container height
        gap=10,
    )

picker_column_types = picker()

figure = Figure().plot_xy(series_name="Demo", t=column_types, x="Sin", y="Cos").show()
image
@bmingles bmingles added enhancement New feature or request triage Issue requires triage labels Apr 25, 2024
@mattrunyon
Copy link
Collaborator

The selector does work without a workspace, but we don't expose it as a possible external dependency.

So the easiest fix for now is to bump @deepahven/redux in dh.ui as it will then be using the selector that doesn't throw this error.

We'll want to add support for reading user set formatting to embed-grid though in the future

@vbabich vbabich added this to the May 2024 milestone Apr 30, 2024
@vbabich vbabich removed the triage Issue requires triage label Apr 30, 2024
@mattrunyon mattrunyon changed the title Embed widget needs to support getSettings redux selector Embed widget should load workspace settings May 9, 2024
mattrunyon added a commit that referenced this issue May 9, 2024
Fixes deephaven/deephaven-plugins#435

Does not fix the issue in embed-widget. I think that should be a
separate ticket. I'll keep
#1964 open for tracking
that if that seems fine

Tested by creating a dh.ui component that included a table and then
changed the formatter settings. Tried global column formats too (the
formats for specifically named columns)

Looks like ui.table already loads these settings, so this will fix for
normal tables.
@mofojed mofojed modified the milestones: May 2024, June 2024 Jun 4, 2024
mattrunyon added a commit that referenced this issue Jun 12, 2024
Fixes #1964. Also removed a bunch of unnecessary code in `AppInit` where
we were using the redux `connect` API with a functional component
instead of just using the redux hooks

Note that even though this moves a bunch of files to `app-utils`, I
don't consider it breaking since they are being moved out of
`code-studio`. They wouldn't be consumed by anything else since
`code-studio` is published as a bundle.

Due to local storage requiring a port match, this can only be tested w/
the local server in 2 steps (this should be fine in prod since the app
and embed-widget run on the same port there).

1. Start the dev server and go to the app
2. Run some code to create a table.
3. Change user formatting settings (e.g. show timezones and have a
timestamp column)
4. Stop the dev server.
5. Run `PORT=4000 npm run start:embed-widget`. This will let us access
the saved workspace from the app
6. Go to `localhost:4000/?name=<your-variable-name>`
7. The formatting settings should be applied
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request web-client-ui
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants