Merge remote-tracking branch 'upstream/develop' into feat/handleTestNotification
This commit is contained in:
commit
3136bdbfa7
4 files changed
+121
-2
No files matched your search
@@ -0,0 +1,49 @@
|
|||||||
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
import { useTheme } from "@emotion/react";
|
||||||
|
import ConfigBox from "../ConfigBox";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ConfigRow is a styled container used to layout content in a row format with specific padding, border, and spacing.
|
||||||
|
* It serves as the wrapper for ConfigBox, with the left section displaying the title and description,
|
||||||
|
* and the right section displaying the children.
|
||||||
|
*
|
||||||
|
* @component
|
||||||
|
* @example
|
||||||
|
* return (
|
||||||
|
* <ConfigBox>
|
||||||
|
* <div>Left content (Title + Description)</div>
|
||||||
|
* <div>Right content (Children)</div>
|
||||||
|
* </ConfigBox>
|
||||||
|
* );
|
||||||
|
*/
|
||||||
|
|
||||||
|
const ConfigRow = ({ title, description, children }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConfigBox>
|
||||||
|
<Box>
|
||||||
|
<Typography component="h2" variant="h2">
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
{description && (
|
||||||
|
<Typography variant="body2" mt={theme.spacing(2)}>
|
||||||
|
{description}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
<Stack gap={theme.spacing(15)} mt={theme.spacing(4)}>
|
||||||
|
{children}
|
||||||
|
</Stack>
|
||||||
|
</ConfigBox>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ConfigRow.propTypes = {
|
||||||
|
title: PropTypes.string.isRequired,
|
||||||
|
description: PropTypes.string,
|
||||||
|
children: PropTypes.node,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ConfigRow;
|
||||||
@@ -154,6 +154,7 @@ const Search = ({
|
|||||||
}}
|
}}
|
||||||
renderOption={(props, option) => {
|
renderOption={(props, option) => {
|
||||||
const { key, ...optionProps } = props;
|
const { key, ...optionProps } = props;
|
||||||
|
const hasSecondaryLabel = secondaryLabel && option[secondaryLabel] !== undefined;
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<ListItem
|
||||||
key={key}
|
key={key}
|
||||||
@@ -167,7 +168,8 @@ const Search = ({
|
|||||||
: {}
|
: {}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{option[filteredBy] + (secondaryLabel ? ` (${option[secondaryLabel]})` : "")}
|
{option[filteredBy] +
|
||||||
|
(hasSecondaryLabel ? ` (${option[secondaryLabel]})` : "")}
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import PropTypes from "prop-types";
|
||||||
|
import Search from "../../../../../Components/Inputs/Search";
|
||||||
|
import { useState } from "react";
|
||||||
|
import ConfigRow from "../../../../../Components/ConfigRow";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MonitorsConfig is a component that allows users to select and apply a maintenance window to a list of monitors.
|
||||||
|
* It provides a search input to filter monitors and select multiple options. The selected monitors are passed
|
||||||
|
* to the parent via the `onSelectMonitors` callback.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @component
|
||||||
|
*
|
||||||
|
* @param {Array} props.monitors - List of available monitors that can be selected.
|
||||||
|
* @param {Array} props.selectedMonitors - List of monitors currently selected for applying the maintenance window.
|
||||||
|
* @param {string} [props.error] - Optional error message that will be displayed if there's an error in monitor selection.
|
||||||
|
* @param {boolean} props.isEditMode - A boolean flag indicating if the component is in edit mode (disabled search/input when true).
|
||||||
|
* @param {Function} props.onSelectMonitors - Callback function that is invoked when monitors are selected or deselected.
|
||||||
|
* @param {string} [props.secondaryLabel] - Optional label or description that provides additional context for the monitor search.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const MonitorsConfig = ({
|
||||||
|
monitors,
|
||||||
|
selectedMonitors,
|
||||||
|
error,
|
||||||
|
isEditMode,
|
||||||
|
onSelectMonitors,
|
||||||
|
secondaryLabel,
|
||||||
|
}) => {
|
||||||
|
const [search, setSearch] = useState("");
|
||||||
|
const handleSearch = (value) => {
|
||||||
|
setSearch(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConfigRow
|
||||||
|
title="Monitors for maintenance"
|
||||||
|
description="Select monitors to apply the maintenance window to. Use the search field to filter and choose multiple monitors."
|
||||||
|
>
|
||||||
|
<Search
|
||||||
|
id={"monitors"}
|
||||||
|
label="Add monitors"
|
||||||
|
multiple={true}
|
||||||
|
isAdorned={false}
|
||||||
|
options={monitors || []}
|
||||||
|
filteredBy="name"
|
||||||
|
secondaryLabel={secondaryLabel}
|
||||||
|
inputValue={search}
|
||||||
|
value={selectedMonitors}
|
||||||
|
handleInputChange={handleSearch}
|
||||||
|
handleChange={onSelectMonitors}
|
||||||
|
error={error}
|
||||||
|
disabled={isEditMode}
|
||||||
|
/>
|
||||||
|
</ConfigRow>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
MonitorsConfig.propTypes = {
|
||||||
|
monitors: PropTypes.array.isRequired,
|
||||||
|
selectedMonitors: PropTypes.array.isRequired,
|
||||||
|
error: PropTypes.string,
|
||||||
|
isEditMode: PropTypes.bool.isRequired,
|
||||||
|
onSelectMonitors: PropTypes.func.isRequired,
|
||||||
|
secondaryLabel: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MonitorsConfig;
|
||||||
@@ -409,7 +409,7 @@ const CreateMaintenance = () => {
|
|||||||
backgroundColor: theme.palette.accent.light, // Hover background
|
backgroundColor: theme.palette.accent.light, // Hover background
|
||||||
},
|
},
|
||||||
"&.Mui-disabled": {
|
"&.Mui-disabled": {
|
||||||
color: theme.palette.primary.ContrastTextTertiary, // Disabled day color
|
color: theme.palette.secondary.main, // Disabled day color
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"& .MuiDayCalendar-weekDayLabel": {
|
"& .MuiDayCalendar-weekDayLabel": {
|
||||||
|
|||||||
Reference in new issue
Block a user