[PageSpeed]: Merged loading states, used theme spacing, moved Skeleton layout outside of main component render

This commit is contained in:
Jesulayomy committed 2025-07-11 11:40:28 -04:00
1 parent 2d587a7d1b
commit f04fd8bea2
1 file changed
+13 -19
+13 -19
View File
@@ -181,16 +181,18 @@ const PageSpeedSetup = () => {
await deleteMonitor({ monitor, redirect: "/pagespeed" }); await deleteMonitor({ monitor, redirect: "/pagespeed" });
}; };
const isBusy = isLoading || isCreating || isDeleting || isUpdating || isPausing;
if (Object.keys(monitor).length === 0) {
return <SkeletonLayout />;
}
return ( return (
<Box <Box
sx={{ sx={{
"& h1": { color: theme.palette.primary.contrastText }, "& h1": { color: theme.palette.primary.contrastText },
}} }}
> >
{Object.keys(monitor).length === 0 ? (
<SkeletonLayout />
) : (
<>
<Breadcrumbs list={CRUMBS} /> <Breadcrumbs list={CRUMBS} />
<Stack <Stack
component="form" component="form"
@@ -271,12 +273,12 @@ const PageSpeedSetup = () => {
"&:before": { "&:before": {
position: "absolute", position: "absolute",
content: `""`, content: `""`,
width: 4, width: theme.spacing(2),
height: 4, height: theme.spacing(2),
borderRadius: "50%", borderRadius: "50%",
backgroundColor: theme.palette.primary.contrastTextTertiary, backgroundColor: theme.palette.primary.contrastTextTertiary,
opacity: 0.8, opacity: 0.8,
left: -10, left: theme.spacing(-5),
top: "50%", top: "50%",
transform: "translateY(-50%)", transform: "translateY(-50%)",
}, },
@@ -294,9 +296,7 @@ const PageSpeedSetup = () => {
> >
<Button <Button
onClick={handlePause} onClick={handlePause}
loading={ loading={isBusy}
isLoading || isCreating || isDeleting || isUpdating || isPausing
}
variant="contained" variant="contained"
color="secondary" color="secondary"
sx={{ sx={{
@@ -324,9 +324,7 @@ const PageSpeedSetup = () => {
)} )}
</Button> </Button>
<Button <Button
loading={ loading={isBusy}
isLoading || isCreating || isDeleting || isUpdating || isPausing
}
variant="contained" variant="contained"
color="error" color="error"
onClick={() => setIsOpen(true)} onClick={() => setIsOpen(true)}
@@ -448,9 +446,7 @@ const PageSpeedSetup = () => {
> >
{t("notificationConfig.title")} {t("notificationConfig.title")}
</Typography> </Typography>
<Typography component="p"> <Typography component="p">{t("notificationConfig.description")}</Typography>
{t("notificationConfig.description")}
</Typography>
</Box> </Box>
<NotificationsConfig <NotificationsConfig
notifications={notifications} notifications={notifications}
@@ -487,7 +483,7 @@ const PageSpeedSetup = () => {
type="submit" type="submit"
variant="contained" variant="contained"
color="accent" color="accent"
loading={isLoading || isCreating || isDeleting || isUpdating || isPausing} loading={isBusy}
disabled={!Object.values(errors).every((value) => value === undefined)} disabled={!Object.values(errors).every((value) => value === undefined)}
sx={isCreate ? undefined : { px: theme.spacing(12) }} sx={isCreate ? undefined : { px: theme.spacing(12) }}
> >
@@ -495,8 +491,6 @@ const PageSpeedSetup = () => {
</Button> </Button>
</Stack> </Stack>
</Stack> </Stack>
</>
)}
{!isCreate && ( {!isCreate && (
<Dialog <Dialog
open={isOpen} open={isOpen}