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

[Alerting UI] Alert and Connector flyouts Save and Save&Test buttons should be active by default. #86708

Merged

Conversation

YulNaumenko
Copy link
Contributor

@YulNaumenko YulNaumenko commented Dec 21, 2020

Current PR is making Save and Save&Test buttons always available:

  1. Alert Create Flyout. With proper validation triggered on the click Save:

Screen Shot 2020-12-22 at 11 56 59 AM

Screen Shot 2020-12-22 at 11 56 49 AM

  1. Alert Edit Flyout

Screen Shot 2020-12-22 at 12 10 03 PM

  1. Connector Create

Screen Shot 2020-12-22 at 12 10 59 PM

  1. Connector Edit

Screen Shot 2020-12-21 at 2 23 03 PM

  1. Connector Modal

Screen Shot 2020-12-21 at 2 14 08 PM

Resolve #84091

@YulNaumenko YulNaumenko added Feature:Alerting v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:Actions Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v7.12.0 labels Dec 21, 2020
@YulNaumenko YulNaumenko self-assigned this Dec 21, 2020
@YulNaumenko YulNaumenko changed the title Alert and Connector flyouts Save and Save&Test buttons should be active by default. [Alerting UI] Alert and Connector flyouts Save and Save&Test buttons should be active by default. Dec 21, 2020
@YulNaumenko YulNaumenko marked this pull request as ready for review December 22, 2020 20:11
@YulNaumenko YulNaumenko requested review from a team as code owners December 22, 2020 20:11
@elasticmachine
Copy link
Contributor

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

@YulNaumenko YulNaumenko requested a review from a team December 23, 2020 00:53
Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review looks good! Very clear what the errors are now :) Left a question about whether we should be clearing invalid input on Save vs leaving it in the form for user to fix.

@@ -43,3 +44,66 @@ export const isValidUrl = (urlString: string, protocol?: string) => {
return false;
}
};

export function getConnectorWithInvalidatedFields(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add unit tests for these new functions?

configErrors: IErrorObject,
secretsErrors: IErrorObject,
baseConnectorErrors: IErrorObject
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I create an email connector and enter an invalid Sender field, I get immediate feedback on the form that "Sender is not a valid email address." but then if I press Save, my (invalid) entry is cleared and the error just says "Sender is required.". Would it be better to keep the user input so the user can fix it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! I will fix it.

Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@igoristic igoristic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monitoring looks good 👍

@gmmorris
Copy link
Contributor

gmmorris commented Dec 31, 2020

Screenshot 2020-12-31 at 10 25 04

Alert trigger is required.

I'm wondering about the wording here... I don't think its right as it isn't quite clear what trigger means...
(I know this wasn't added in this PR, but this PR does make it more likely users will see it. :) )

The user has a list of Alert types... and we want them to choose one...
But I'm not sure Alert type is any clearer than Alert trigger... 🤷

@gchaps any thoughts?

@gmmorris
Copy link
Contributor

We don't seem to show any error when the user chooses an action that has no connector (see below).

Screenshot 2020-12-31 at 10 27 35

We don't allow the user to save, but we don't show a validation error either.

@@ -192,7 +192,7 @@ export const EmailActionConnectorFields: React.FunctionComponent<
}
)}
disabled={readOnly}
checked={hasAuth}
checked={hasAuth || false}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasAuth is boolean, so I can't figure out why || false is needed.... 🤔
If it can be undefined then something seems to be wrong in the typing 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current implementation, the initial alert object has all user input fields as undefined to be able to not trigger validation on the form opening (each input field has a check on undefined to not set a validation error in this case). When onblur event on the field or click save we are triggering invalidating the values - basically setting it to null instead of undefined.
Do you think we should consider another approach for implementing UI inputs validation triggering?

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.

Left a few typing problems that need sorting but nothing major.
Behaviour wise all looks good except for the missing error when an action is selected but no connector is configured, so happy to approve assuming this is sorted :)

👍

