-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1edf57c
Replace makeStyles with styled in MUIv5.
liuxsh9 7c809cb
Format Code
liuxsh9 1302e60
Replace makeStyles with styled in MUIv5.
liuxsh9 225af33
Format Code
liuxsh9 575f8cb
Fix some warnings
liuxsh9 28fbb63
Use the sx prop of MUI v5 to apply the styles and remove the @mui/sty…
liuxsh9 40e85c7
Replace the style combination method with array syntax to fix the error.
liuxsh9 bf5e4b1
Inline styles using sx props
liuxsh9 94a28b4
Fix errors and abbreviate styles such as padding
liuxsh9 ebb9248
abbreviate styles such as padding, margin and gap
liuxsh9 71cf33b
Fix errors that occurred during testing
liuxsh9 c878dcd
Remove style testing. When using sx prop, there is no style attribute…
liuxsh9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,9 @@ | ||
import { Card, Link, Typography } from "@mui/material"; | ||
import createStyles from "@mui/styles/createStyles"; | ||
import makeStyles from "@mui/styles/makeStyles"; | ||
import classNames from "classnames"; | ||
import { Box, Card, Link, SxProps, Theme, Typography } from "@mui/material"; | ||
import yaml from "js-yaml"; | ||
import React, { useState } from "react"; | ||
import DialogWithTitle from "../DialogWithTitle"; | ||
import { ClassNameProps } from "../props"; | ||
|
||
const useStyles = makeStyles((theme) => | ||
createStyles({ | ||
configText: { | ||
whiteSpace: "pre", | ||
fontFamily: "SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace", | ||
padding: theme.spacing(2), | ||
overflow: "scroll", | ||
maxHeight: 600, | ||
}, | ||
}), | ||
); | ||
|
||
export type CodeDialogButtonProps = { | ||
/** | ||
* Title of the dialog box | ||
|
@@ -32,6 +17,7 @@ export type CodeDialogButtonProps = { | |
* Code to show in the dialog. If an object is passed in, that object will be stringified to yaml. | ||
*/ | ||
code: string | object; | ||
sx?: SxProps<Theme>; | ||
}; | ||
|
||
/** | ||
|
@@ -42,8 +28,6 @@ export const CodeDialogButton = ({ | |
buttonText = "View", | ||
code, | ||
}: CodeDialogButtonProps) => { | ||
const classes = useStyles(); | ||
|
||
const [showConfigDialog, setShowConfigDialog] = useState(false); | ||
|
||
const handleConfigClick = () => { | ||
|
@@ -63,7 +47,16 @@ export const CodeDialogButton = ({ | |
}} | ||
> | ||
<Card variant="outlined"> | ||
<Typography className={classes.configText}> | ||
<Typography | ||
sx={{ | ||
whiteSpace: "pre", | ||
fontFamily: | ||
"SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace", | ||
padding: 2, | ||
overflow: "scroll", | ||
maxHeight: 600, | ||
}} | ||
> | ||
{typeof code === "string" ? code : yaml.dump(code, { indent: 2 })} | ||
</Typography> | ||
</Card> | ||
|
@@ -73,24 +66,6 @@ export const CodeDialogButton = ({ | |
); | ||
}; | ||
|
||
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, | ||
}, | ||
}), | ||
); | ||
|
||
type CodeDialogButtonWithPreviewProps = CodeDialogButtonProps & ClassNameProps; | ||
Comment on lines
-76
to
-93
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
/** | ||
* Similar to CodeDialogButton but also shows a snippet of the expanded text next to the button. | ||
|
@@ -99,10 +74,9 @@ export const CodeDialogButtonWithPreview = ({ | |
code, | ||
buttonText, | ||
className, | ||
sx, | ||
...props | ||
}: CodeDialogButtonWithPreviewProps) => { | ||
const classes = useCodeDialogButtonWithPreviewStyles(); | ||
|
||
const codeText = | ||
typeof code === "string" | ||
? code | ||
|
@@ -111,13 +85,35 @@ export const CodeDialogButtonWithPreview = ({ | |
const buttonTextToPass = buttonText ?? "Expand"; | ||
|
||
return ( | ||
<div className={classNames(classes.root, className)}> | ||
<span className={classes.previewText}>{codeText}</span> | ||
<Box | ||
className={className} | ||
sx={[ | ||
{ | ||
display: "flex", | ||
flexWrap: "nowrap", | ||
flexDirection: "row", | ||
gap: 1, | ||
}, | ||
...(Array.isArray(sx) ? sx : [sx]), | ||
]} | ||
> | ||
<Box | ||
component="span" | ||
sx={{ | ||
display: "block", | ||
whiteSpace: "nowrap", | ||
overflow: "hidden", | ||
textOverflow: "ellipsis", | ||
flex: 1, | ||
}} | ||
> | ||
{codeText} | ||
</Box> | ||
<CodeDialogButton | ||
code={codeText} | ||
buttonText={buttonTextToPass} | ||
{...props} | ||
/> | ||
</div> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.
CI will fail, the error message: