-
Notifications
You must be signed in to change notification settings - Fork 234
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
Fix: No Incidents Message #1763
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,82 @@ | ||||||||||||||||||||||||||||||||
// Components | ||||||||||||||||||||||||||||||||
import { Typography, Stack } from "@mui/material"; | ||||||||||||||||||||||||||||||||
import PropTypes from "prop-types"; | ||||||||||||||||||||||||||||||||
import { useTheme } from "@emotion/react"; | ||||||||||||||||||||||||||||||||
import IconBox from "../../IconBox"; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
const EmptyView = ({ | ||||||||||||||||||||||||||||||||
icon, | ||||||||||||||||||||||||||||||||
header, | ||||||||||||||||||||||||||||||||
message = "No Data", | ||||||||||||||||||||||||||||||||
size = "h2", | ||||||||||||||||||||||||||||||||
borderRadiusRight = 4, | ||||||||||||||||||||||||||||||||
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. Do we need border radius as a prop? This seems excessive for configuration |
||||||||||||||||||||||||||||||||
justifyContent = "flex-start", | ||||||||||||||||||||||||||||||||
height = "300px" | ||||||||||||||||||||||||||||||||
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. No hardcoded values please, especially non relative dimensions |
||||||||||||||||||||||||||||||||
}) => { | ||||||||||||||||||||||||||||||||
const theme = useTheme(); | ||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||
<Stack | ||||||||||||||||||||||||||||||||
flex={1} | ||||||||||||||||||||||||||||||||
direction="row" | ||||||||||||||||||||||||||||||||
sx={{ | ||||||||||||||||||||||||||||||||
backgroundColor: theme.palette.primary.main, | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
border: 1, | ||||||||||||||||||||||||||||||||
borderStyle: "solid", | ||||||||||||||||||||||||||||||||
borderColor: theme.palette.primary.lowContrast, | ||||||||||||||||||||||||||||||||
borderRadius: 2, | ||||||||||||||||||||||||||||||||
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. Most borders in the application are radius of 4, any reason for 2 here? 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. I was following the styling defined in chartbox low level component. 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. |
||||||||||||||||||||||||||||||||
borderTopRightRadius: borderRadiusRight, | ||||||||||||||||||||||||||||||||
borderBottomRightRadius: borderRadiusRight, | ||||||||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||
<Stack | ||||||||||||||||||||||||||||||||
flex={1} | ||||||||||||||||||||||||||||||||
alignItems="center" | ||||||||||||||||||||||||||||||||
sx={{ | ||||||||||||||||||||||||||||||||
padding: theme.spacing(8), | ||||||||||||||||||||||||||||||||
justifyContent, | ||||||||||||||||||||||||||||||||
gap: theme.spacing(8), | ||||||||||||||||||||||||||||||||
height, | ||||||||||||||||||||||||||||||||
minWidth: 250, | ||||||||||||||||||||||||||||||||
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. Hardcoded value |
||||||||||||||||||||||||||||||||
"& h2": { | ||||||||||||||||||||||||||||||||
color: theme.palette.primary.contrastTextSecondary, | ||||||||||||||||||||||||||||||||
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. Please don't override heading text colors 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. |
||||||||||||||||||||||||||||||||
fontSize: 15, | ||||||||||||||||||||||||||||||||
fontWeight: 500, | ||||||||||||||||||||||||||||||||
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. Please do not override heading font sizes or weights |
||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
"& tspan, & text": { | ||||||||||||||||||||||||||||||||
fill: theme.palette.primary.contrastTextTertiary, | ||||||||||||||||||||||||||||||||
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. The theme styles fonts and they should not be overridden unless there is a very good reason |
||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||
<Stack | ||||||||||||||||||||||||||||||||
alignSelf="flex-start" | ||||||||||||||||||||||||||||||||
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. Is there a reason for alignSelf in a child of a flex box component? You should be able to align this component using the parent flex component. 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. in this specific case, using alignSelf: "flex-start" is intentional and necessary to achieve the desired layout similar to how it was implement in chartbox component. |
||||||||||||||||||||||||||||||||
direction="row" | ||||||||||||||||||||||||||||||||
alignItems="center" | ||||||||||||||||||||||||||||||||
gap={theme.spacing(6)} | ||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||
{icon && <IconBox>{icon}</IconBox>} | ||||||||||||||||||||||||||||||||
{header && <Typography component="h2">{header}</Typography>} | ||||||||||||||||||||||||||||||||
</Stack> | ||||||||||||||||||||||||||||||||
<Stack | ||||||||||||||||||||||||||||||||
flex={1} | ||||||||||||||||||||||||||||||||
justifyContent="center" | ||||||||||||||||||||||||||||||||
alignItems="center" | ||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||
<Typography component={size}> | ||||||||||||||||||||||||||||||||
{message} | ||||||||||||||||||||||||||||||||
</Typography> | ||||||||||||||||||||||||||||||||
</Stack> | ||||||||||||||||||||||||||||||||
</Stack> | ||||||||||||||||||||||||||||||||
</Stack> | ||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
EmptyView.propTypes = { | ||||||||||||||||||||||||||||||||
message: PropTypes.string, | ||||||||||||||||||||||||||||||||
icon: PropTypes.node, | ||||||||||||||||||||||||||||||||
header: PropTypes.string, | ||||||||||||||||||||||||||||||||
size: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'body1', 'body2']) | ||||||||||||||||||||||||||||||||
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. I don't believe we provide styling for anything beyond h3, please remove anything beyond h3 |
||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
Comment on lines
+75
to
+80
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. Mom's spaghetti time! Let's fix those PropTypes! 🍝 Static analysis caught some missing PropTypes. Let's add them to keep our code robust! EmptyView.propTypes = {
message: PropTypes.string,
icon: PropTypes.node,
header: PropTypes.string,
- size: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'body1', 'body2'])
+ size: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'body1', 'body2']),
+ borderRadiusRight: PropTypes.number,
+ justifyContent: PropTypes.string,
+ height: PropTypes.string
}; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export default EmptyView; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ const ChartBoxes = ({ | |
<ChartBox | ||
icon={<UptimeIcon />} | ||
header="Uptime" | ||
isEmpty={monitor?.uptimePercentage === 0 && !monitor?.upChecks?.length} | ||
> | ||
<Stack | ||
width={"100%"} | ||
|
@@ -95,6 +96,8 @@ const ChartBoxes = ({ | |
<ChartBox | ||
icon={<IncidentsIcon />} | ||
header="Incidents" | ||
noDataMessage="Great. No Incidents, yet!" | ||
isEmpty={!monitor?.groupedDownChecks?.length} | ||
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. Please avoid truthy falsey comparisons, use strict evaluations so it's clear what you are trying to do |
||
> | ||
<Stack width={"100%"}> | ||
<Box position="relative"> | ||
|
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.
h2 is not a size, this prop is misleading.
h2 is a heading level