Skip to content

Conversation

@ymao1
Copy link
Contributor

@ymao1 ymao1 commented Dec 17, 2020

Resolves #62824

Summary

In Alert Add/Edit flyouts, added check for changes when flyout is closed without saving and showing confirmation modal if user has made changes to the alert form.

Screen Shot 2020-12-17 at 3 02 21 PM

Checklist

Delete any items that are not applicable to this PR.

}, [alertTypeId]);

const closeFlyout = useCallback(() => {
setAlert(initialAlert);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We no longer need to reset the alert to an initial alert on close because with this PR we are removing the flyout on close completely instead of just hiding it.

...(!!(alertTypeId && alertTypeId.length > 0) ? { alertTypeId } : {}),
...(!!(throttle && throttle.length > 0) ? { throttle } : {}),
};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added tests for the scenarios I saw when manually testing this, namely:

  • the name field grabs focus when the add alert flyout opens so it starts out as undefined but is set to an empty string onBlur if the user doesn't enter anything
  • the alertTypeId field starts out undefined in the stack alerts flyout, but if you select an alert type and then X it out, it is set to null
  • the throttle field starts out undefined but if you set a throttle and then unset it, it is set to null

This tries to normalize these scenarios so that they can be compared.

@ymao1 ymao1 self-assigned this Dec 17, 2020
tags,
...(alertName ? { name: alertName } : {}),
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting initial values for alert name and tags via the initialValues prop of the AddAlert component instead of using setAlertProperty in the ServiceAlertTrigger component. This allows us to correctly check whether the user changes the alert name/tags and show the confirm on discard modal accordingly. Otherwise the default alert name/tag will always register as a change to the alert

@ymao1 ymao1 added Feature:Alerting release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v7.12.0 v8.0.0 labels Dec 21, 2020
@ymao1 ymao1 marked this pull request as ready for review December 21, 2020 13:00
@ymao1 ymao1 requested review from a team as code owners December 21, 2020 13:00
@elasticmachine
Copy link
Contributor

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

@ymao1
Copy link
Contributor Author

ymao1 commented Dec 21, 2020

@elasticmachine merge upstream

@botelastic botelastic bot added the Team:APM - DEPRECATED Use Team:obs-ux-infra_services. label Dec 21, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@ymao1
Copy link
Contributor Author

ymao1 commented Jan 4, 2021

@elasticmachine merge upstream

@ymao1
Copy link
Contributor Author

ymao1 commented Jan 4, 2021

@elasticmachine merge upstream

@ymao1
Copy link
Contributor Author

ymao1 commented Jan 4, 2021

I found the problem, when you edited alert with adding more actions and then click Cancel -> Discard changes, the added actions wasn't removed (discarded)

@YulNaumenko Great catch! I pushed a fix for that issue.

Copy link
Contributor

@smith smith left a comment

Choose a reason for hiding this comment

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

APM changes look good and work for me.

Copy link
Contributor

@YulNaumenko YulNaumenko left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines 28 to 44
const alertTypeName = alertType
? ALERT_TYPES_CONFIG[alertType].name
: undefined;
const alertName = alertTypeName
? serviceName
? `${alertTypeName} | ${serviceName}`
: alertTypeName
: undefined;
const tags = ['apm'];
if (serviceName) {
tags.push(`service.name:${serviceName}`.toLowerCase());
}
const initialValues = {
tags,
...(alertName ? { name: alertName } : {}),
};

Copy link
Member

Choose a reason for hiding this comment

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

Minor nit: can you extract this to a function?

Suggested change
const alertTypeName = alertType
? ALERT_TYPES_CONFIG[alertType].name
: undefined;
const alertName = alertTypeName
? serviceName
? `${alertTypeName} | ${serviceName}`
: alertTypeName
: undefined;
const tags = ['apm'];
if (serviceName) {
tags.push(`service.name:${serviceName}`.toLowerCase());
}
const initialValues = {
tags,
...(alertName ? { name: alertName } : {}),
};
const initialValues = getInitialValues(alertType, serviceName)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sqren Done! You can see the change here

@ymao1
Copy link
Contributor Author

ymao1 commented Jan 5, 2021

@elasticmachine merge upstream

@mikecote mikecote self-requested a review January 7, 2021 12:20
Copy link
Contributor

@mikecote mikecote left a comment

Choose a reason for hiding this comment

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

Triggers and actions UI changes LGTM!

I'm curious if you connected with @gchaps to go over the copy?

@ymao1
Copy link
Contributor Author

ymao1 commented Jan 7, 2021

@gchaps Can you review the Discard modal wording in the screenshot? Right now, it reads Discard changes to alert? and Once you discard your changes, there's no getting them back.. I took them from a similar Discard modal in the Kibana UI. Do they make sense in this context?

@gchaps
Copy link
Contributor

gchaps commented Jan 7, 2021

I think we have to have the notion that these are "unsaved changes". Here is a suggestion:

Discard unsaved changes?

If you leave this form, your changes will be lost.

Cancel | Discard changes

Or if you want to keep the wording "alert"

Discard unsaved changes to alert?

If you leave this form, your changes will be lost.

Cancel | Discard changes

@ymao1
Copy link
Contributor Author

ymao1 commented Jan 7, 2021

I think we have to have the notion that these are "unsaved changes". Here is a suggestion:

Discard unsaved changes?
If you leave this form, your changes will be lost.
Cancel | Discard changes

Or if you want to keep the wording "alert"

Discard unsaved changes to alert?
If you leave this form, your changes will be lost.
Cancel | Discard changes

@gchaps I think the title Discard unsaved changes to alert? sounds good! Since this is a flyout, does the text If you leave this form still make sense?

@gchaps
Copy link
Contributor

gchaps commented Jan 11, 2021

@ymao1 Good call. How about

Discard unsaved changes to alert?

You can't recover unsaved changes.

Cancel | Discard changes

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1734 1735 +1
triggersActionsUi 330 333 +3
total +4

Async chunks

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

id before after diff
apm 5.4MB 5.4MB -404.0B
triggersActionsUi 1.5MB 1.6MB +7.9KB
total +7.5KB

Page load bundle

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

id before after diff
triggersActionsUi 165.1KB 165.1KB +1.0B

History

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

@ymao1 ymao1 merged commit 666af32 into elastic:master Jan 11, 2021
ymao1 added a commit to ymao1/kibana that referenced this pull request Jan 11, 2021
…losed without saving and changes made. (elastic#86370)

* Adding hasChanged check and showing confirmation modal if something has changed

* Showing confirmation always on close

* Adding functional test

* Setting name and tags for APM alerts using initial values instead of setAlertProperty

* Checking for alert param changes separately

* Checking for alert param changes separately

* Fixing functional test

* Resetting initial alert params on alert type change

* Fixing duplicate import

* Cloning edited alert

* PR fixes

* PR fixes

* Updating modal wording

Co-authored-by: Kibana Machine <[email protected]>
ymao1 added a commit that referenced this pull request Jan 12, 2021
…losed without saving and changes made. (#86370) (#87927)

* Adding hasChanged check and showing confirmation modal if something has changed

* Showing confirmation always on close

* Adding functional test

* Setting name and tags for APM alerts using initial values instead of setAlertProperty

* Checking for alert param changes separately

* Checking for alert param changes separately

* Fixing functional test

* Resetting initial alert params on alert type change

* Fixing duplicate import

* Cloning edited alert

* PR fixes

* PR fixes

* Updating modal wording

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
@mikecote mikecote added release_note:enhancement and removed release_note:skip Skip the PR/issue when compiling release notes labels Feb 2, 2021
@ymao1 ymao1 deleted the alerting/confirm-before-close branch February 4, 2021 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Alerting release_note:enhancement Team:APM - DEPRECATED Use Team:obs-ux-infra_services. Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v7.12.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alert Flyout should show a confirmation dialog before closing

8 participants