Comment on lines 116 to 118
const alertParamsErrors = (alertTypeModel
? alertTypeModel.validate(alert.params).errors
: []) as IErrorObject;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong 🤔
the type signature for IErrorObject can't be []... this is probably passing because of the explicit as casting.
It's best to avoid this sort of casting as it can hide errors... better to do this:

const alertParamsErrors: IErrorObject =  ....

@@ -31,13 +31,13 @@ const JiraConnectorFields: React.FC<ActionConnectorFieldsProps<JiraActionConnect
}) => {
const { apiUrl, projectKey } = action.config;

const isApiUrlInvalid: boolean = errors.apiUrl.length > 0 && apiUrl != null;
const isApiUrlInvalid: boolean = errors.apiUrl.length > 0 && apiUrl !== undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as != null except now you are allowing null as a valid apiUrl. Why?

Copy link
Contributor Author

@YulNaumenko YulNaumenko Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added undefined as a value to compare to skip the input validation on the form initialization (before the user did some input or clicked Save). If it is null currently, this is expected an invalid user input trigger and invalid fields will be highlighted. Do you have any issues with this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sound good to me, just wondering the reasoning. thank you!

@@ -29,13 +29,14 @@ const ResilientConnectorFields: React.FC<ActionConnectorFieldsProps<ResilientAct
readOnly,
}) => {
const { apiUrl, orgId } = action.config;
const isApiUrlInvalid: boolean = errors.apiUrl.length > 0 && apiUrl != null;
const isApiUrlInvalid: boolean = errors.apiUrl.length > 0 && apiUrl !== undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question here

@@ -35,7 +35,8 @@ const editAction = jest.fn();
const defaultProps = {
actionConnector: connector,
actionParams,
errors: { short_description: [] },
// eslint-disable-next-line @typescript-eslint/naming-convention
errors: { 'subActionParams.incident.short_description': [] },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you write it like this, there is no typescript error:

errors: { ['subActionParams.incident.short_description']: [] },

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. 👍

@@ -90,7 +102,8 @@ describe('servicenow action params validation', () => {

expect(actionTypeModel.validateParams(actionParams)).toEqual({
errors: {
short_description: ['Short description is required.'],
// eslint-disable-next-line @typescript-eslint/naming-convention
'subActionParams.incident.short_description': ['Short description is required.'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, get it here too ;)

Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making those quick TS changes. Looks good from the SIEM perspective. Thank you! LGTM 🚀

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
stackAlerts 114.3KB 114.3KB +4.0B
triggersActionsUi 1.6MB 1.5MB -21.5KB
total -21.5KB

Distributable file count

id before after diff
default 47252 48015 +763

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 246.7KB 246.7KB +29.0B
triggersActionsUi 162.3KB 165.1KB +2.8KB
total +2.8KB
Unknown metric groups

async chunk count

id before after diff
triggersActionsUi 31 32 +1

History

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

@YulNaumenko YulNaumenko merged commit dddd8e4 into elastic:master Jan 5, 2021
YulNaumenko added a commit to YulNaumenko/kibana that referenced this pull request Jan 5, 2021
…should be active by default. (elastic#86708)

* Alert and Connector flyouts Save and Save&Test buttons should be active by default.

* fixed typechecks

* fixed typechecks

* refactored repeted code

* fixed typechecks

* fixed typechecks

* fixed typechecks

* fixed due to comments

* fixed failing tests

* fixed due to comments

* fixed due to comments

* fixed due to comments

* fixed typescript checks
YulNaumenko added a commit that referenced this pull request Jan 5, 2021
…should be active by default. (#86708) (#87380)

* Alert and Connector flyouts Save and Save&Test buttons should be active by default.

* fixed typechecks

* fixed typechecks

* refactored repeted code

* fixed typechecks

* fixed typechecks

* fixed typechecks

* fixed due to comments

* fixed failing tests

* fixed due to comments

* fixed due to comments

* fixed due to comments

* fixed typescript checks
@mikecote mikecote added release_note:enhancement and removed release_note:skip Skip the PR/issue when compiling release notes labels Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Actions Feature:Alerting release_note:enhancement Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create alert/connector submit button should be active by default
8 participants