fix(monitors): PR feedback -layout rhythm, pagination memory leak, error alerts, and mobile cards
This commit is contained in:
1 parent
010ef9661f
commit
656c04d0e4
4 files changed
+28
-41
No files matched your search
@@ -7,6 +7,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Slide from "@mui/material/Slide";
|
import Slide from "@mui/material/Slide";
|
||||||
import { X } from "lucide-react";
|
import { X } from "lucide-react";
|
||||||
|
import { LAYOUT } from "@/Utils/Theme/constants";
|
||||||
|
|
||||||
interface FloatingActionBarProps {
|
interface FloatingActionBarProps {
|
||||||
selectedCount: number;
|
selectedCount: number;
|
||||||
@@ -34,31 +35,32 @@ export const FloatingActionBar: React.FC<FloatingActionBarProps> = ({
|
|||||||
elevation={6}
|
elevation={6}
|
||||||
sx={{
|
sx={{
|
||||||
position: "fixed",
|
position: "fixed",
|
||||||
bottom: theme.spacing(4),
|
bottom: theme.spacing(LAYOUT.XS),
|
||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translateX(-50%)",
|
transform: "translateX(-50%)",
|
||||||
zIndex: theme.zIndex.snackbar,
|
zIndex: theme.zIndex.snackbar,
|
||||||
padding: theme.spacing(1.5, 3),
|
px: LAYOUT.MD,
|
||||||
|
py: LAYOUT.XS,
|
||||||
borderRadius: theme.shape.borderRadius,
|
borderRadius: theme.shape.borderRadius,
|
||||||
backgroundColor: theme.palette.background.paper,
|
backgroundColor: theme.palette.background.paper,
|
||||||
border: `1px solid ${theme.palette.divider}`,
|
border: `1px solid ${theme.palette.divider}`,
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: theme.spacing(4),
|
gap: LAYOUT.XS,
|
||||||
boxShadow: theme.shadows[8],
|
boxShadow: theme.shadows[8],
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
gap={theme.spacing(1)}
|
gap={LAYOUT.XS}
|
||||||
>
|
>
|
||||||
<Typography
|
<Typography
|
||||||
variant="body1"
|
variant="body1"
|
||||||
fontWeight={600}
|
fontWeight={600}
|
||||||
color={theme.palette.text.primary}
|
color={theme.palette.text.primary}
|
||||||
>
|
>
|
||||||
{selectedCount} {t("common.selected", { defaultValue: "selected" })}
|
{selectedCount} {t("common.selected")}
|
||||||
</Typography>
|
</Typography>
|
||||||
<IconButton
|
<IconButton
|
||||||
size="small"
|
size="small"
|
||||||
@@ -73,7 +75,7 @@ export const FloatingActionBar: React.FC<FloatingActionBarProps> = ({
|
|||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
gap={theme.spacing(2)}
|
gap={LAYOUT.XS}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import Stack from "@mui/material/Stack";
|
|||||||
import RadioGroup from "@mui/material/RadioGroup";
|
import RadioGroup from "@mui/material/RadioGroup";
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
import Alert from "@mui/material/Alert";
|
||||||
import { useGet, usePatch } from "@/Hooks/UseApi";
|
import { useGet, usePatch } from "@/Hooks/UseApi";
|
||||||
import type { Notification } from "@/Types/Notification";
|
import type { Notification } from "@/Types/Notification";
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProp
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const { patch, loading: isPatching } = usePatch();
|
const { patch, loading: isPatching, error } = usePatch();
|
||||||
|
|
||||||
// Reset state when modal opens
|
// Reset state when modal opens
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -65,9 +66,7 @@ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProp
|
|||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
open={open}
|
open={open}
|
||||||
title={t("pages.common.monitors.bulkEdit.title", {
|
title={t("pages.common.monitors.bulkEdit.title")}
|
||||||
defaultValue: "Edit Notifications",
|
|
||||||
})}
|
|
||||||
onCancel={onClose}
|
onCancel={onClose}
|
||||||
onConfirm={isMissingSelection ? undefined : handleConfirm}
|
onConfirm={isMissingSelection ? undefined : handleConfirm}
|
||||||
loading={isPatching}
|
loading={isPatching}
|
||||||
@@ -78,10 +77,10 @@ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProp
|
|||||||
spacing={theme.spacing(4)}
|
spacing={theme.spacing(4)}
|
||||||
mt={theme.spacing(2)}
|
mt={theme.spacing(2)}
|
||||||
>
|
>
|
||||||
|
{error && <Alert severity="error">{error}</Alert>}
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{t("pages.common.monitors.bulkEdit.selectedText", {
|
{t("pages.common.monitors.bulkEdit.selectedText", {
|
||||||
count: selectedMonitors.length,
|
count: selectedMonitors.length,
|
||||||
defaultValue: `You are applying changes to {{count}} monitor(s).`,
|
|
||||||
})}
|
})}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
@@ -91,31 +90,18 @@ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProp
|
|||||||
>
|
>
|
||||||
<RadioWithDescription
|
<RadioWithDescription
|
||||||
value="add"
|
value="add"
|
||||||
label={t("pages.common.monitors.bulkEdit.actionAdd", { defaultValue: "Add" })}
|
label={t("pages.common.monitors.bulkEdit.actionAdd")}
|
||||||
description={t("pages.common.monitors.bulkEdit.actionAddDesc", {
|
description={t("pages.common.monitors.bulkEdit.actionAddDesc")}
|
||||||
defaultValue:
|
|
||||||
"Adds the selected notifications to these monitors without removing existing ones.",
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
<RadioWithDescription
|
<RadioWithDescription
|
||||||
value="remove"
|
value="remove"
|
||||||
label={t("pages.common.monitors.bulkEdit.actionRemove", {
|
label={t("pages.common.monitors.bulkEdit.actionRemove")}
|
||||||
defaultValue: "Remove",
|
description={t("pages.common.monitors.bulkEdit.actionRemoveDesc")}
|
||||||
})}
|
|
||||||
description={t("pages.common.monitors.bulkEdit.actionRemoveDesc", {
|
|
||||||
defaultValue:
|
|
||||||
"Removes exclusively the selected notifications from these monitors.",
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
<RadioWithDescription
|
<RadioWithDescription
|
||||||
value="set"
|
value="set"
|
||||||
label={t("pages.common.monitors.bulkEdit.actionSet", {
|
label={t("pages.common.monitors.bulkEdit.actionSet")}
|
||||||
defaultValue: "Replace all",
|
description={t("pages.common.monitors.bulkEdit.actionSetDesc")}
|
||||||
})}
|
|
||||||
description={t("pages.common.monitors.bulkEdit.actionSetDesc", {
|
|
||||||
defaultValue:
|
|
||||||
"Replaces all existing notifications. Leave empty to clear all notifications.",
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
@@ -123,12 +109,8 @@ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProp
|
|||||||
multiple
|
multiple
|
||||||
value={notificationIds}
|
value={notificationIds}
|
||||||
onChange={(e) => setNotificationIds(e.target.value as string[])}
|
onChange={(e) => setNotificationIds(e.target.value as string[])}
|
||||||
fieldLabel={t("pages.common.monitors.bulkEdit.selectLabel", {
|
fieldLabel={t("pages.common.monitors.bulkEdit.selectLabel")}
|
||||||
defaultValue: "Notification Channels",
|
placeholder={t("pages.common.monitors.bulkEdit.selectPlaceholder")}
|
||||||
})}
|
|
||||||
placeholder={t("pages.common.monitors.bulkEdit.selectPlaceholder", {
|
|
||||||
defaultValue: "Select channels...",
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
{notifications?.map((n) => (
|
{notifications?.map((n) => (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { ArrowDown, ArrowUp } 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 useMediaQuery from "@mui/material/useMediaQuery";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { usePost } from "@/Hooks/UseApi";
|
import { usePost } from "@/Hooks/UseApi";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
@@ -44,9 +45,6 @@ export const MonitorTable = ({
|
|||||||
monitors,
|
monitors,
|
||||||
refetch,
|
refetch,
|
||||||
setSelectedMonitor,
|
setSelectedMonitor,
|
||||||
selectedMonitors,
|
|
||||||
onSelectMonitor,
|
|
||||||
onSelectAll,
|
|
||||||
sortField,
|
sortField,
|
||||||
setSortField,
|
setSortField,
|
||||||
sortOrder,
|
sortOrder,
|
||||||
@@ -61,6 +59,7 @@ export const MonitorTable = ({
|
|||||||
}: MonitorTableProps) => {
|
}: MonitorTableProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const chartType = useSelector((state: RootState) => state.ui?.chartType ?? "histogram");
|
const chartType = useSelector((state: RootState) => state.ui?.chartType ?? "histogram");
|
||||||
const { post } = usePost<Record<string, never>, Monitor>();
|
const { post } = usePost<Record<string, never>, Monitor>();
|
||||||
|
|||||||
@@ -236,8 +236,10 @@ const UptimeMonitorsPage = () => {
|
|||||||
refetch={refetch}
|
refetch={refetch}
|
||||||
setSelectedMonitor={setSelectedMonitor}
|
setSelectedMonitor={setSelectedMonitor}
|
||||||
count={count || 0}
|
count={count || 0}
|
||||||
page={page}
|
setPage={(newPage) => {
|
||||||
setPage={setPage}
|
setPage(newPage);
|
||||||
|
setSelectedRows([]);
|
||||||
|
}}
|
||||||
rowsPerPage={rowsPerPage}
|
rowsPerPage={rowsPerPage}
|
||||||
sortField={sortField}
|
sortField={sortField}
|
||||||
setSortField={setSortField}
|
setSortField={setSortField}
|
||||||
@@ -251,6 +253,7 @@ const UptimeMonitorsPage = () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
setPage(0);
|
setPage(0);
|
||||||
|
setSelectedRows([]);
|
||||||
}}
|
}}
|
||||||
selectedRows={selectedRows}
|
selectedRows={selectedRows}
|
||||||
onSelectionChange={setSelectedRows}
|
onSelectionChange={setSelectedRows}
|
||||||
@@ -263,6 +266,7 @@ const UptimeMonitorsPage = () => {
|
|||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
loading={isDeleting}
|
loading={isDeleting}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<BulkEditNotificationsModal
|
<BulkEditNotificationsModal
|
||||||
open={isBulkEditModalOpen}
|
open={isBulkEditModalOpen}
|
||||||
onClose={() => setIsBulkEditModalOpen(false)}
|
onClose={() => setIsBulkEditModalOpen(false)}
|
||||||
|
|||||||
Reference in new issue
Block a user