hide unused features
This commit is contained in:
1 parent
4c284493ba
commit
e3921beac4
3 files changed
+35
-47
No files matched your search
@@ -251,7 +251,6 @@ const CreateStatusPage = () => {
|
|||||||
onChange={(_, newValue) => {
|
onChange={(_, newValue) => {
|
||||||
field.onChange(newValue.map((m: Monitor) => m.id));
|
field.onChange(newValue.map((m: Monitor) => m.id));
|
||||||
}}
|
}}
|
||||||
renderTags={() => null}
|
|
||||||
fieldLabel={t(
|
fieldLabel={t(
|
||||||
"pages.statusPages.form.monitors.option.monitors.label"
|
"pages.statusPages.form.monitors.option.monitors.label"
|
||||||
)}
|
)}
|
||||||
@@ -424,7 +423,7 @@ const CreateStatusPage = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Controller
|
{/* <Controller
|
||||||
name="showUptimePercentage"
|
name="showUptimePercentage"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
@@ -457,7 +456,7 @@ const CreateStatusPage = () => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/> */}
|
||||||
</Stack>
|
</Stack>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -3,52 +3,26 @@ import Stack from "@mui/material/Stack";
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { Table, type Header, ValueLabel } from "@/Components/v2/design-elements";
|
import { Table, type Header, ValueLabel } from "@/Components/v2/design-elements";
|
||||||
import { ActionsMenu, type ActionMenuItem } from "@/Components/v2/actions-menu";
|
import { ActionsMenu, type ActionMenuItem } from "@/Components/v2/actions-menu";
|
||||||
import { Dialog } from "@/Components/v2/inputs";
|
|
||||||
import { ExternalLink } from "lucide-react";
|
import { ExternalLink } from "lucide-react";
|
||||||
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useDelete } from "@/Hooks/UseApi";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { createToast } from "@/Utils/toastUtils";
|
|
||||||
|
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
import type { StatusPage } from "@/Types/StatusPage";
|
||||||
|
|
||||||
interface StatusPagesTableProps {
|
interface StatusPagesTableProps {
|
||||||
data: StatusPage[];
|
data: StatusPage[];
|
||||||
refetch: () => void;
|
setSelectedStatusPage: (statusPage: StatusPage | null) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const StatusPagesTable = ({ data, refetch }: StatusPagesTableProps) => {
|
export const StatusPagesTable = ({
|
||||||
|
data,
|
||||||
|
setSelectedStatusPage,
|
||||||
|
}: StatusPagesTableProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { deleteFn, loading: isDeleting } = useDelete();
|
|
||||||
|
|
||||||
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
|
|
||||||
const [selectedStatusPage, setSelectedStatusPage] = useState<StatusPage | null>(null);
|
|
||||||
|
|
||||||
const handleDeleteClick = (statusPage: StatusPage) => {
|
|
||||||
setSelectedStatusPage(statusPage);
|
|
||||||
setIsDeleteDialogOpen(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDeleteConfirm = async () => {
|
|
||||||
if (!selectedStatusPage) return;
|
|
||||||
const result = await deleteFn(`/status-page/${selectedStatusPage.id}`);
|
|
||||||
if (result) {
|
|
||||||
createToast({ body: t("pages.statusPages.deleteSuccess") });
|
|
||||||
refetch();
|
|
||||||
}
|
|
||||||
setIsDeleteDialogOpen(false);
|
|
||||||
setSelectedStatusPage(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDeleteCancel = () => {
|
|
||||||
setIsDeleteDialogOpen(false);
|
|
||||||
setSelectedStatusPage(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
const getActions = (row: StatusPage): ActionMenuItem[] => {
|
const getActions = (row: StatusPage): ActionMenuItem[] => {
|
||||||
return [
|
return [
|
||||||
@@ -67,9 +41,7 @@ export const StatusPagesTable = ({ data, refetch }: StatusPagesTableProps) => {
|
|||||||
{t("common.buttons.delete")}
|
{t("common.buttons.delete")}
|
||||||
</Typography>
|
</Typography>
|
||||||
),
|
),
|
||||||
action: () => {
|
action: () => setSelectedStatusPage(row),
|
||||||
handleDeleteClick(row);
|
|
||||||
},
|
|
||||||
closeMenu: true,
|
closeMenu: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -165,14 +137,6 @@ export const StatusPagesTable = ({ data, refetch }: StatusPagesTableProps) => {
|
|||||||
onRowClick={handleRowClick}
|
onRowClick={handleRowClick}
|
||||||
emptyViewText={t("common.table.empty")}
|
emptyViewText={t("common.table.empty")}
|
||||||
/>
|
/>
|
||||||
<Dialog
|
|
||||||
open={isDeleteDialogOpen}
|
|
||||||
title={t("common.dialogs.delete.title")}
|
|
||||||
content={t("common.dialogs.delete.description")}
|
|
||||||
onConfirm={handleDeleteConfirm}
|
|
||||||
onCancel={handleDeleteCancel}
|
|
||||||
loading={isDeleting}
|
|
||||||
/>
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import { useState } from "react";
|
||||||
import { BasePageWithStates } from "@/Components/v2/design-elements";
|
import { BasePageWithStates } from "@/Components/v2/design-elements";
|
||||||
|
import { Dialog } from "@/Components/v2/inputs";
|
||||||
import { StatusPagesTable } from "./Components/StatusPagesTable";
|
import { StatusPagesTable } from "./Components/StatusPagesTable";
|
||||||
import { useGet } from "@/Hooks/UseApi";
|
import { useGet, useDelete } from "@/Hooks/UseApi";
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
import type { StatusPage } from "@/Types/StatusPage";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { HeaderCreate } from "@/Components/v2/common";
|
import { HeaderCreate } from "@/Components/v2/common";
|
||||||
@@ -16,8 +18,23 @@ const StatusPages = () => {
|
|||||||
refetch,
|
refetch,
|
||||||
} = useGet<StatusPage[]>("/status-page/team");
|
} = useGet<StatusPage[]>("/status-page/team");
|
||||||
|
|
||||||
|
const { deleteFn, loading: isDeleting } = useDelete();
|
||||||
|
const [selectedStatusPage, setSelectedStatusPage] = useState<StatusPage | null>(null);
|
||||||
|
const isDialogOpen = Boolean(selectedStatusPage);
|
||||||
|
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
|
|
||||||
|
const handleConfirm = async () => {
|
||||||
|
if (!selectedStatusPage) return;
|
||||||
|
await deleteFn(`/status-page/${selectedStatusPage.id}`);
|
||||||
|
setSelectedStatusPage(null);
|
||||||
|
refetch();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
setSelectedStatusPage(null);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePageWithStates
|
<BasePageWithStates
|
||||||
page={t("pages.statusPages.title")}
|
page={t("pages.statusPages.title")}
|
||||||
@@ -36,7 +53,15 @@ const StatusPages = () => {
|
|||||||
/>
|
/>
|
||||||
<StatusPagesTable
|
<StatusPagesTable
|
||||||
data={statusPages ?? []}
|
data={statusPages ?? []}
|
||||||
refetch={refetch}
|
setSelectedStatusPage={setSelectedStatusPage}
|
||||||
|
/>
|
||||||
|
<Dialog
|
||||||
|
open={isDialogOpen}
|
||||||
|
title={t("common.dialogs.delete.title")}
|
||||||
|
content={t("common.dialogs.delete.description")}
|
||||||
|
onConfirm={handleConfirm}
|
||||||
|
onCancel={handleCancel}
|
||||||
|
loading={isDeleting}
|
||||||
/>
|
/>
|
||||||
</BasePageWithStates>
|
</BasePageWithStates>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user