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

[Actions] fixes bug where severity is auto selected but not applied to the action in PagerDuty #84891

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -19633,7 +19633,6 @@
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.selectMessageText": "PagerDuty でイベントを送信します。",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectCriticalOptionLabel": "重大",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectErrorOptionLabel": "エラー",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectFieldLabel": "深刻度",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectInfoOptionLabel": "情報",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectWarningOptionLabel": "警告",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.sourceTextFieldLabel": "ソース (任意)",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -19652,7 +19652,6 @@
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.selectMessageText": "在 PagerDuty 中发送事件。",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectCriticalOptionLabel": "紧急",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectErrorOptionLabel": "错误",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectFieldLabel": "严重性",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectInfoOptionLabel": "信息",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectWarningOptionLabel": "警告",
"xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.sourceTextFieldLabel": "源(可选)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,25 @@ describe('PagerDutyParamsFields renders', () => {
expect(wrapper.find('[data-test-subj="summaryInput"]').length > 0).toBeTruthy();
expect(wrapper.find('[data-test-subj="dedupKeyAddVariableButton"]').length > 0).toBeTruthy();
});

test('params select fields dont auto set values ', () => {
const actionParams = {};

const wrapper = mountWithIntl(
<PagerDutyParamsFields
actionParams={actionParams}
errors={{ summary: [], timestamp: [], dedupKey: [] }}
editAction={() => {}}
index={0}
/>
);
expect(wrapper.find('[data-test-subj="severitySelect"]').length > 0).toBeTruthy();
expect(wrapper.find('[data-test-subj="severitySelect"]').first().prop('value')).toStrictEqual(
undefined
);
expect(wrapper.find('[data-test-subj="eventActionSelect"]').length > 0).toBeTruthy();
expect(
wrapper.find('[data-test-subj="eventActionSelect"]').first().prop('value')
).toStrictEqual(undefined);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import React, { Fragment } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiFormRow, EuiSelect, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { isUndefined } from 'lodash';
import { ActionParamsProps } from '../../../../types';
import { PagerDutyActionParams } from '.././types';
import { TextFieldWithMessageVariables } from '../../text_field_with_message_variables';
Expand Down Expand Up @@ -106,14 +107,15 @@ const PagerDutyParamsFields: React.FunctionComponent<ActionParamsProps<PagerDuty
label={i18n.translate(
'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.severitySelectFieldLabel',
{
defaultMessage: 'Severity',
defaultMessage: 'Severity (optional)',
}
)}
>
<EuiSelect
fullWidth
data-test-subj="severitySelect"
options={severityOptions}
hasNoInitialSelection={isUndefined(severity)}
value={severity}
onChange={(e) => {
editAction('severity', e.target.value, index);
Expand All @@ -135,6 +137,7 @@ const PagerDutyParamsFields: React.FunctionComponent<ActionParamsProps<PagerDuty
fullWidth
data-test-subj="eventActionSelect"
options={eventActionOptions}
hasNoInitialSelection={isUndefined(eventAction)}
value={eventAction}
onChange={(e) => {
editAction('eventAction', e.target.value, index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { AlertActionParam, RecoveredActionGroup } from '../../../../alerts/common';
import { EventActionOptions } from '../components/builtin_action_types/types';
import { AlertProvidedActionVariables } from './action_variables';

export const getDefaultsForActionParams = (
Expand All @@ -15,10 +16,10 @@ export const getDefaultsForActionParams = (
case '.pagerduty':
const pagerDutyDefaults = {
dedupKey: `{{${AlertProvidedActionVariables.alertId}}}:{{${AlertProvidedActionVariables.alertInstanceId}}}`,
eventAction: 'trigger',
eventAction: EventActionOptions.TRIGGER,
};
if (actionGroupId === RecoveredActionGroup.id) {
pagerDutyDefaults.eventAction = 'resolve';
pagerDutyDefaults.eventAction = EventActionOptions.RESOLVE;
}
return pagerDutyDefaults;
}
Expand Down