redirect on delete
This commit is contained in:
1 parent
2087202eea
commit
532cbe222b
3 files changed
+12
-7
No files matched your search
@@ -2,11 +2,9 @@ import { useSelector } from "react-redux";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { networkService } from "../../../../main";
|
import { networkService } from "../../../../main";
|
||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
|
|
||||||
const useStatusPageDelete = (fetchStatusPage, url) => {
|
const useStatusPageDelete = (fetchStatusPage, url) => {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const navigate = useNavigate();
|
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const deleteStatusPage = async () => {
|
const deleteStatusPage = async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Components
|
// Components
|
||||||
import { Typography, Stack } from "@mui/material";
|
import { Typography, Stack } from "@mui/material";
|
||||||
import GenericFallback from "../../../Components/GenericFallback";
|
import GenericFallback from "../../../Components/GenericFallback";
|
||||||
import Fallback from "../../../Components/Fallback";
|
|
||||||
import AdminLink from "./Components/AdminLink";
|
import AdminLink from "./Components/AdminLink";
|
||||||
import ControlsHeader from "./Components/ControlsHeader";
|
import ControlsHeader from "./Components/ControlsHeader";
|
||||||
import SkeletonLayout from "./Components/Skeleton";
|
import SkeletonLayout from "./Components/Skeleton";
|
||||||
@@ -17,7 +16,7 @@ import { useLocation } from "react-router-dom";
|
|||||||
import { useStatusPageDelete } from "./Hooks/useStatusPageDelete";
|
import { useStatusPageDelete } from "./Hooks/useStatusPageDelete";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
const PublicStatus = () => {
|
const PublicStatus = () => {
|
||||||
const { url } = useParams();
|
const { url } = useParams();
|
||||||
|
|
||||||
@@ -26,17 +25,18 @@ const PublicStatus = () => {
|
|||||||
// Utils
|
// Utils
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
|
const location = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [statusPage, monitors, isLoading, networkError, fetchStatusPage] =
|
const [statusPage, monitors, isLoading, networkError, fetchStatusPage] =
|
||||||
useStatusPageFetch(false, url);
|
useStatusPageFetch(false, url);
|
||||||
const [deleteStatusPage, isDeleting] = useStatusPageDelete(fetchStatusPage, url);
|
const [deleteStatusPage, isDeleting] = useStatusPageDelete(fetchStatusPage, url);
|
||||||
const location = useLocation();
|
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
const currentPath = location.pathname;
|
const currentPath = location.pathname;
|
||||||
let sx = { paddingLeft: theme.spacing(20), paddingRight: theme.spacing(20) };
|
let sx = { paddingLeft: theme.spacing(20), paddingRight: theme.spacing(20) };
|
||||||
let link = undefined;
|
let link = undefined;
|
||||||
const isPublic = location.pathname.startsWith("/status/uptime/public");
|
const isPublic = location.pathname.startsWith("/status/uptime/public");
|
||||||
|
|
||||||
// Public status page
|
// Public status page
|
||||||
if (isPublic) {
|
if (isPublic) {
|
||||||
sx = {
|
sx = {
|
||||||
@@ -142,6 +142,7 @@ const PublicStatus = () => {
|
|||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
deleteStatusPage();
|
deleteStatusPage();
|
||||||
setIsDeleteOpen(false);
|
setIsDeleteOpen(false);
|
||||||
|
navigate("/status");
|
||||||
}}
|
}}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
setIsDeleteOpen(false);
|
setIsDeleteOpen(false);
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
import { Stack, Typography } from "@mui/material";
|
import { Stack, Typography } from "@mui/material";
|
||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
import Fallback from "../../../Components/Fallback";
|
import Fallback from "../../../Components/Fallback";
|
||||||
|
import MonitorCreateHeader from "../../../Components/MonitorCreateHeader";
|
||||||
import GenericFallback from "../../../Components/GenericFallback";
|
import GenericFallback from "../../../Components/GenericFallback";
|
||||||
// Utils
|
// Utils
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useStatusPagesFetch } from "./Hooks/useStatusPagesFetch";
|
import { useStatusPagesFetch } from "./Hooks/useStatusPagesFetch";
|
||||||
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
const BREADCRUMBS = [{ name: `Status Pages`, path: "/distributed-uptime/status-pages" }];
|
const BREADCRUMBS = [{ name: `Status Pages`, path: "" }];
|
||||||
|
|
||||||
const StatusPages = () => {
|
const StatusPages = () => {
|
||||||
// Utils
|
// Utils
|
||||||
@@ -57,6 +58,11 @@ const StatusPages = () => {
|
|||||||
return (
|
return (
|
||||||
<Stack gap={theme.spacing(10)}>
|
<Stack gap={theme.spacing(10)}>
|
||||||
<Breadcrumbs list={BREADCRUMBS} />
|
<Breadcrumbs list={BREADCRUMBS} />
|
||||||
|
<MonitorCreateHeader
|
||||||
|
label="Create status page"
|
||||||
|
isAdmin={isAdmin}
|
||||||
|
path="/status/uptime/create"
|
||||||
|
/>
|
||||||
{statusPages?.map((statusPage) => {
|
{statusPages?.map((statusPage) => {
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
|
|||||||
Reference in new issue
Block a user