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

feat: UI table respond to non-primitive prop changes #1046

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mattrunyon
Copy link
Collaborator

Fixes #982

Also fixes a bug I found while implementing this where adding a custom column in the UI would cause formatting rule if_ clauses to be removed.

Also noticed I had copy-pasted the "UI table formatting" tests from "UI flex" and forgot to change the describe title, so I corrected the test name (that is the majority of the snapshot changes)

@mattrunyon mattrunyon requested a review from a team November 27, 2024 18:00
@mattrunyon mattrunyon self-assigned this Nov 27, 2024
@mattrunyon mattrunyon requested review from dgodinez-dh and mofojed and removed request for a team and dgodinez-dh November 27, 2024 18:00

const log = Log.module('@deephaven/js-plugin-ui/UITable');

function useDeepEquals<T>(value: T): T {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth placing this in it's own file so it can be used in other code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I think this and the other hook would be good in @deephaven/react-hooks, but I was being lazy and avoiding needing to merge to web-client-ui, publish, then consume here. I can do that though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add JS docs for this hook as well.

!array.every((v, i) => v === stableArray.current[i])
) {
stableArray.current = array;
function useThrowError(): [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this hook.

@@ -22,27 +22,63 @@ import { type dh as DhType } from '@deephaven/jsapi-types';
import { ColorGradient, DatabarConfig, FormattingRule } from './UITableUtils';
import JsTableProxy, { UITableLayoutHints } from './JsTableProxy';

/**
* Create a UITableModel.
* WARNING: This may mutate the baseTable object to add customColumns for formatting.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we copy the baseTable to avoid mutating it? Or is it desirable for other code to have it mutated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right. Initially I was incorrectly thinking if I copied the table the original might have a subscription that gets left open. But if that's the case, it would be up to the caller to handle that subscription anyway.

Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small cleanup

}) {
this.table = table;
this.originalCustomColumns = table.customColumns;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May just want to do a table.copy() and apply custom columns to that/use that table so the original table doesn't get messed with.


const log = Log.module('@deephaven/js-plugin-ui/UITable');

function useDeepEquals<T>(value: T): T {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add JS docs for this hook as well.


const alwaysFetchColumns = useMemo(() => {
if (alwaysFetchColumnsArray[0] === true) {
if (modelColumns.length > 500) {
if (columns.length > 500) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The 500 should be a constant, as it's used in the error message below.

setError(
`Table has ${modelColumns.length} columns, which is too many to always fetch. ` +
`Table has ${columns.length} columns, which is too many to always fetch. ` +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the useThrowError hook above here. Looks like you only used in useUITableModel even though it applies here as well.

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 this pull request may close these issues.

ui.table respond to format prop changes
3 participants