From 5466d38496c3067f8f092b4259ed98dd358c9bd5 Mon Sep 17 00:00:00 2001 From: Owaise Imdad Date: Sat, 15 Mar 2025 01:44:00 +0530 Subject: [PATCH 1/3] FIX-1930 have made initial changes in order to proceed with rebuidling. --- .../Components/ConfigRow/index.jsx | 34 +++++++++++++ .../Components/MonitorsConfig/index.jsx | 49 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/Pages/Maintenance/CreateMaintenance/Components/ConfigRow/index.jsx create mode 100644 src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx diff --git a/src/Pages/Maintenance/CreateMaintenance/Components/ConfigRow/index.jsx b/src/Pages/Maintenance/CreateMaintenance/Components/ConfigRow/index.jsx new file mode 100644 index 000000000..93709ef1e --- /dev/null +++ b/src/Pages/Maintenance/CreateMaintenance/Components/ConfigRow/index.jsx @@ -0,0 +1,34 @@ +import { Box, Stack, Typography } from "@mui/material"; +import PropTypes from "prop-types"; +import { useTheme } from "@emotion/react"; +import ConfigBox from "../../../../../Components/ConfigBox"; + +const ConfigRow = ({ title, description, children }) => { + const theme = useTheme(); + + return ( + + + + {title} + + {description && ( + + {description} + + )} + + + {children} + + + ); +}; + +ConfigRow.propTypes = { + title: PropTypes.string.isRequired, + description: PropTypes.string, + children: PropTypes.node +}; + +export default ConfigRow; \ No newline at end of file diff --git a/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx b/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx new file mode 100644 index 000000000..f8955a873 --- /dev/null +++ b/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx @@ -0,0 +1,49 @@ +import PropTypes from "prop-types"; +import ConfigRow from "../ConfigRow"; +import Search from "../../../../../Components/Inputs/Search"; +import { useState } from "react"; + +const MonitorsConfig = ({ + monitors, + selectedMonitors, + error, + isEditMode, + onSelectMonitors, + secondaryLabelText, +}) => { + const [search, setSearch] = useState(""); + const handleSearch = (value) => { + setSearch(value); + }; + + return ( + + + + ); +}; + +MonitorsConfig.propTypes = { + monitors: PropTypes.array.isRequired, + selectedMonitors: PropTypes.array.isRequired, + error: PropTypes.string, + isEditMode: PropTypes.bool.isRequired, + onSelectMonitors: PropTypes.func.isRequired, + secondaryLabelText: PropTypes.string, +}; + +export default MonitorsConfig; From e881c72ec925723644772bb7fce57d69f743b541 Mon Sep 17 00:00:00 2001 From: Owaise Imdad Date: Sat, 15 Mar 2025 02:09:18 +0530 Subject: [PATCH 2/3] FIX-1930 change the text in order to make sure there is clarity. --- .../CreateMaintenance/Components/MonitorsConfig/index.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx b/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx index f8955a873..532e48f8d 100644 --- a/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx +++ b/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx @@ -9,7 +9,7 @@ const MonitorsConfig = ({ error, isEditMode, onSelectMonitors, - secondaryLabelText, + secondaryLabel, }) => { const [search, setSearch] = useState(""); const handleSearch = (value) => { @@ -25,7 +25,7 @@ const MonitorsConfig = ({ isAdorned={false} options={monitors || []} filteredBy="name" - secondaryLabel={secondaryLabelText} + secondaryLabel={secondaryLabel} inputValue={search} value={selectedMonitors} handleInputChange={handleSearch} @@ -43,7 +43,7 @@ MonitorsConfig.propTypes = { error: PropTypes.string, isEditMode: PropTypes.bool.isRequired, onSelectMonitors: PropTypes.func.isRequired, - secondaryLabelText: PropTypes.string, + secondaryLabel: PropTypes.string, }; export default MonitorsConfig; From 45a3ea2da0ac56ed8d51cf760844ad2e63d9680d Mon Sep 17 00:00:00 2001 From: Owaise Imdad Date: Sat, 15 Mar 2025 23:26:10 +0530 Subject: [PATCH 3/3] Refactored and moved the config row component to main conponents folders to be reused. --- .../Components/ConfigRow/index.jsx | 21 ++++++++++++++--- .../Components/MonitorsConfig/index.jsx | 23 +++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) rename src/{Pages/Maintenance/CreateMaintenance => }/Components/ConfigRow/index.jsx (57%) diff --git a/src/Pages/Maintenance/CreateMaintenance/Components/ConfigRow/index.jsx b/src/Components/ConfigRow/index.jsx similarity index 57% rename from src/Pages/Maintenance/CreateMaintenance/Components/ConfigRow/index.jsx rename to src/Components/ConfigRow/index.jsx index 93709ef1e..c19d9ac5a 100644 --- a/src/Pages/Maintenance/CreateMaintenance/Components/ConfigRow/index.jsx +++ b/src/Components/ConfigRow/index.jsx @@ -1,7 +1,22 @@ import { Box, Stack, Typography } from "@mui/material"; import PropTypes from "prop-types"; import { useTheme } from "@emotion/react"; -import ConfigBox from "../../../../../Components/ConfigBox"; +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 ( + * + *
Left content (Title + Description)
+ *
Right content (Children)
+ *
+ * ); + */ const ConfigRow = ({ title, description, children }) => { const theme = useTheme(); @@ -28,7 +43,7 @@ const ConfigRow = ({ title, description, children }) => { ConfigRow.propTypes = { title: PropTypes.string.isRequired, description: PropTypes.string, - children: PropTypes.node + children: PropTypes.node, }; -export default ConfigRow; \ No newline at end of file +export default ConfigRow; diff --git a/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx b/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx index 532e48f8d..e792734ff 100644 --- a/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx +++ b/src/Pages/Maintenance/CreateMaintenance/Components/MonitorsConfig/index.jsx @@ -1,7 +1,23 @@ import PropTypes from "prop-types"; -import ConfigRow from "../ConfigRow"; 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, @@ -17,7 +33,10 @@ const MonitorsConfig = ({ }; return ( - +