Merge pull request #1704 from bluewave-labs/fix/fe/status-page-delete-modal
fix: fe/status page delete modal
This commit is contained in:
3 files changed
+36
-15
No files matched your search
@@ -1,18 +1,19 @@
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
|
||||||
import { Button, Stack } from "@mui/material";
|
import { Button, Stack } from "@mui/material";
|
||||||
import { GenericDialog } from "./genericDialog";
|
import { GenericDialog } from "./genericDialog";
|
||||||
|
import { useTheme } from "@emotion/react";
|
||||||
|
|
||||||
const Dialog = ({
|
const Dialog = ({
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
open,
|
open,
|
||||||
theme,
|
|
||||||
onCancel,
|
onCancel,
|
||||||
confirmationButtonLabel,
|
confirmationButtonLabel,
|
||||||
onConfirm,
|
onConfirm,
|
||||||
isLoading,
|
isLoading,
|
||||||
}) => {
|
}) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GenericDialog
|
<GenericDialog
|
||||||
title={title}
|
title={title}
|
||||||
@@ -34,14 +35,14 @@ const Dialog = ({
|
|||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<LoadingButton
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="error"
|
color="error"
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
onClick={onConfirm}
|
onClick={onConfirm}
|
||||||
>
|
>
|
||||||
{confirmationButtonLabel}
|
{confirmationButtonLabel}
|
||||||
</LoadingButton>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</GenericDialog>
|
</GenericDialog>
|
||||||
);
|
);
|
||||||
@@ -51,7 +52,6 @@ Dialog.propTypes = {
|
|||||||
title: PropTypes.string.isRequired,
|
title: PropTypes.string.isRequired,
|
||||||
description: PropTypes.string,
|
description: PropTypes.string,
|
||||||
open: PropTypes.bool.isRequired,
|
open: PropTypes.bool.isRequired,
|
||||||
theme: PropTypes.object.isRequired,
|
|
||||||
onCancel: PropTypes.func.isRequired,
|
onCancel: PropTypes.func.isRequired,
|
||||||
confirmationButtonLabel: PropTypes.string.isRequired,
|
confirmationButtonLabel: PropTypes.string.isRequired,
|
||||||
onConfirm: PropTypes.func.isRequired,
|
onConfirm: PropTypes.func.isRequired,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { useNavigate } from "react-router-dom";
|
|||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
const Controls = ({ deleteStatusPage, isDeleting }) => {
|
const Controls = ({ isDeleteOpen, setIsDeleteOpen, isDeleting }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const currentPath = location.pathname;
|
const currentPath = location.pathname;
|
||||||
@@ -17,7 +17,6 @@ const Controls = ({ deleteStatusPage, isDeleting }) => {
|
|||||||
if (currentPath === "/status/public") {
|
if (currentPath === "/status/public") {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
@@ -27,7 +26,7 @@ const Controls = ({ deleteStatusPage, isDeleting }) => {
|
|||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="error"
|
color="error"
|
||||||
onClick={deleteStatusPage}
|
onClick={() => setIsDeleteOpen(!isDeleteOpen)}
|
||||||
loading={isDeleting}
|
loading={isDeleting}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
@@ -56,11 +55,12 @@ const Controls = ({ deleteStatusPage, isDeleting }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Controls.propTypes = {
|
Controls.propTypes = {
|
||||||
deleteStatusPage: PropTypes.func,
|
|
||||||
isDeleting: PropTypes.bool,
|
isDeleting: PropTypes.bool,
|
||||||
|
isDeleteOpen: PropTypes.bool.isRequired,
|
||||||
|
setIsDeleteOpen: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ControlsHeader = ({ statusPage, deleteStatusPage, isDeleting }) => {
|
const ControlsHeader = ({ statusPage, isDeleting, isDeleteOpen, setIsDeleteOpen }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -86,8 +86,9 @@ const ControlsHeader = ({ statusPage, deleteStatusPage, isDeleting }) => {
|
|||||||
<Typography variant="h2">{statusPage?.companyName}</Typography>
|
<Typography variant="h2">{statusPage?.companyName}</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Controls
|
<Controls
|
||||||
deleteStatusPage={deleteStatusPage}
|
|
||||||
isDeleting={isDeleting}
|
isDeleting={isDeleting}
|
||||||
|
isDeleteOpen={isDeleteOpen}
|
||||||
|
setIsDeleteOpen={setIsDeleteOpen}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
@@ -95,8 +96,9 @@ const ControlsHeader = ({ statusPage, deleteStatusPage, isDeleting }) => {
|
|||||||
|
|
||||||
ControlsHeader.propTypes = {
|
ControlsHeader.propTypes = {
|
||||||
statusPage: PropTypes.object,
|
statusPage: PropTypes.object,
|
||||||
deleteStatusPage: PropTypes.func,
|
|
||||||
isDeleting: PropTypes.bool,
|
isDeleting: PropTypes.bool,
|
||||||
|
isDeleteOpen: PropTypes.bool.isRequired,
|
||||||
|
setIsDeleteOpen: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ControlsHeader;
|
export default ControlsHeader;
|
||||||
@@ -7,16 +7,19 @@ import ControlsHeader from "./Components/ControlsHeader";
|
|||||||
import SkeletonLayout from "./Components/Skeleton";
|
import SkeletonLayout from "./Components/Skeleton";
|
||||||
import StatusBar from "./Components/StatusBar";
|
import StatusBar from "./Components/StatusBar";
|
||||||
import MonitorsList from "./Components/MonitorsList";
|
import MonitorsList from "./Components/MonitorsList";
|
||||||
|
import Dialog from "../../../Components/Dialog";
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { useStatusPageFetch } from "./Hooks/useStatusPageFetch";
|
import { useStatusPageFetch } from "./Hooks/useStatusPageFetch";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import { useStatusPageDelete } from "./Hooks/useStatusPageDelete";
|
import { useStatusPageDelete } from "./Hooks/useStatusPageDelete";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
const PublicStatus = () => {
|
const PublicStatus = () => {
|
||||||
// Local state
|
// Local state
|
||||||
|
const [isDeleteOpen, setIsDeleteOpen] = useState(false);
|
||||||
// Utils
|
// Utils
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
@@ -123,17 +126,33 @@ const PublicStatus = () => {
|
|||||||
<Stack
|
<Stack
|
||||||
gap={theme.spacing(10)}
|
gap={theme.spacing(10)}
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
sx={sx}
|
sx={{ ...sx, position: "relative" }}
|
||||||
>
|
>
|
||||||
<ControlsHeader
|
<ControlsHeader
|
||||||
statusPage={statusPage}
|
statusPage={statusPage}
|
||||||
deleteStatusPage={deleteStatusPage}
|
|
||||||
isDeleting={isDeleting}
|
isDeleting={isDeleting}
|
||||||
|
isDeleteOpen={isDeleteOpen}
|
||||||
|
setIsDeleteOpen={setIsDeleteOpen}
|
||||||
/>
|
/>
|
||||||
<Typography variant="h2">Service status</Typography>
|
<Typography variant="h2">Service status</Typography>
|
||||||
<StatusBar monitors={monitors} />
|
<StatusBar monitors={monitors} />
|
||||||
<MonitorsList monitors={monitors} />
|
<MonitorsList monitors={monitors} />
|
||||||
{link}
|
{link}
|
||||||
|
<Dialog
|
||||||
|
// open={isOpen.deleteStats}
|
||||||
|
title="Do you want to delete this status page?"
|
||||||
|
onConfirm={() => {
|
||||||
|
deleteStatusPage();
|
||||||
|
setIsDeleteOpen(false);
|
||||||
|
}}
|
||||||
|
onCancel={() => {
|
||||||
|
setIsDeleteOpen(false);
|
||||||
|
}}
|
||||||
|
open={isDeleteOpen}
|
||||||
|
confirmationButtonLabel="Yes, delete status page"
|
||||||
|
description="Once deleted, your status page cannot be retrieved."
|
||||||
|
isLoading={isDeleting || isLoading}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user