update pagespeed

This commit is contained in:
Alex Holliday committed 2026-01-12 23:57:39 +00:00
1 parent 7a6b0d5da4
commit 25d1039376
204 files changed
+977 -343

No files matched your search

@@ -0,0 +1,38 @@
import Select from "@/Components/v1/Inputs/Select/index.jsx";
import PropTypes from "prop-types";
const ConfigSelect = ({ configSelection, valueSelect, onChange, ...props }) => {
const getValueById = (config, id) => {
const item = config.find((config) => config._id === id);
return item ? (item.value ? item.value : item.name) : null;
};
const getIdByValue = (config, name) => {
const item = config.find((config) => {
if (config.value) {
return config.value === name;
} else {
return config.name === name;
}
});
return item ? item._id : null;
};
return (
<Select
value={getIdByValue(configSelection, valueSelect)}
onChange={(event) => {
const newValue = getValueById(configSelection, event.target.value);
onChange(newValue);
}}
items={configSelection}
{...props}
/>
);
};
ConfigSelect.propTypes = {
configSelection: PropTypes.array.isRequired,
valueSelect: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
};
export default ConfigSelect;
@@ -0,0 +1,69 @@
// Components
import { Stack, Typography } from "@mui/material";
import DeleteIcon from "@mui/icons-material/Delete";
import { useTheme } from "@emotion/react";
import PropTypes from "prop-types";
const MonitorListItem = ({ monitor, onDelete }) => {
const theme = useTheme();
return (
<Stack
direction={"row"}
alignItems={"center"}
gap={theme.spacing(4)}
width="100%"
>
<Typography flexGrow={1}>{monitor.name}</Typography>
<DeleteIcon
sx={{ cursor: "pointer" }}
onClick={() => onDelete(monitor)}
/>
</Stack>
);
};
MonitorListItem.propTypes = {
monitor: PropTypes.shape({
_id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
}).isRequired,
onDelete: PropTypes.func.isRequired,
};
const MonitorList = ({ selectedMonitors, setSelectedMonitors }) => {
const onDelete = (monitorToDelete) => {
const newMonitors = selectedMonitors.filter(
(monitor) => monitor._id !== monitorToDelete._id
);
setSelectedMonitors(newMonitors);
};
const theme = useTheme();
return (
<Stack
gap={theme.spacing(6)}
width="100%"
>
{selectedMonitors?.map((monitor) => (
<MonitorListItem
key={monitor._id}
monitor={monitor}
onDelete={onDelete}
/>
))}
</Stack>
);
};
MonitorList.propTypes = {
selectedMonitors: PropTypes.arrayOf(
PropTypes.shape({
_id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
})
).isRequired,
setSelectedMonitors: PropTypes.func.isRequired,
};
export default MonitorList;
@@ -0,0 +1,68 @@
import PropTypes from "prop-types";
import Search from "@/Components/v1/Inputs/Search/index.jsx";
import { useState } from "react";
import ConfigRow from "@/Components/v1/ConfigRow/index.jsx";
/**
* 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;