fix: address review feedback

- Replace hardcoded button text with translation
- Fix status box translation to avoid showing removed title
- Add conditional rendering for optional gauge metrics
This commit is contained in:
vineet-channe committed 2025-08-05 17:35:40 +05:30
1 parent 86a0b0b60c
commit de34710c90
2 files changed
+80 -70

No files matched your search

@@ -14,10 +14,9 @@ const BaseContainer = ({children}) => {
return( return(
<Box <Box
sx={{ sx={{
backgroundColor: theme.palette.background.paper,
padding: theme.spacing(3), padding: theme.spacing(3),
borderRadius: theme.spacing(2), borderRadius: theme.spacing(2),
border: `1px solid ${theme.palette.primary.lowContrast}`, border: `1px solid ${theme.palette.divider}`,
minWidth: 250, minWidth: 250,
width: "fit-content", width: "fit-content",
}}> }}>
@@ -28,15 +27,28 @@ const BaseContainer = ({children}) => {
const InfrastructureStyleGauge = ({ value, heading, metricOne, valueOne, metricTwo, valueTwo }) => { const InfrastructureStyleGauge = ({ value, heading, metricOne, valueOne, metricTwo, valueTwo }) => {
const theme = useTheme(); const theme = useTheme();
const valueStyle = {
borderRadius: theme.spacing(2), const MetricRow = ({ label, value }) => (
backgroundColor: theme.palette.tertiary.main, <Stack
width: "40%", justifyContent="space-between"
mb: theme.spacing(2), direction="row"
mt: theme.spacing(2), alignItems="center"
pr: theme.spacing(2), gap={theme.spacing(2)}
textAlign: "right", >
}; <Typography>{label}</Typography>
<Typography sx={{
borderRadius: theme.spacing(2),
backgroundColor: theme.palette.tertiary.main,
width: "40%",
mb: theme.spacing(2),
mt: theme.spacing(2),
pr: theme.spacing(2),
textAlign: "right",
}}>
{value}
</Typography>
</Stack>
);
return( return(
<BaseContainer> <BaseContainer>
@@ -47,7 +59,6 @@ const InfrastructureStyleGauge = ({ value, heading, metricOne, valueOne, metricT
flexDirection: "column", flexDirection: "column",
alignItems: "center", alignItems: "center",
width: "100%", width: "100%",
backgroundColor: theme.palette.gradient?.color1 || "transparent"
}} }}
> >
<CustomGauge progress={value} radius={100}/> <CustomGauge progress={value} radius={100}/>
@@ -55,25 +66,11 @@ const InfrastructureStyleGauge = ({ value, heading, metricOne, valueOne, metricT
{heading} {heading}
</Typography> </Typography>
</Box> </Box>
<Box sx={{ width:"100%", borderTop:`1px solid ${theme.palette.primary.lowContrast}`}}> <Box sx={{ width:"100%", borderTop:`1px solid ${theme.palette.divider}`}}>
<Stack <MetricRow label={metricOne} value={valueOne} />
justifyContent={"space-between"} {metricTwo && valueTwo && (
direction="row" <MetricRow label={metricTwo} value={valueTwo} />
alignItems="center" )}
gap={theme.spacing(2)}
>
<Typography>{metricOne}</Typography>
<Typography sx={valueStyle}>{valueOne}</Typography>
</Stack>
<Stack
justifyContent={"space-between"}
direction="row"
alignItems="center"
gap={theme.spacing(2)}
>
<Typography>{metricTwo}</Typography>
<Typography sx={valueStyle}>{valueTwo}</Typography>
</Stack>
</Box> </Box>
</Stack> </Stack>
</BaseContainer> </BaseContainer>
@@ -106,37 +103,37 @@ const Gauges = ({ diagnostics, isLoading }) => {
flexWrap="wrap" flexWrap="wrap"
> >
<InfrastructureStyleGauge <InfrastructureStyleGauge
value={heapTotalSize} value={heapTotalSize}
heading={t("diagnosticsPage.gauges.heapAllocationTitle")} heading={t("diagnosticsPage.gauges.heapAllocationTitle")}
metricOne="% of available memory" metricOne={t("diagnosticsPage.gauges.heapAllocationSubtitle")}
valueOne={`${heapTotalSize?.toFixed(1)}%`} valueOne={`${heapTotalSize?.toFixed(1) || 0}%`}
metricTwo="Total Heap Limit" metricTwo={t("total")}
valueTwo={formatBytes(diagnostics?.v8HeapStats?.heapSizeLimitBytes)} valueTwo={formatBytes(diagnostics?.v8HeapStats?.heapSizeLimitBytes)}
/> />
<InfrastructureStyleGauge <InfrastructureStyleGauge
value={heapUsedSize} value={heapUsedSize}
heading={t("diagnosticsPage.gauges.heapUsageTitle")} heading={t("diagnosticsPage.gauges.heapUsageTitle")}
metricOne="% of available memory" metricOne={t("diagnosticsPage.gauges.heapUsageSubtitle")}
valueOne={`${heapTotalSize?.toFixed(1)}%`} valueOne={`${heapUsedSize?.toFixed(1) || 0}%`}
metricTwo="Used Heap Size" metricTwo={t("used")}
valueTwo={formatBytes(diagnostics?.v8HeapStats?.usedHeapSizeBytes)} valueTwo={formatBytes(diagnostics?.v8HeapStats?.usedHeapSizeBytes)}
/> />
<InfrastructureStyleGauge <InfrastructureStyleGauge
value={actualHeapUsed} value={actualHeapUsed}
heading={t("diagnosticsPage.gauges.heapUtilizationTitle")} heading={t("diagnosticsPage.gauges.heapUtilizationTitle")}
metricOne="% of available memory" metricOne={t("diagnosticsPage.gauges.heapUtilizationSubtitle")}
valueOne={`${heapTotalSize?.toFixed(1)}%`} valueOne={`${actualHeapUsed?.toFixed(1) || 0}%`}
metricTwo="Total Heap Limit" metricTwo={t("total")}
valueTwo={formatBytes(diagnostics?.v8HeapStats?.totalHeapSizeBytes)} valueTwo={formatBytes(diagnostics?.v8HeapStats?.totalHeapSizeBytes)}
/> />
<InfrastructureStyleGauge <InfrastructureStyleGauge
value={diagnostics?.cpuUsage?.usagePercentage} value={diagnostics?.cpuUsage?.usagePercentage}
heading={t("diagnosticsPage.gauges.instantCpuUsageTitle")} heading={t("diagnosticsPage.gauges.instantCpuUsageTitle")}
metricOne="% of CPU used" metricOne={t("diagnosticsPage.gauges.instantCpuUsageSubtitle")}
valueOne={`${diagnostics?.cpuUsage?.usagePercentage?.toFixed(2)}%`} valueOne={`${diagnostics?.cpuUsage?.usagePercentage?.toFixed(1) || 0}%`}
metricTwo="Usage level" metricTwo=""
valueTwo={diagnostics?.cpuUsage?.usagePercentage > 80 ? "High" : diagnostics?.cpuUsage?.usagePercentage > 50 ? "Medium" : "Low"} valueTwo=""
/> />
</Stack> </Stack>
); );
}; };
@@ -146,4 +143,17 @@ Gauges.propTypes = {
isLoading: PropTypes.bool, isLoading: PropTypes.bool,
}; };
InfrastructureStyleGauge.propTypes = {
value: PropTypes.number,
heading: PropTypes.string,
metricOne: PropTypes.string,
valueOne: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
metricTwo: PropTypes.string,
valueTwo: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
};
BaseContainer.propTypes = {
children: PropTypes.node.isRequired,
};
export default Gauges; export default Gauges;
+11 -11
View File
@@ -20,39 +20,39 @@ const Diagnostics = () => {
// Setup // Setup
return ( return (
<Stack gap={theme.spacing(10)}> <Stack gap={theme.spacing(10)}>
<StatusBoxes shouldRender={!isLoading} flexWrap="wrap"> <StatusBoxes flexWrap="wrap">
<StatBox <StatBox
gradient={true} gradient={true}
status="up" status="up"
heading={t("status")} heading={t("status")}
subHeading={ subHeading={
error error
? "Error" ? t("logsPage.logLevelSelect.values.error")
: isLoading : isLoading
? "Loading..." ? t("commonSaving")
: diagnostics : diagnostics
? "Diagnostics Available" ? t("diagnosticsPage.diagnosticDescription")
: "No Data" : t("general.noOptionsFound", { unit: "data" })
} }
/> />
<StatBox <StatBox
heading="Event loop delay" heading={t("diagnosticsPage.stats.eventLoopDelayTitle")}
subHeading={getHumanReadableDuration(diagnostics?.eventLoopDelayMs)} subHeading={getHumanReadableDuration(diagnostics?.eventLoopDelayMs)}
/> />
<StatBox <StatBox
heading="Uptime" heading={t("diagnosticsPage.stats.uptimeTitle")}
subHeading={getHumanReadableDuration(diagnostics?.uptimeMs)} subHeading={getHumanReadableDuration(diagnostics?.uptimeMs)}
/> />
<StatBox <StatBox
heading="Used Heap Size" heading={t("diagnosticsPage.stats.usedHeapSizeTitle")}
subHeading={formatBytes(diagnostics?.v8HeapStats?.usedHeapSizeBytes)} subHeading={formatBytes(diagnostics?.v8HeapStats?.usedHeapSizeBytes)}
/> />
<StatBox <StatBox
heading="Total Heap Size" heading={t("diagnosticsPage.stats.totalHeapSizeTitle")}
subHeading={formatBytes(diagnostics?.v8HeapStats?.totalHeapSizeBytes)} subHeading={formatBytes(diagnostics?.v8HeapStats?.totalHeapSizeBytes)}
/> />
<StatBox <StatBox
heading="OS Memory Limit" heading={t("diagnosticsPage.stats.osMemoryLimitTitle")}
subHeading={formatBytes(diagnostics?.osStats?.totalMemoryBytes)} subHeading={formatBytes(diagnostics?.osStats?.totalMemoryBytes)}
/> />
</StatusBoxes> </StatusBoxes>
@@ -67,7 +67,7 @@ const Diagnostics = () => {
onClick={fetchDiagnostics} onClick={fetchDiagnostics}
loading={isLoading} loading={isLoading}
> >
Fetch Diagnostics {t("queuePage.refreshButton")}
</Button> </Button>
</Box> </Box>
</Stack> </Stack>