From 18e5de0eeccc45693c45746b5713dc02b0ab4585 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Thu, 3 Dec 2020 11:54:50 +0000 Subject: [PATCH 1/4] fixed but where severity was auto selected but not applied to the action in PagerDuty --- .../builtin_action_types/pagerduty/pagerduty_params.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx index 32f16760dd461..717327d926cf5 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx @@ -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'; @@ -114,6 +115,7 @@ const PagerDutyParamsFields: React.FunctionComponent { editAction('severity', e.target.value, index); @@ -135,6 +137,7 @@ const PagerDutyParamsFields: React.FunctionComponent { editAction('eventAction', e.target.value, index); From 06aefee1ebffbaca3b284116b7fec504ebad8227 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Thu, 3 Dec 2020 12:06:16 +0000 Subject: [PATCH 2/4] use constants for defaults --- .../public/application/lib/get_defaults_for_action_params.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/get_defaults_for_action_params.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/get_defaults_for_action_params.ts index 36c054977ac30..d8431c4133be0 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/get_defaults_for_action_params.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/get_defaults_for_action_params.ts @@ -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 = ( @@ -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; } From bc7dc49416d0ea0c7800f0da7b6f0c8346f9c292 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Thu, 3 Dec 2020 12:20:26 +0000 Subject: [PATCH 3/4] added missing test --- .../pagerduty/pagerduty_params.test.tsx | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx index 1aa64ef53f688..325580c2ab602 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx @@ -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( + {}} + 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); + }); }); From 8bb2950b9198ae44a38102f735539195395288cd Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Thu, 3 Dec 2020 15:22:12 +0000 Subject: [PATCH 4/4] made severity an optional field --- x-pack/plugins/translations/translations/ja-JP.json | 1 - x-pack/plugins/translations/translations/zh-CN.json | 1 - .../builtin_action_types/pagerduty/pagerduty_params.tsx | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 7b84c62264c83..be5ddaa7f3adc 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -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": "ソース (任意)", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 55071303a1b36..42b6ed588fc74 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -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": "源(可选)", diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx index 717327d926cf5..f136689a7c52c 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx @@ -107,7 +107,7 @@ const PagerDutyParamsFields: React.FunctionComponent