fix(ui): resolve PR feedback regarding type casts and hardcoded spacing

This commit is contained in:
ashu130698 committed 2026-05-14 15:50:56 +05:30
1 parent 3c05b9df98
commit c740fb1aca
3 files changed
+32 -25

No files matched your search

@@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useTheme } from "@mui/material/styles"; import { useTheme } from "@mui/material/styles";
import { Dialog, Select, RadioWithDescription } from "@/Components/inputs"; import { Dialog, Select, RadioWithDescription } from "@/Components/inputs";
import { SPACING, LAYOUT } from "@/Utils/Theme/constants";
import Stack from "@mui/material/Stack"; 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";
@@ -58,7 +59,7 @@ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProp
onComplete(!!res); onComplete(!!res);
}; };
// Prevent submitting empty arrays unless the action is 'set' (as per PR feedback!) // Prevent submitting empty arrays unless the action is 'set'
const isMissingSelection = action !== "set" && notificationIds.length === 0; const isMissingSelection = action !== "set" && notificationIds.length === 0;
return ( return (
@@ -72,8 +73,8 @@ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProp
fullWidth fullWidth
> >
<Stack <Stack
spacing={theme.spacing(4)} spacing={theme.spacing(LAYOUT.XS)}
mt={theme.spacing(2)} mt={theme.spacing(SPACING.LG)}
> >
{error && <Alert severity="error">{error}</Alert>} {error && <Alert severity="error">{error}</Alert>}
<Typography variant="body1"> <Typography variant="body1">
@@ -84,7 +85,12 @@ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProp
<RadioGroup <RadioGroup
value={action} value={action}
onChange={(e) => setAction(e.target.value as "add" | "remove" | "set")} onChange={(e) => {
const val = e.target.value;
if (val === "add" || val === "remove" || val === "set") {
setAction(val);
}
}}
> >
<RadioWithDescription <RadioWithDescription
value="add" value="add"
@@ -106,7 +112,14 @@ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProp
<Select <Select
multiple multiple
value={notificationIds} value={notificationIds}
onChange={(e) => setNotificationIds(e.target.value as string[])} onChange={(e) => {
const val = e.target.value;
if (typeof val === "string") {
setNotificationIds(val.split(","));
} else if (Array.isArray(val)) {
setNotificationIds(val.filter((v) => typeof v === "string"));
}
}}
fieldLabel={t("pages.common.monitors.bulkEdit.selectLabel")} fieldLabel={t("pages.common.monitors.bulkEdit.selectLabel")}
placeholder={t("pages.common.monitors.bulkEdit.selectPlaceholder")} placeholder={t("pages.common.monitors.bulkEdit.selectPlaceholder")}
> >
@@ -23,6 +23,7 @@ import type { Monitor } from "@/Types/Monitor";
import type { ActionMenuItem } from "@/Components/actions-menu"; import type { ActionMenuItem } from "@/Components/actions-menu";
import type { RootState } from "@/Types/state"; import type { RootState } from "@/Types/state";
import { Checkbox } from "@/Components/inputs"; import { Checkbox } from "@/Components/inputs";
import { SPACING, LAYOUT } from "@/Utils/Theme/constants";
interface MonitorTableProps { interface MonitorTableProps {
monitors: Monitor[]; monitors: Monitor[];
@@ -208,7 +209,7 @@ export const MonitorTable = ({
mobileLabel: t("common.table.headers.name"), mobileLabel: t("common.table.headers.name"),
content: ( content: (
<Stack <Stack
gap={theme.spacing(4)} gap={theme.spacing(LAYOUT.XS)}
direction={"row"} direction={"row"}
alignItems={"center"} alignItems={"center"}
onClick={(e) => handleSort(e, "name")} onClick={(e) => handleSort(e, "name")}
@@ -228,14 +229,14 @@ export const MonitorTable = ({
mobileLabel: t("common.table.headers.status"), mobileLabel: t("common.table.headers.status"),
content: ( content: (
<Stack <Stack
gap={theme.spacing(4)} gap={theme.spacing(LAYOUT.XS)}
direction={"row"} direction={"row"}
justifyContent={"center"} justifyContent={"center"}
alignItems={"center"} alignItems={"center"}
onClick={(e) => handleSort(e, "status")} onClick={(e) => handleSort(e, "status")}
sx={{ cursor: "pointer" }} sx={{ cursor: "pointer" }}
> >
<Box width={theme.spacing(8)} /> <Box width={theme.spacing(LAYOUT.MD)} />
{t("common.table.headers.status")} {t("common.table.headers.status")}
{renderSortIcon(sortField === "status")} {renderSortIcon(sortField === "status")}
</Stack> </Stack>
@@ -260,14 +261,14 @@ export const MonitorTable = ({
mobileLabel: t("common.table.headers.type"), mobileLabel: t("common.table.headers.type"),
content: ( content: (
<Stack <Stack
gap={theme.spacing(4)} gap={theme.spacing(LAYOUT.XS)}
direction={"row"} direction={"row"}
justifyContent={"center"} justifyContent={"center"}
alignItems={"center"} alignItems={"center"}
onClick={(e) => handleSort(e, "type")} onClick={(e) => handleSort(e, "type")}
sx={{ cursor: "pointer" }} sx={{ cursor: "pointer" }}
> >
<Box width={theme.spacing(8)} /> <Box width={theme.spacing(LAYOUT.MD)} />
{t("common.table.headers.type")} {t("common.table.headers.type")}
{renderSortIcon(sortField === "type")} {renderSortIcon(sortField === "type")}
</Stack> </Stack>
@@ -293,26 +294,18 @@ export const MonitorTable = ({
<Box> <Box>
{isSmall && ( {isSmall && (
<Box <Box
px={1} px={SPACING.SM}
pb={2} pb={SPACING.LG}
> >
<Stack <Stack
direction="row" direction="row"
alignItems="center" alignItems="center"
spacing={1} spacing={SPACING.SM}
> >
<Checkbox <Checkbox
checked={monitors.length > 0 && selectedMonitors.length === monitors.length} checked={isAllSelected}
indeterminate={ indeterminate={isSomeSelected}
selectedMonitors.length > 0 && selectedMonitors.length < monitors.length onChange={(e) => handleSelectAll(e.target.checked)}
}
onChange={(e) => {
if (e.target.checked) {
onSelectAll(monitors.map((m) => m.id));
} else {
onSelectAll([]);
}
}}
/> />
<Typography <Typography
variant="body2" variant="body2"
+2 -1
View File
@@ -23,6 +23,7 @@ import type { RootState } from "@/Types/state";
import { useTheme } from "@mui/material"; import { useTheme } from "@mui/material";
import useDebounce from "@/Hooks/useDebounce"; import useDebounce from "@/Hooks/useDebounce";
import { useBulkMonitorActions } from "@/Hooks/useBulkMonitorActions"; import { useBulkMonitorActions } from "@/Hooks/useBulkMonitorActions";
import { SPACING, LAYOUT } from "@/Utils/Theme/constants";
const UptimeMonitorsPage = () => { const UptimeMonitorsPage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -183,7 +184,7 @@ const UptimeMonitorsPage = () => {
<Stack <Stack
direction={isSmall ? "column" : "row"} direction={isSmall ? "column" : "row"}
justifyContent={isSmall ? "flex-start" : "space-between"} justifyContent={isSmall ? "flex-start" : "space-between"}
gap={theme.spacing(4)} gap={theme.spacing(LAYOUT.XS)}
> >
<ControlsFilter <ControlsFilter
selectedTypes={selectedTypes} selectedTypes={selectedTypes}