fix(monitors): address PR feedback on mobile card views and modal selection state

This commit is contained in:
ashu130698 committed 2026-05-14 15:48:55 +05:30
1 parent eeee6db94e
commit 7a5ee6ba05
4 files changed
+39 -11

No files matched your search

@@ -142,7 +142,7 @@ export function DataTable<
> >
<Typography <Typography
component="div" component="div"
color={theme.palette.text.primary} color={theme.palette.text.secondary}
> >
{header.mobileLabel ?? header.content} {header.mobileLabel ?? header.content}
</Typography> </Typography>
@@ -14,14 +14,14 @@ interface BulkEditNotificationsModalProps {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
selectedMonitors: string[]; selectedMonitors: string[];
onSuccess: () => void; onComplete: (success: boolean) => void;
} }
export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProps> = ({ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProps> = ({
open, open,
onClose, onClose,
selectedMonitors, selectedMonitors,
onSuccess, onComplete,
}) => { }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const theme = useTheme(); const theme = useTheme();
@@ -55,9 +55,7 @@ export const BulkEditNotificationsModal: React.FC<BulkEditNotificationsModalProp
action, action,
}); });
if (res) { onComplete(!!res);
onSuccess();
}
}; };
// Prevent submitting empty arrays unless the action is 'set' (as per PR feedback!) // Prevent submitting empty arrays unless the action is 'set' (as per PR feedback!)
@@ -291,6 +291,35 @@ export const MonitorTable = ({
return ( return (
<Box> <Box>
{isSmall && (
<Box px={1} pb={2}>
<Stack
direction="row"
alignItems="center"
spacing={1}
>
<Checkbox
checked={monitors.length > 0 && selectedMonitors.length === monitors.length}
indeterminate={
selectedMonitors.length > 0 && selectedMonitors.length < monitors.length
}
onChange={(e) => {
if (e.target.checked) {
onSelectAll(monitors.map((m) => m.id));
} else {
onSelectAll([]);
}
}}
/>
<Typography
variant="body2"
color="text.secondary"
>
{t("common.selectAll", "Select All")}
</Typography>
</Stack>
</Box>
)}
<Table <Table
headers={headers} headers={headers}
data={monitors} data={monitors}
+6 -5
View File
@@ -137,10 +137,12 @@ const UptimeMonitorsPage = () => {
refetch(); refetch();
}; };
const handleBulkEditSuccess = () => { const handleBulkEditComplete = (success: boolean) => {
setIsBulkEditModalOpen(false); setIsBulkEditModalOpen(false);
setSelectedRows([]); if (success) {
refetch(); setSelectedRows([]);
refetch();
}
}; };
const handleCancel = () => { const handleCancel = () => {
@@ -267,12 +269,11 @@ const UptimeMonitorsPage = () => {
onCancel={handleCancel} onCancel={handleCancel}
loading={isDeleting} loading={isDeleting}
/> />
<BulkEditNotificationsModal <BulkEditNotificationsModal
open={isBulkEditModalOpen} open={isBulkEditModalOpen}
onClose={() => setIsBulkEditModalOpen(false)} onClose={() => setIsBulkEditModalOpen(false)}
selectedMonitors={selectedRows} selectedMonitors={selectedRows}
onSuccess={handleBulkEditSuccess} onComplete={handleBulkEditComplete}
/> />
</MonitorBasePageWithStates> </MonitorBasePageWithStates>
); );