Skip to content

feat(frontend): Create theme provider#936

Merged
google-oss-prow[bot] merged 1 commit intokubeflow:mainfrom
jenny-s51:create-theme-provider
Apr 8, 2025
Merged

feat(frontend): Create theme provider#936
google-oss-prow[bot] merged 1 commit intokubeflow:mainfrom
jenny-s51:create-theme-provider

Conversation

@jenny-s51
Copy link
Copy Markdown
Member

@jenny-s51 jenny-s51 commented Apr 1, 2025

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

  • Creates a new react context and wraps the entire app from within bootstrap.tsx.
  • Changes all instances of isMUITheme() function call to a isMUITheme variable and assign the variable from the context.

How Has This Been Tested?

On line 17 of const.ts , change Theme.MUI to Theme.Default and verify UI updates theme without a new build.

Merge criteria:

  • All the commits have been signed-off (To pass the DCO check)
  • The commits have meaningful messages; the author will squash them after approval or in case of manual merges will ask to merge with squash.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work.
  • Code changes follow the kubeflow contribution guidelines.
  • For first time contributors: Please reach out to the Reviewers to ensure all tests are being run, ensuring the label ok-to-test has been added to the PR.

If you have UI changes

  • The developer has added tests or explained why testing cannot be added.
  • Included any necessary screenshots or gifs if it was a UI change.
  • Verify that UI/UX changes conform the UX guidelines for Kubeflow.

@jenny-s51 jenny-s51 marked this pull request as draft April 1, 2025 19:53
@jenny-s51 jenny-s51 marked this pull request as ready for review April 2, 2025 19:53
@jenny-s51 jenny-s51 force-pushed the create-theme-provider branch from 7c18faf to cdca5ef Compare April 2, 2025 19:53
@christianvogt
Copy link
Copy Markdown
Contributor

/lgtm

tested mui and default themes

@google-oss-prow
Copy link
Copy Markdown
Contributor

@christianvogt: changing LGTM is restricted to collaborators

Details

In response to this:

/lgtm

tested mui and default themes

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.

Copy link
Copy Markdown
Contributor

@lucferbux lucferbux left a comment

Choose a reason for hiding this comment

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

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 = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds good, thanks @lucferbux - opened opendatahub-io/mod-arch-library#4

@lucferbux
Copy link
Copy Markdown
Contributor

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 ...ContextProvider convention @jenny-s51 would be ok for me. cc @christianvogt

};

export const ThemeContext = React.createContext({
isMUITheme: true,
Copy link
Copy Markdown
Contributor

@christianvogt christianvogt Apr 4, 2025

Choose a reason for hiding this comment

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

@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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @christianvogt! Updated to false

@google-oss-prow google-oss-prow Bot added size/XL and removed size/L labels Apr 7, 2025
@jenny-s51 jenny-s51 force-pushed the create-theme-provider branch 4 times, most recently from ab524d3 to 7914113 Compare April 7, 2025 17:12
@google-oss-prow google-oss-prow Bot added size/L and removed size/XL labels Apr 7, 2025
@jenny-s51 jenny-s51 force-pushed the create-theme-provider branch from b04a139 to 69c5db7 Compare April 7, 2025 17:33
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
@jenny-s51 jenny-s51 force-pushed the create-theme-provider branch from 4c367b1 to 95421b8 Compare April 7, 2025 17:42
Copy link
Copy Markdown
Contributor

@lucferbux lucferbux left a comment

Choose a reason for hiding this comment

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

/lgtm

<EmptyModelRegistryState
testid="empty-model-registries-state"
title={isMUITheme() ? 'Deploy a model registry' : 'Request access to model registries'}
title="Deploy a model registry"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should still have both text here, in kubeflow we deploy a model registry but midstream we reqeust access to it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we either remove it everywhere (see line 70) or we maintain the conditional rendering.

) : (
<Divider />
)
<TitleWithIcon title="Model Registry" objectType={ProjectObjectType.registeredModels} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can agree that the administration section should not live upstream.

data-testid="model-versions-table-search"
/>
)}
<FormFieldset
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we are allowing to set the flag upstream, this will introduce breaks if a user decide to set THEME=default ?

@google-oss-prow
Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow Bot merged commit c4d4613 into kubeflow:main Apr 8, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants