Fix Send to Active Notebook functionality#341
Conversation
- Added `getLastUsedPanelOfTypes` to PanelManager (will be needed for Enterprise) - Clean up some of the TypeScript types
| registerComponent( | ||
| NotebookPanel.COMPONENT, | ||
| (NotebookPanel as unknown) as ComponentType | ||
| (FileExplorerPanel as unknown) as PanelComponentType |
There was a problem hiding this comment.
@mattrunyon any idea how to get TypeScript typings correct so we don't need to explicitly convert this one? I'm having a hard time getting TypeScript to co-operate here.
There was a problem hiding this comment.
The error:
Argument of type 'ConnectedComponent<typeof FileExplorerPanel, Omit<ClassAttributes<FileExplorerPanel> & PanelProps & { localDashboardId: string; metadata?: Record<...> | undefined; } & StateProps & DispatchProp<...>, "dispatch" | ... 2 more ... | "fileStorage"> & PanelProps & { ...; }>' is not assignable to parameter of type 'PanelComponentType<ComponentClass<{}, any>, Omit<ClassAttributes<FileExplorerPanel> & PanelProps & { localDashboardId: string; metadata?: Record<...> | undefined; } & StateProps & DispatchProp<...>, "dispatch" | ... 2 more ... | "fileStorage"> & PanelProps & { ...; }>'.
Type 'ConnectedComponent<typeof FileExplorerPanel, Omit<ClassAttributes<FileExplorerPanel> & PanelProps & { localDashboardId: string; metadata?: Record<...> | undefined; } & StateProps & DispatchProp<...>, "dispatch" | ... 2 more ... | "fileStorage"> & PanelProps & { ...; }>' is not assignable to type 'FunctionComponent<{}>'.
Types of parameters 'props' and 'props' are incompatible.
Type '{ children?: ReactNode; }' is not assignable to type 'Omit<ClassAttributes<FileExplorerPanel> & PanelProps & { localDashboardId: string; metadata?: Record<string, unknown> | undefined; } & StateProps & DispatchProp<...>, "dispatch" | ... 2 more ... | "fileStorage"> & PanelProps & { ...; }'.
Type '{ children?: ReactNode; }' is missing the following properties from type 'Omit<ClassAttributes<FileExplorerPanel> & PanelProps & { localDashboardId: string; metadata?: Record<string, unknown> | undefined; } & StateProps & DispatchProp<...>, "dispatch" | ... 2 more ... | "fileStorage">': glContainer, glEventHub, localDashboardIdts(2345)
Codecov Report
@@ Coverage Diff @@
## main #341 +/- ##
=========================================
+ Coverage 5.94% 12.42% +6.48%
=========================================
Files 2 17 +15
Lines 202 1199 +997
Branches 35 255 +220
=========================================
+ Hits 12 149 +137
- Misses 190 989 +799
- Partials 0 61 +61
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
| panelManager.getLastUsedPanelOfTypes([TestComponentA, TestComponentB]) | ||
| ).toBe(panelB); | ||
| expect( | ||
| panelManager.getLastUsedPanelOfTypes([TestComponentB, TestComponentB]) |
There was a problem hiding this comment.
I made a typo in the original code, this was supposed to be
| panelManager.getLastUsedPanelOfTypes([TestComponentB, TestComponentB]) | |
| panelManager.getLastUsedPanelOfTypes([TestComponentB, TestComponentA]) |
| types.some( | ||
| type => | ||
| panel instanceof type || | ||
| (isWrappedComponent(type) && |
There was a problem hiding this comment.
Can we get away with a simple panel => panel instanceof type check here? just pass unwrapped components to getLastUsedPanelOfTypes and skip the isWrappedComponent check? I didn't think of this solution when I added this on the enterprise side, then I saw you had it simplified in DHC. Then I guess remove | WrappedComponentType<C, P> from the PanelComponentType definition too.
There was a problem hiding this comment.
I've fixed this, but for posterity, we still need the WrappedComponentType for registerComponent anyway, so may as well make it work right!
- Flip the P and C template parameters around, so C can include the props type P - Include the template parameters in the registerComponent and getLastUsedPanelOfTypes
getLastUsedPanelOfTypesto PanelManager (will be needed for Enterprise)