Local modifications to ClusterLabs/Anvil by Alteeve
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

60 lines
1.6 KiB

import { FC } from 'react';
import { v4 as uuidv4 } from 'uuid';
import AlertOverrideInputGroup from './AlertOverrideInputGroup';
import List from '../List';
const ManageAlertOverride: FC<ManageAlertOverrideProps> = (props) => {
const {
alertOverrideTargetOptions,
formikUtils,
mailRecipientUuid: mrUuid,
} = props;
const { formik } = formikUtils;
const {
values: { [mrUuid]: mailRecipient },
} = formik;
const { alertOverrides } = mailRecipient;
return (
<List
allowAddItem
edit
header="Alert override rules"
listEmpty="No alert overrides(s)"
listItems={alertOverrides}
onAdd={() => {
/**
* This is **not** the same as an alert override UUID because 1 alert
* override formik value can reference _n_ alert override rules, where
* _n_ is the number of subnodes per node. */
const valueId = uuidv4();
formik.setValues((previous) => {
const shallow = { ...previous };
const { [mrUuid]: mr } = shallow;
mr.alertOverrides = {
...mr.alertOverrides,
[valueId]: { level: 2, target: null },
};
return shallow;
});
}}
renderListItem={(valueId, value) =>
!value.remove && (
<AlertOverrideInputGroup
alertOverrideTargetOptions={alertOverrideTargetOptions}
alertOverrideValueId={valueId}
formikUtils={formikUtils}
mailRecipientUuid={mrUuid}
/>
)
}
/>
);
};
export default ManageAlertOverride;