-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Alerting] Showing confirmation modal on Alert Add/Edit when flyout closed without saving and changes made. #86370
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
Conversation
| }, [alertTypeId]); | ||
|
|
||
| const closeFlyout = useCallback(() => { | ||
| setAlert(initialAlert); |
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 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 } : {}), | ||
| }; | ||
| } |
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.
I added tests for the scenarios I saw when manually testing this, namely:
- the
namefield grabs focus when the add alert flyout opens so it starts out asundefinedbut is set to an empty stringonBlurif the user doesn't enter anything - the
alertTypeIdfield 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
throttlefield 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.
| tags, | ||
| ...(alertName ? { name: alertName } : {}), | ||
| }; | ||
|
|
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.
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
|
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
|
@elasticmachine merge upstream |
|
Pinging @elastic/apm-ui (Team:apm) |
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
@YulNaumenko Great catch! I pushed a fix for that issue. |
smith
left a comment
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.
APM changes look good and work for me.
YulNaumenko
left a comment
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!
| 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 } : {}), | ||
| }; | ||
|
|
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.
Minor nit: can you extract this to a function?
| 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) |
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.
…ing/confirm-before-close
|
@elasticmachine merge upstream |
mikecote
left a comment
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.
Triggers and actions UI changes LGTM!
I'm curious if you connected with @gchaps to go over the copy?
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_has_changed.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_has_changed.ts
Outdated
Show resolved
Hide resolved
…ing/confirm-before-close
|
@gchaps Can you review the Discard modal wording in the screenshot? Right now, it reads |
|
I think we have to have the notion that these are "unsaved changes". Here is a suggestion:
Or if you want to keep the wording "alert"
|
…ing/confirm-before-close
@gchaps I think the title |
|
@ymao1 Good call. How about
|
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
…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]>
…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]>
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.
Checklist
Delete any items that are not applicable to this PR.