Skip to content
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

Merged

Conversation

YulNaumenko
Copy link
Contributor

Resolve #60583

@YulNaumenko YulNaumenko added bug Fixes for quality problems that affect the customer experience Feature:Alerting v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.7.0 Feature:UIActions UI actions. These are client side only, not related to the server side actions.. Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Mar 20, 2020
@YulNaumenko YulNaumenko requested a review from a team as a code owner March 20, 2020 02:53
@YulNaumenko YulNaumenko self-assigned this Mar 20, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

Copy link
Contributor

@gmmorris gmmorris left a 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:

  1. That reduce can be replaced with a much simpler array now that we don't need the keys. :)

  2. 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 the actions.map (on line 431) so that we created just before calling getActionTypeForm 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 😃

Copy link
Member

@pmuellr pmuellr left a 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 :-)

…-multiple-actions

# Conflicts:
#	x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx
@YulNaumenko YulNaumenko requested a review from a team as a code owner March 20, 2020 17:22
Copy link
Contributor

@andreadelrio andreadelrio left a 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.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@YulNaumenko YulNaumenko merged commit 67a01a7 into elastic:master Mar 20, 2020
YulNaumenko added a commit to YulNaumenko/kibana that referenced this pull request Mar 20, 2020
…type to an alert (elastic#60720)

* Allows multiple action under the same connector for alert

* Fixed due to comments

* fixed ui issue
YulNaumenko added a commit that referenced this pull request Mar 20, 2020
…type to an alert (#60720) (#60797)

* Allows multiple action under the same connector for alert

* Fixed due to comments

* fixed ui issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Alerting Feature:UIActions UI actions. These are client side only, not related to the server side actions.. release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove restriction on adding multiple connectors of the same action type to an alert.
6 participants