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

chore: Upgraded @deephaven/jsapi-types to 1.0.0-dev0.33.2 (#389) #390

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

bmingles
Copy link
Contributor

resolves #389

@bmingles bmingles requested a review from mofojed March 25, 2024 21:50
plugins/ui/src/js/src/DashboardPlugin.tsx Show resolved Hide resolved
@@ -22,7 +22,7 @@ function ObjectView(props: ObjectViewProps) {
() =>
[...plugins.values()]
.filter(isWidgetPlugin)
.find(p => [p.supportedTypes].flat().includes(object.type)),
.find(p => [p.supportedTypes].flat().includes(object.type as string)),
Copy link
Member

Choose a reason for hiding this comment

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

Instead of casting here... Above I'd just set type and then just check if it's null before going through plugins (since we will never be able to open the object if the type isn't defined). Also there's a object == null check that doesn't make sense below (since it's always defined).
So something like :

const { object } = props;
const { type } = object;

...

  const plugin = useMemo(
    () =>
      type != null ? [...plugins.values()]
        .filter(isWidgetPlugin)
        .find(p => [p.supportedTypes].flat().includes(type)) : undefined,
    [plugins, type]
  );

Comment on lines 17 to 24

const Component = getSpectrumComponent(name) as
| React.ComponentType<unknown>
| undefined;

if (Component == null) {
throw new Error(`Unknown Spectrum component ${name}`);
}
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this, we should throw in getSpectrumComponent if there is no type returned. Then this is just const Component = getSpectrumComponent(name) and it all makes sense.

Comment on lines 31 to 33
const openedMetadataRef = useRef<ReactPanelControl['metadata'] | null>(
portal != null ? metadata : null
);
Copy link
Member

Choose a reason for hiding this comment

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

Ahhh good catch. I would've just returned undefined instead of null, since that matches the ReactPanelControl['metadata'] type already.:

Suggested change
const openedMetadataRef = useRef<ReactPanelControl['metadata'] | null>(
portal != null ? metadata : null
);
const openedMetadataRef = useRef<ReactPanelControl['metadata']>(
portal != null ? metadata : undefined
);

@bmingles bmingles requested a review from mofojed March 26, 2024 16:21
@bmingles bmingles merged commit ff4b097 into deephaven:main Mar 27, 2024
12 checks passed
@bmingles bmingles deleted the 389-update-jsapi-types branch March 27, 2024 14:02
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.

Update @deephaven/jsapi-types to latest
2 participants