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

Plot list virtualization #1707

Merged
merged 11 commits into from
May 19, 2022
Merged

Plot list virtualization #1707

merged 11 commits into from
May 19, 2022

Conversation

sroy3
Copy link
Contributor

@sroy3 sroy3 commented May 13, 2022

Scroll down for video (I tried many different things to get it to upload in the description, but always hit an error).

@sroy3 sroy3 added the product PR that affects product label May 13, 2022
@sroy3 sroy3 self-assigned this May 13, 2022
@@ -85,6 +106,14 @@ export const CheckpointPlots: React.FC<CheckpointPlotsProps> = ({
element: <DropTarget />,
wrapperTag: 'div'
}}
wrapperComponent={
Copy link

Choose a reason for hiding this comment

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

Identical blocks of code found in 2 locations. Consider refactoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try to remove having to pass the component to the DragDropContainer altogether.

Copy link
Member

Choose a reason for hiding this comment

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

[Q] Do we think there will be a different component that will wrap the d'n'd container? If not then why not be specific and give it a needsBigGrid or shouldVirtualize prop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comparison table should have drag and drop rows (not implemented yet), if we do virtualize them, it won't be a grid, but a list. We could also pass a VirtualizedWith and then use an enum for values. I still think the DragDropContainer should not have to deal with that component, I think I can do something with the children instead.

@@ -99,6 +105,14 @@ export const TemplatePlotsGrid: React.FC<TemplatePlotsGridProps> = ({
element: <DropTarget />,
wrapperTag: 'div'
}}
wrapperComponent={
Copy link

Choose a reason for hiding this comment

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

Identical blocks of code found in 2 locations. Consider refactoring.

@sroy3
Copy link
Contributor Author

sroy3 commented May 17, 2022

Screen.Recording.2022-05-17.at.2.29.44.PM.mov

@sroy3 sroy3 marked this pull request as ready for review May 17, 2022 18:42
@sroy3 sroy3 requested review from a team and shcheklein May 17, 2022 18:43
expect(screen.queryByRole('grid')).not.toBeInTheDocument()
})

describe('Sizing', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of these tests look similar and seem like they aren't testing what their name implies, but depending on plot size and screen size, the number of items per row changes and react-virtualized grid renders the items according to their column and row index, which is calculated with the nbItemsPerRow prop. If it does not use the right number, the plots will be rendered in another order and there might be plots missing.

changePlotsSizes: ((size: PlotSize, section: Section) => void) | undefined
}

export const PlotsSizeContext = createContext<PlotsSizeContextValue>({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This acts as a global state for the sizes, but will re-render everything when we change the size of a plot section, while using a store would only re-render what uses it.

Copy link
Member

Choose a reason for hiding this comment

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

...next stop Redux

Copy link
Member

@mattseddon mattseddon left a comment

Choose a reason for hiding this comment

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

This is really good. I had some minor comments throughout the PR but they were only suggestions so feel free to disregard them.

I did notice some weirdness with dragging and dropping within storybook:

Screen.Recording.2022-05-18.at.8.20.41.pm.mov

Virtualized plots being dragged into view maybe? Hard to tell when all the plots are the same.

The placeholder for a new template section is also a bit oversized now:

Screen.Recording.2022-05-18.at.8.34.41.pm.mov

Happy to merge and follow up to fix the bugs.

extension/src/test/fixtures/expShow/checkpointPlots.ts Outdated Show resolved Hide resolved
extension/src/test/fixtures/plotsDiff/template/index.ts Outdated Show resolved Hide resolved
webview/src/plots/components/App.test.tsx Outdated Show resolved Hide resolved
webview/src/plots/components/App.test.tsx Outdated Show resolved Hide resolved
webview/src/plots/components/App.test.tsx Outdated Show resolved Hide resolved
</DragDropProvider>

{zoomedInPlot && (
Copy link
Member

Choose a reason for hiding this comment

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

[Q] Should this have always been outside of the d'n'd provider?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not really matter as we can't really drag and drop while zoomed in, but still since those two providers do nothing on zoomed in plot and that it re-renders every children on change, I thought it best to remove it from there.

changePlotsSizes: ((size: PlotSize, section: Section) => void) | undefined
}

export const PlotsSizeContext = createContext<PlotsSizeContextValue>({
Copy link
Member

Choose a reason for hiding this comment

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

...next stop Redux

@@ -85,6 +106,14 @@ export const CheckpointPlots: React.FC<CheckpointPlotsProps> = ({
element: <DropTarget />,
wrapperTag: 'div'
}}
wrapperComponent={
Copy link
Member

Choose a reason for hiding this comment

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

[Q] Do we think there will be a different component that will wrap the d'n'd container? If not then why not be specific and give it a needsBigGrid or shouldVirtualize prop?

@sroy3
Copy link
Contributor Author

sroy3 commented May 18, 2022

Drag and drop has been fixed:

Screen.Recording.2022-05-18.at.4.16.27.PM.mov
Screen.Recording.2022-05-18.at.4.16.08.PM.mov

@codeclimate
Copy link

codeclimate bot commented May 19, 2022

Code Climate has analyzed commit 7ce71ae and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

The test coverage on the diff in this pull request is 100.0% (85% is the threshold).

This pull request will bring the total coverage in the repository to 96.7% (0.1% change).

View more on Code Climate.

@sroy3 sroy3 merged commit f7702f6 into main May 19, 2022
@sroy3 sroy3 deleted the react-virtualized branch May 19, 2022 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR that affects product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants