-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Alerting] Showing confirmation modal on Alert Add/Edit when flyout c…
…losed without saving and changes made. (#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]>
- Loading branch information
1 parent
3ef7bd3
commit 666af32
Showing
17 changed files
with
408 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
x-pack/plugins/apm/public/components/alerting/get_initial_alert_values.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { getInitialAlertValues } from './get_initial_alert_values'; | ||
import { AlertType, ALERT_TYPES_CONFIG } from '../../../common/alert_types'; | ||
|
||
test('handles null alert type and undefined service name', () => { | ||
expect(getInitialAlertValues(null, undefined)).toEqual({ tags: ['apm'] }); | ||
}); | ||
|
||
test('handles valid alert type', () => { | ||
const alertType = AlertType.ErrorCount; | ||
expect(getInitialAlertValues(alertType, undefined)).toEqual({ | ||
name: ALERT_TYPES_CONFIG[alertType].name, | ||
tags: ['apm'], | ||
}); | ||
|
||
expect(getInitialAlertValues(alertType, 'Service Name')).toEqual({ | ||
name: `${ALERT_TYPES_CONFIG[alertType].name} | Service Name`, | ||
tags: ['apm', `service.name:service name`], | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/apm/public/components/alerting/get_initial_alert_values.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { AlertType, ALERT_TYPES_CONFIG } from '../../../common/alert_types'; | ||
|
||
export function getInitialAlertValues( | ||
alertType: AlertType | null, | ||
serviceName: string | undefined | ||
) { | ||
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()); | ||
} | ||
|
||
return { | ||
tags, | ||
...(alertName ? { name: alertName } : {}), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.