-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed restriction on adding multiple connectors of the same action type to an alert #60720
Removed restriction on adding multiple connectors of the same action type to an alert #60720
Conversation
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I have a few clean up suggestions:
-
That reduce can be replaced with a much simpler array now that we don't need the keys. :)
-
It feels like we're relying a lot on the index not changing, which can be hard to follow as a developer new to the code. Would it be possible to create the
actionsErrors
inside of theactions.map
(on line 431) so that we created just before callinggetActionTypeForm
for each action? That way, you have less "global state" in the component.
This would mean ending up with something like this:
...
return (
<Fragment>
{actions.map((actionItem: AlertAction, index: number) => {
const actionConnector = connectors.find(field => field.id === actionItem.id);
// connectors doesn't exists
if (!actionConnector) {
return getAddConnectorsForm(actionItem, index);
}
const actionErrors: Array<{ errors: IErrorObject }> = actionTypeRegistry.get(alertAction.actionTypeId)?.validateParams(alertAction.params);
);
return getActionTypeForm(actionItem, actionConnector, actionErrors, index);
})}
<EuiSpacer size="m" />
...
That way you're only using the index for the key, not for finding the error, which is a bit easier for me to follow, 🤷♂
Just some thoughts 😃
...lugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx
Outdated
Show resolved
Hide resolved
...lugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_edit.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concur with Gidi's comments.
Longer-term, we'll need a way to re-order these actions - they're stored as an array, and a customer might want to reorder them for some reason. Not needed for 7.7 :-)
...lugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx
Outdated
Show resolved
Hide resolved
…-multiple-actions # Conflicts: # x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to look into a better fix for that z-index later but this should do it for now.
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…type to an alert (elastic#60720) * Allows multiple action under the same connector for alert * Fixed due to comments * fixed ui issue
Resolve #60583