feat(frontend): Create theme provider#936
Conversation
7c18faf to
cdca5ef
Compare
|
/lgtm tested mui and default themes |
|
@christianvogt: changing LGTM is restricted to collaborators DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
lucferbux
left a comment
There was a problem hiding this comment.
I wanna have a conversation about this, need to know what's the main purpose.
| @@ -0,0 +1,11 @@ | |||
| import * as React from 'react'; | |||
|
|
|||
| type ThemeContextProps = { | |||
There was a problem hiding this comment.
This is just a nit, but in the dashboard we tend to get both Context and ContextProvider in the same file, we usually call the file <specific-name>Context and inside we have both things. can we follow that pattern here?
There was a problem hiding this comment.
Nice catch @lucferbux - renamed the ThemeProvider.tsx to ThemeContext.tsx which applies the pattern you mention here: https://github.com/kubeflow/model-registry/pull/936/files#diff-3d6c136c679e4743b6813190737e2a47ec4a71e6283d06c9da4546fa7c8a522f
There was a problem hiding this comment.
@jenny-s51 Lucas is suggesting you move both the provider and context into the same file (also include the hook). Looks like there's still two different files: MUIThemeContext and ThemeContext
| @@ -0,0 +1,35 @@ | |||
| import * as React from 'react'; | |||
There was a problem hiding this comment.
Another nit, but I'll fix that in my PR, this should go to the shared library since it's gonna be used everywhere, I'm refactoring that a little bit so we can keep it here for this PR.
There was a problem hiding this comment.
Sounds good, thanks @lucferbux - opened opendatahub-io/mod-arch-library#4
|
Ok, deleted one of the comments, I didn't understand the main goal, now it's clear, if we can address the nit of the |
| }; | ||
|
|
||
| export const ThemeContext = React.createContext({ | ||
| isMUITheme: true, |
There was a problem hiding this comment.
@jenny-s51 I think this should be set to false to match the default component library being used. And the default style.
Or maybe this can read the env variable?
ab524d3 to
7914113
Compare
b04a139 to
69c5db7
Compare
Signed-off-by: Jenny <32821331+jenny-s51@users.noreply.github.com> fix UI loading bug Signed-off-by: Jenny <32821331+jenny-s51@users.noreply.github.com> rename ThemeProvider, remove conditional rendering for upstream Signed-off-by: Jenny <32821331+jenny-s51@users.noreply.github.com> remove unused imports Signed-off-by: Jenny <32821331+jenny-s51@users.noreply.github.com> delete ThemeContext.ts and move logic to ThemeContext.tsx Signed-off-by: Jenny <32821331+jenny-s51@users.noreply.github.com> reapply conditionals Signed-off-by: Jenny <32821331+jenny-s51@users.noreply.github.com> revert to isMUITheme
4c367b1 to
95421b8
Compare
| <EmptyModelRegistryState | ||
| testid="empty-model-registries-state" | ||
| title={isMUITheme() ? 'Deploy a model registry' : 'Request access to model registries'} | ||
| title="Deploy a model registry" |
There was a problem hiding this comment.
we should still have both text here, in kubeflow we deploy a model registry but midstream we reqeust access to it.
There was a problem hiding this comment.
we either remove it everywhere (see line 70) or we maintain the conditional rendering.
| ) : ( | ||
| <Divider /> | ||
| ) | ||
| <TitleWithIcon title="Model Registry" objectType={ProjectObjectType.registeredModels} /> |
There was a problem hiding this comment.
Same here, in muiTheme we don't want TitleWithIcon we cant the title with the divider, that's the look with mui, with default is the this way. And muitheme shouldn't have a description.
| <Divider /> | ||
| ) | ||
| } | ||
| title="Model Registry" |
There was a problem hiding this comment.
Here we are. goin with title rather than title with icon, let's just make it more consisten, we need to move the conversation to agree on a solution.
| popoverPosition={PopoverPosition.left} | ||
| /> | ||
| )} | ||
| <KubeflowDocs |
There was a problem hiding this comment.
I can agree that the administration section should not live upstream.
| data-testid="model-versions-table-search" | ||
| /> | ||
| )} | ||
| <FormFieldset |
There was a problem hiding this comment.
If we are allowing to set the flag upstream, this will introduce breaks if a user decide to set THEME=default ?
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lucferbux The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Model registry UI uses env variables to switch themes which requires a completely separate build in order to use a different theme. When consuming model registry UI through module federation, it should be possible to assign the theme at runtime.
It will use an env variable to assign the default theme and it should also be possible to switch themes at runtime.
Description
isMUITheme()function call to aisMUIThemevariable and assign the variable from the context.How Has This Been Tested?
On line 17 of const.ts , change
Theme.MUItoTheme.Defaultand verify UI updates theme without a new build.Merge criteria:
DCOcheck)ok-to-testhas been added to the PR.If you have UI changes