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

feat: Theming - Moved ThemeProvider updates into effect #1682

Merged
merged 5 commits into from
Dec 13, 2023

Conversation

bmingles
Copy link
Contributor

@bmingles bmingles commented Dec 11, 2023

Moved ThemeProvider updates into effect
resolves #1681

@bmingles bmingles changed the title Theming - Moved ThemeProvider updates into effect feat: Theming - Moved ThemeProvider updates into effect Dec 11, 2023
@bmingles bmingles marked this pull request as ready for review December 11, 2023 14:38
Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (ce7c33f) 46.71% compared to head (ae25ea6) 46.73%.
Report is 1 commits behind head on main.

Files Patch % Lines
...ackages/components/src/RandomAreaPlotAnimation.tsx 0.00% 2 Missing ⚠️
packages/chart/src/ChartThemeProvider.tsx 0.00% 1 Missing ⚠️
packages/iris-grid/src/IrisGridThemeProvider.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1682      +/-   ##
==========================================
+ Coverage   46.71%   46.73%   +0.02%     
==========================================
  Files         606      606              
  Lines       36769    36757      -12     
  Branches     9231     9227       -4     
==========================================
+ Hits        17176    17179       +3     
+ Misses      19541    19526      -15     
  Partials       52       52              
Flag Coverage Δ
unit 46.73% <60.00%> (+0.02%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}
}, [activeThemes]);
const chartTheme = useMemo(
() => (activeThemes == null ? null : defaultChartTheme()),
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem right...
Looking at ChartModelFactory.makeModel, it's always expecting a non-null theme. Why are we allowing the theme to be null here? Shouldn't it always call defaultChartTheme() and possibly even throw if it's null?
Same comment under IrisGridThemeProvider.

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 activeThemes needs to remain null until plugins load to differentiate pending load vs an empty array that would designate plugins loaded, but no custom themes. We could use the default chart theme / grid theme, but seemed like unnecessary parsing when we know loading isn't complete yet. The IrisGridThemeContext and ChartThemeContext support null for the theme, but the consumers can opt to throw or provided a default if theme is null. useChartTheme throws if null, while IrisGrid handles the default if no theme is present.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, this is just in the bootstrapping process that it's null.

Wondering if we should just change PluginsBootstrap to not render children until plugins are actually loaded; we need it for auth and for theming, which are the next things that get loaded ... then we wouldn't have to worry about having null plugins here. What do you think?
The initialization order in AppBootstrap.tsx could be something like:

<ClientBootstrap ...>
  <PluginsBootstrap ...>
    <ThemeBootstrap ...>

Copy link
Contributor Author

@bmingles bmingles Dec 11, 2023

Choose a reason for hiding this comment

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

I think that would work in DHC, but IIR, I think it bites us in DHE due to Login component being further down the tree. I guess they don't have to be implemented the same, but removing the possibility of things being null may cause us trouble trying to use the providers in DHE since they will have to support null for some cases.

Copy link
Member

Choose a reason for hiding this comment

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

We're not even using PluginsBootstrap or PluginsContext in DHE... and yeah on DHE we can't load worker plugins until user is actually authenticated. We will need to wire up PluginsContext there at some point... regardless, why would we ever want to return null here? I think that's breaking the contract of what this bootstrap component should do, and may make it confusing to debug later.

I'd gate PluginsBootstrap, and these as well so there's never nulls. On Enterprise, it'll need to have it's own plugin bootstrapping step.

@bmingles bmingles force-pushed the 1681-move-theme-provider-updates branch from 3ab65c8 to b689d43 Compare December 11, 2023 21:22
@mofojed mofojed merged commit a09bdca into deephaven:main Dec 13, 2023
4 of 5 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2023
@bmingles bmingles deleted the 1681-move-theme-provider-updates branch December 13, 2023 22:53
@bmingles bmingles linked an issue Jan 2, 2024 that may be closed by this pull request
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.

Theming - Move ThemeProvider updates into useEffect
2 participants