Modify
This commit is contained in:
1 parent
2b017490a3
commit
fc1f4fc142
2 files changed
+2
-50
No files matched your search
@@ -11,7 +11,7 @@ import { useLocation } from "react-router-dom";
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const Controls = ({ isDeleteOpen, setIsDeleteOpen, isDeleting, url, type }) => {
|
const Controls = ({ url, type }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -27,16 +27,6 @@ const Controls = ({ isDeleteOpen, setIsDeleteOpen, isDeleting, url, type }) => {
|
|||||||
direction="row"
|
direction="row"
|
||||||
gap={theme.spacing(2)}
|
gap={theme.spacing(2)}
|
||||||
>
|
>
|
||||||
<Box>
|
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
color="error"
|
|
||||||
onClick={() => setIsDeleteOpen(!isDeleteOpen)}
|
|
||||||
loading={isDeleting}
|
|
||||||
>
|
|
||||||
{t("delete")}
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
@@ -65,18 +55,12 @@ const Controls = ({ isDeleteOpen, setIsDeleteOpen, isDeleting, url, type }) => {
|
|||||||
|
|
||||||
Controls.propTypes = {
|
Controls.propTypes = {
|
||||||
type: PropTypes.string,
|
type: PropTypes.string,
|
||||||
isDeleting: PropTypes.bool,
|
|
||||||
url: PropTypes.string,
|
url: PropTypes.string,
|
||||||
isDeleteOpen: PropTypes.bool.isRequired,
|
|
||||||
setIsDeleteOpen: PropTypes.func.isRequired,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const ControlsHeader = ({
|
const ControlsHeader = ({
|
||||||
statusPage,
|
statusPage,
|
||||||
isPublic,
|
isPublic,
|
||||||
isDeleting,
|
|
||||||
isDeleteOpen,
|
|
||||||
setIsDeleteOpen,
|
|
||||||
url,
|
url,
|
||||||
type = "uptime",
|
type = "uptime",
|
||||||
}) => {
|
}) => {
|
||||||
@@ -137,9 +121,6 @@ const ControlsHeader = ({
|
|||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Controls
|
<Controls
|
||||||
isDeleting={isDeleting}
|
|
||||||
isDeleteOpen={isDeleteOpen}
|
|
||||||
setIsDeleteOpen={setIsDeleteOpen}
|
|
||||||
url={url}
|
url={url}
|
||||||
type={type}
|
type={type}
|
||||||
/>
|
/>
|
||||||
@@ -152,9 +133,6 @@ ControlsHeader.propTypes = {
|
|||||||
url: PropTypes.string,
|
url: PropTypes.string,
|
||||||
statusPage: PropTypes.object,
|
statusPage: PropTypes.object,
|
||||||
isPublic: PropTypes.bool,
|
isPublic: PropTypes.bool,
|
||||||
isDeleting: PropTypes.bool,
|
|
||||||
isDeleteOpen: PropTypes.bool.isRequired,
|
|
||||||
setIsDeleteOpen: PropTypes.func.isRequired,
|
|
||||||
type: PropTypes.string,
|
type: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ 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";
|
|
||||||
import Breadcrumbs from "../../../Components/Breadcrumbs/index.jsx";
|
import Breadcrumbs from "../../../Components/Breadcrumbs/index.jsx";
|
||||||
import TextLink from "../../../Components/TextLink";
|
import TextLink from "../../../Components/TextLink";
|
||||||
|
|
||||||
@@ -15,27 +14,20 @@ 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 { useState } from "react";
|
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const PublicStatus = () => {
|
const PublicStatus = () => {
|
||||||
const { url } = useParams();
|
const { url } = useParams();
|
||||||
|
|
||||||
// Local state
|
|
||||||
const [isDeleteOpen, setIsDeleteOpen] = useState(false);
|
|
||||||
// Utils
|
// Utils
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
|
|
||||||
const [statusPage, monitors, isLoading, networkError, fetchStatusPage] =
|
const [statusPage, monitors, isLoading, networkError] =
|
||||||
useStatusPageFetch(false, url);
|
useStatusPageFetch(false, url);
|
||||||
const [deleteStatusPage, isDeleting] = useStatusPageDelete(fetchStatusPage, url);
|
|
||||||
|
|
||||||
// Breadcrumbs
|
// Breadcrumbs
|
||||||
const crumbs = [
|
const crumbs = [
|
||||||
@@ -158,9 +150,6 @@ const PublicStatus = () => {
|
|||||||
{!isPublic && <Breadcrumbs list={crumbs} />}
|
{!isPublic && <Breadcrumbs list={crumbs} />}
|
||||||
<ControlsHeader
|
<ControlsHeader
|
||||||
statusPage={statusPage}
|
statusPage={statusPage}
|
||||||
isDeleting={isDeleting}
|
|
||||||
isDeleteOpen={isDeleteOpen}
|
|
||||||
setIsDeleteOpen={setIsDeleteOpen}
|
|
||||||
url={url}
|
url={url}
|
||||||
isPublic={isPublic}
|
isPublic={isPublic}
|
||||||
/>
|
/>
|
||||||
@@ -168,21 +157,6 @@ const PublicStatus = () => {
|
|||||||
<StatusBar monitors={monitors} />
|
<StatusBar monitors={monitors} />
|
||||||
<MonitorsList monitors={monitors} />
|
<MonitorsList monitors={monitors} />
|
||||||
{link}
|
{link}
|
||||||
<Dialog
|
|
||||||
title={t("deleteStatusPage")}
|
|
||||||
onConfirm={() => {
|
|
||||||
deleteStatusPage();
|
|
||||||
setIsDeleteOpen(false);
|
|
||||||
navigate("/status");
|
|
||||||
}}
|
|
||||||
onCancel={() => {
|
|
||||||
setIsDeleteOpen(false);
|
|
||||||
}}
|
|
||||||
open={isDeleteOpen}
|
|
||||||
confirmationButtonLabel={t("deleteStatusPageConfirm")}
|
|
||||||
description={t("deleteStatusPageDescription")}
|
|
||||||
isLoading={isDeleting || isLoading}
|
|
||||||
/>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user