-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[Dashboard] Upgrade to MUIv5 and dependency updates #45789
Conversation
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.
wow! thanks for tackling this.
We've been using sx props internally and in the ray dashboard code base for new components that we create. Can you update the PR to use sx
props for all the cases where we can easily do it.
Like when using Typography
or Paper
or other mui components
}, | ||
}), | ||
); | ||
const TitleTypography = styled(Typography)(({ theme }) => ({ |
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.
for something like Typography which accepts sx, can we use sx
props instead of styled?
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.
No problem, we can adjust to using sx
as the default.
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.
Have replaced them with sx
, please take a look.
I really have no opinion / saying on this.. this is like pure js land stuff, will leave this to @alanwguo and dashboard / observability team if we need to upgrade npm or something to make this happen, let me know. |
side note: this PR looks rather big, might be easier to get it merge if this can be done in stages, though I do not really know technically how to make it happen. |
Updated the React framework to version 18.3.0. Update lowlight packages and remove unused packages. Signed-off-by: liuxsh9 <[email protected]>
Signed-off-by: liuxsh9 <[email protected]>
Updated the React framework to version 18.3.0. Update lowlight packages and remove unused packages. Signed-off-by: liuxsh9 <[email protected]>
Signed-off-by: liuxsh9 <[email protected]>
Signed-off-by: liuxsh9 <[email protected]>
…les transition package. Upgrade the react and lowlight modules. Signed-off-by: liuxsh9 <[email protected]>
@@ -111,13 +114,15 @@ export const CodeDialogButtonWithPreview = ({ | |||
const buttonTextToPass = buttonText ?? "Expand"; | |||
|
|||
return ( | |||
<div className={classNames(classes.root, className)}> | |||
<span className={classes.previewText}>{codeText}</span> | |||
<Box className={className} sx={Object.assign({}, styles.root, sx)}> |
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.
<Box className={className} sx={Object.assign({}, styles.root, sx)}> | |
<Box className={className} sx={[styles.root, sx]}> |
Please use array syntax instead
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.
Sure! Made a minor adjustment to sx={[styles.root, ...(Array.isArray(sx) ? sx : [sx])]}
to ensure the type matches.
...props | ||
}: CodeDialogButtonWithPreviewProps) => { | ||
const classes = useCodeDialogButtonWithPreviewStyles(); | ||
const styles = useCodeDialogButtonWithPreviewStyles(useTheme()); |
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.
There shouldn't be a need to create an object like this.
When using sx props, you can also easily get access to the theme by passing a function into sx.
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.
In most cases, I would prefer if we inlined styles instead of creating a separate styles object, but this is not a blocker.
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.
Understood, I've removed the redundant object and directly passed the function instead. Additionally, converted some parts to use inlined styles, while leaving the rest as is for readability considerations.
)} | ||
<Box | ||
component={RiLoader4Line} | ||
sx={Object.assign({}, styles.icon(small), styles.iconRunning, sx)} |
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.
please use array syntax
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.
Done
<Box | ||
component={RiCheckboxCircleFill} | ||
className={className} | ||
sx={Object.assign({}, styles.icon(small), styles.colorSuccess, sx)} |
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.
array syntax
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.
Done
Signed-off-by: liuxsh9 <[email protected]>
Signed-off-by: liuxsh9 <[email protected]>
Thanks for the suggestions! We've completed the corresponding modifications. How does the new version look? @alanwguo |
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 went around the UI looking for visual bugs. There was only one that I found.
Thanks for the effort. I think the PR is almost ready.
<Box | ||
component={RiArrowDownSLine} | ||
sx={(theme) => ({ | ||
marginRight: theme.spacing(1), |
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.
marginRight: theme.spacing(1), | |
marginRight: 1, |
nit: sx automatically uses theme spacing values when passing in numbers for margins, padding, border, etc
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.
Got it! Have made the changes.
const useCodeDialogButtonWithPreviewStyles = makeStyles((theme) => | ||
createStyles({ | ||
root: { | ||
display: "flex", | ||
flexWrap: "nowrap", | ||
flexDirection: "row", | ||
gap: theme.spacing(1), | ||
}, | ||
previewText: { | ||
display: "block", | ||
whiteSpace: "nowrap", | ||
overflow: "hidden", | ||
textOverflow: "ellipsis", | ||
flex: 1, | ||
}, | ||
}), | ||
); | ||
|
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.
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.
Fixed.
Signed-off-by: liuxsh9 <[email protected]>
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.
looks great! Thanks. Just some small non-blockers
@@ -17,6 +16,8 @@ import "./github.css"; | |||
import "./index.css"; | |||
import { MAX_LINES_FOR_LOGS } from "../../service/log"; | |||
|
|||
lowlight.registerLanguage("prolog", prolog); |
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.
curious what this is for?
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.
After lowlight 2.0, it introduced three import modes: core
, common
(default), and all
. To prioritize simplicity and extensibility, we opted for the default common
mode, which auto-registers 30+ languages. However, prolog
is not included in the list. Therefore, we need to manually register it here.
wooorm/lowlight@95cd2f6
sx={{ | ||
padding: 2, | ||
paddingTop: 1.5, | ||
margin: (theme) => theme.spacing(2, 1), |
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.
nit:
margin: (theme) => theme.spacing(2, 1), | |
marginX: 1, | |
marginY: 2, |
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.
Good to use a uniform format, have modified them.
Signed-off-by: liuxsh9 <[email protected]>
Signed-off-by: liuxsh9 <[email protected]>
@@ -53,6 +48,11 @@ | |||
"resolutions": { | |||
"@types/react": "16.9.26" | |||
}, | |||
"jest": { | |||
"transformIgnorePatterns": [ |
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.
The new version of lowlight has extended its syntax to TypeScript, which requires additional configuration when using Jest for testing. The official recommendation is to adapt to the following scheme:
- If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
- To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
We are currently adding configuration here, is it suitable?
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 find any thing online about this. What happens if you don't include this?
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.
… in the object. Signed-off-by: liuxsh9 <[email protected]>
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 just did another round of testing. Looks great!
Thanks!!
Why are these changes needed?
This PR replaces the current
makeStyles
in the Dashboard with the MUIv5 recommendedstyled
approach, thereby removing the@mui/styles
transitional package, which facilitates future upgrades and expansions. Additionally, the React framework has been upgraded to version 18.3.0, and lowlight has been upgraded to version 2.9.0.Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.