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

[Dashboard] Upgrade to MUIv5 and dependency updates #45789

Merged
merged 12 commits into from
Jul 2, 2024

Conversation

liuxsh9
Copy link
Contributor

@liuxsh9 liuxsh9 commented Jun 7, 2024

Why are these changes needed?

This PR replaces the current makeStyles in the Dashboard with the MUIv5 recommended styled 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

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@anyscalesam
Copy link
Contributor

@aslonnie @alanwguo can PTAL and see if this is safe to merge; nice to have an upgrade in... and if our CI and release test pass I don't think there is any harm in keeping up to date.

Copy link
Contributor

@alanwguo alanwguo left a 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 }) => ({
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@aslonnie
Copy link
Collaborator

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.

@aslonnie aslonnie removed their request for review June 16, 2024 03:53
@aslonnie aslonnie assigned alanwguo and unassigned aslonnie Jun 16, 2024
@aslonnie
Copy link
Collaborator

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 <liuxiaoshuang4@huawei.com>
Signed-off-by: liuxsh9 <liuxiaoshuang4@huawei.com>
Updated the React framework to version 18.3.0.
Update lowlight packages and remove unused packages.

Signed-off-by: liuxsh9 <liuxiaoshuang4@huawei.com>
Signed-off-by: liuxsh9 <liuxiaoshuang4@huawei.com>
Signed-off-by: liuxsh9 <liuxiaoshuang4@huawei.com>
…les transition package. Upgrade the react and lowlight modules.

Signed-off-by: liuxsh9 <liuxiaoshuang4@huawei.com>
@@ -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)}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<Box className={className} sx={Object.assign({}, styles.root, sx)}>
<Box className={className} sx={[styles.root, sx]}>

Please use array syntax instead

Copy link
Contributor Author

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());
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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)}
Copy link
Contributor

Choose a reason for hiding this comment

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

please use array syntax

Copy link
Contributor Author

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)}
Copy link
Contributor

Choose a reason for hiding this comment

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

array syntax

Copy link
Contributor Author

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 <liuxiaoshuang4@huawei.com>
Signed-off-by: liuxsh9 <liuxiaoshuang4@huawei.com>
@liuxsh9
Copy link
Contributor Author

liuxsh9 commented Jun 26, 2024

Thanks for the suggestions! We've completed the corresponding modifications. How does the new version look? @alanwguo

Copy link
Contributor

@alanwguo alanwguo left a 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),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
marginRight: theme.spacing(1),
marginRight: 1,

nit: sx automatically uses theme spacing values when passing in numbers for margins, padding, border, etc

Copy link
Contributor Author

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.

Comment on lines -76 to -93
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,
},
}),
);

Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed this component has some missing styles after your PR:

Screenshot 2024-06-26 at 1 50 59 PM

You can repro this by going to the jobs page -> job detail -> runtime environment (view) button

Copy link
Contributor Author

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 <liuxiaoshuang4@huawei.com>
Copy link
Contributor

@alanwguo alanwguo left a 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);
Copy link
Contributor

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?

Copy link
Contributor Author

@liuxsh9 liuxsh9 Jun 29, 2024

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),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
margin: (theme) => theme.spacing(2, 1),
marginX: 1,
marginY: 2,

Copy link
Contributor Author

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.

@alanwguo alanwguo added the go add ONLY when ready to merge, run all tests label Jun 28, 2024
Signed-off-by: liuxsh9 <liuxiaoshuang4@huawei.com>
Signed-off-by: liuxsh9 <liuxiaoshuang4@huawei.com>
@@ -53,6 +48,11 @@
"resolutions": {
"@types/react": "16.9.26"
},
"jest": {
"transformIgnorePatterns": [
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 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:

We are currently adding configuration here, is it suitable?

Copy link
Contributor

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?

Copy link
Contributor Author

@liuxsh9 liuxsh9 Jul 2, 2024

Choose a reason for hiding this comment

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

CI will fail, the error message:

image

… in the object.

Signed-off-by: liuxsh9 <liuxiaoshuang4@huawei.com>
Copy link
Contributor

@alanwguo alanwguo left a 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!!

@rkooo567 rkooo567 merged commit cab9059 into ray-project:master Jul 2, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants