in public/pages/CreateTrigger/containers/CreateTrigger/utils/formikToTrigger.js [103:146]
export function formikToBucketLevelTriggerAction(values) {
const actions = values.actions;
const executionPolicyPath = 'action_execution_policy.action_execution_scope';
if (actions && actions.length > 0) {
return actions.map((action) => {
let formattedAction = _.cloneDeep(action);
switch (formattedAction.throttle_enabled) {
case true:
_.set(formattedAction, 'throttle.unit', FORMIK_INITIAL_ACTION_VALUES.throttle.unit);
break;
case false:
formattedAction = _.omit(formattedAction, ['throttle']);
break;
}
const notifyOption = _.get(formattedAction, `${executionPolicyPath}`);
const notifyOptionId = _.isString(notifyOption) ? notifyOption : _.keys(notifyOption)[0];
switch (notifyOptionId) {
case NOTIFY_OPTIONS_VALUES.PER_ALERT:
const actionableAlerts = _.get(
formattedAction,
`${executionPolicyPath}.${NOTIFY_OPTIONS_VALUES.PER_ALERT}.actionable_alerts`,
[]
);
_.set(
formattedAction,
`${executionPolicyPath}.${NOTIFY_OPTIONS_VALUES.PER_ALERT}.actionable_alerts`,
actionableAlerts.map((entry) => entry.value)
);
break;
case NOTIFY_OPTIONS_VALUES.PER_EXECUTION:
_.set(
formattedAction,
`${executionPolicyPath}.${NOTIFY_OPTIONS_VALUES.PER_EXECUTION}`,
{}
);
break;
}
return formattedAction;
});
}
return actions;
}