add the checkboxes for dropdown list and remove searchbox list inside it

This commit is contained in:
shanika Jayawardane committed 2025-07-12 15:13:24 -06:00
1 parent 6e76e29768
commit 39d666df6b
1 file changed
+9 -24
@@ -222,23 +222,14 @@ const CreateMaintenance = () => {
}; };
const handleMonitorsChange = (selected) => { const handleMonitorsChange = (selected) => {
if (selected.some((m) => m._id === "__all__")) { // Ensure all are objects
if (selectedMonitors.length !== monitors.length) { const selectedObjs = selected
setSelectedMonitors(monitors); .map((sel) => (typeof sel === "string" ? monitors.find((m) => m._id === sel) : sel))
} else { .filter(Boolean);
setSelectedMonitors([]); setSelectedMonitors(selectedObjs);
}
} else {
// Ensure all are objects
const selectedObjs = selected
.map((sel) =>
typeof sel === "string" ? monitors.find((m) => m._id === sel) : sel
)
.filter(Boolean);
setSelectedMonitors(selectedObjs);
}
const { error } = maintenanceWindowValidation.validate( const { error } = maintenanceWindowValidation.validate(
{ monitors: selected }, { monitors: selectedObjs },
{ abortEarly: false } { abortEarly: false }
); );
setErrors((prev) => { setErrors((prev) => {
@@ -246,8 +237,6 @@ const CreateMaintenance = () => {
}); });
}; };
const allSelected = selectedMonitors.length === monitors.length && monitors.length > 0;
const handleSubmit = async () => { const handleSubmit = async () => {
if (hasValidationErrors(form, maintenanceWindowValidation, setErrors)) return; if (hasValidationErrors(form, maintenanceWindowValidation, setErrors)) return;
// Build timestamp for maintenance window from startDate and startTime // Build timestamp for maintenance window from startDate and startTime
@@ -303,10 +292,6 @@ const CreateMaintenance = () => {
} }
}; };
// Add Select All option to the dropdown
const selectAllOption = { _id: "__all__", name: t("selectAll") };
const monitorOptions = [selectAllOption, ...monitors];
return ( return (
<Box className="create-maintenance"> <Box className="create-maintenance">
<Breadcrumbs <Breadcrumbs
@@ -565,8 +550,8 @@ const CreateMaintenance = () => {
id={"monitors"} id={"monitors"}
label={t("addMonitors")} label={t("addMonitors")}
multiple={true} multiple={true}
isAdorned={false} isAdorned={true}
options={monitorOptions} options={monitors}
filteredBy="name" filteredBy="name"
secondaryLabel={"type"} secondaryLabel={"type"}
inputValue={search} inputValue={search}