Skip to content

feat: DH-14581 usePanelRegistration hook#1208

Merged
bmingles merged 4 commits intodeephaven:mainfrom
bmingles:1207-use-panel-registration
Apr 6, 2023
Merged

feat: DH-14581 usePanelRegistration hook#1208
bmingles merged 4 commits intodeephaven:mainfrom
bmingles:1207-use-panel-registration

Conversation

@bmingles
Copy link
Copy Markdown
Contributor

@bmingles bmingles commented Apr 5, 2023

Supports Enterprise DH-14581

resolves #1207

@bmingles bmingles force-pushed the 1207-use-panel-registration branch from 26deadb to 751e335 Compare April 5, 2023 20:55
@bmingles bmingles requested a review from mofojed April 5, 2023 21:03
@bmingles bmingles marked this pull request as ready for review April 5, 2023 21:03
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 5, 2023

Codecov Report

Merging #1208 (afd165f) into main (59d3df4) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1208      +/-   ##
==========================================
+ Coverage   44.20%   44.21%   +0.01%     
==========================================
  Files         448      449       +1     
  Lines       33437    33445       +8     
  Branches     8404     8406       +2     
==========================================
+ Hits        14781    14789       +8     
  Misses      18606    18606              
  Partials       50       50              
Flag Coverage Δ
unit 44.21% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/dashboard/src/DashboardPlugin.ts 18.18% <ø> (ø)
...kages/dashboard/src/layout/usePanelRegistration.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

mofojed
mofojed previously approved these changes Apr 5, 2023
Copy link
Copy Markdown
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.

Just a minor suggestion for using null coalescing, but looks great!

Comment on lines +28 to +31
const name =
'COMPONENT' in ComponentType
? ComponentType.COMPONENT
: ComponentType.displayName;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you can just use null coalescing to handle this:

Suggested change
const name =
'COMPONENT' in ComponentType
? ComponentType.COMPONENT
: ComponentType.displayName;
const name = ComponentType.COMPONENT ?? ComponentType.displayName;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I actually did that originally, but the type system complains when you access ComponentType.COMPONENT without verifying it's there

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

nvm, fixed it in the types

/**
* Registers a given panel component. Also runs a `useEffect` that will
* automatically de-register then panel on unmount.
* @param registerComponent
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We might not want this as part of the hook. Bender and I chatted about plugins the other day and there's a lot of rough edges and things that need to be cleaned up around their implementation. Basically we should be able to write our existing plugins all as external plugins in an ideal world

hydrate and dehydrate are the same. IMO they are logic that belong in the component, not at the registration point. Our existing hydration code is in AppMainContainer which separates it from where the hydration is actually used.

I don't think they're changes that should be in this PR, but just something to note that this will probably change signatures as we address those points

mofojed
mofojed previously approved these changes Apr 6, 2023
Copy link
Copy Markdown
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.

@mattrunyon hydration has to be available at the app level, but we should be moving widget panels to just use the default hydration when possible. metadata for data about the widget, fetch to get the object, panelState for storing any previous state set by the user.


export type PanelFunctionComponentType<P> = NamedExoticComponent<P> & {
COMPONENT?: string;
TITLE?: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this is used here and in PanelComponentType, may want to separate it out and add some JSDocs about what each is for

@bmingles bmingles merged commit d8db9ca into deephaven:main Apr 6, 2023
@bmingles bmingles deleted the 1207-use-panel-registration branch April 6, 2023 19:33
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 6, 2023
@bmingles bmingles changed the title feat: usePanelRegistration hook feat: DH-14581 usePanelRegistration hook Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DH-14581: usePanelRegistration hook

3 participants