-
Notifications
You must be signed in to change notification settings - Fork 29
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
Save smooth plot values across sessions #4220
Conversation
c436daf
to
ef70d30
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't figure out why the window's jest tests are failing (posted details in a comment) but everything else is ready to go
webview/src/plots/components/templatePlots/TemplatePlotsGrid.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few things to work through
@@ -30,6 +31,7 @@ export const ZoomablePlot: React.FC<ZoomablePlotProps> = ({ | |||
const { data, content: spec } = useGetPlot(section, id, createdSpec) | |||
const dispatch = useDispatch() | |||
const currentPlotProps = useRef<VegaLiteProps>() | |||
const onPlotViewReady = useSetupSmoothPlot(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[C] I think this could have a more descriptive name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Q] Also, would it be a better idea to pass this in for smooth plots only instead of calling this for all zoomable plots? Unless I have missed something custom plots should never need to call useSetupSmoothPlot
and having the hook floating around for all plots makes things harder to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code for smooth plots have now been moved to a react component, which is used for template plots only.
webview/src/plots/components/templatePlots/TemplatePlotsGrid.tsx
Outdated
Show resolved
Hide resolved
webview/src/plots/components/templatePlots/TemplatePlotsGrid.tsx
Outdated
Show resolved
Hide resolved
@@ -285,7 +297,8 @@ export class WebviewMessages { | |||
nbItemsPerRow: this.plots.getNbItemsPerRowOrWidth( | |||
PlotsSection.TEMPLATE_PLOTS | |||
), | |||
plots | |||
plots, | |||
smoothPlotValues: this.plots.getSmoothPlotValues() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Q] What was the reason for keeping this separate from the plots data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't think of it 🤦♀️.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ended up keeping it separate for now so we could watch for changes to values by just watching the values instead of snapshots
which would cause unnecessary checks.
@@ -48,8 +48,9 @@ export const TemplatePlotsGrid: React.FC<TemplatePlotsGridProps> = ({ | |||
|
|||
const addDisabled = useCallback( | |||
(e: Event) => { | |||
const disabledId = (e.currentTarget as HTMLFormElement).parentElement | |||
?.parentElement?.parentElement?.id | |||
const disabledId = (e.currentTarget as HTMLFormElement).closest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an extra wrapper for a ref
so I changed this code to use closest
instead of trying to adjust for another parentElement
since this looks cleaner to me. Any reason why we weren't using closest
in the first place though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would need to go back and check around #2747
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info! Not seeing any comments on this particular line in the prs relating to this code, but my guess on why we were using parentElement
is because it's technically faster since closest
keeps checking up to the root
. I don't think this code gets fired too often (only when user's mouse enters .vega-actions
) so should be alright to use 🤔
Alright resolved/responded to comments and added a debounce timer for keyboard events (thanks for spotting that, @mattseddon!). Going to request reviews since the code has changed quite a bit! |
Code Climate has analyzed commit c2ca400 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 97.1% (85% is the threshold). This pull request will bring the total coverage in the repository to 95.2%. View more on Code Climate. |
Demo
Screen.Recording.2023-07-11.at.2.51.42.PM.mov
Part of #3223