From c42867525ef7825deb040ab9cbe8dcb306ecb738 Mon Sep 17 00:00:00 2001 From: Yuliia Naumenko Date: Wed, 15 Jul 2020 11:44:31 -0700 Subject: [PATCH 1/2] Fixed Webhook connector doesn't retain added HTTP header settings --- .../webhook/webhook_connectors.test.tsx | 1 + .../webhook/webhook_connectors.tsx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.test.tsx index 3b7865e59b9e6..3a2afff03c58f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.test.tsx @@ -36,6 +36,7 @@ describe('WebhookActionConnectorFields renders', () => { /> ); expect(wrapper.find('[data-test-subj="webhookViewHeadersSwitch"]').length > 0).toBeTruthy(); + expect(wrapper.find('[data-test-subj="webhookHeaderText"]').length > 0).toBeTruthy(); wrapper.find('[data-test-subj="webhookViewHeadersSwitch"]').first().simulate('click'); expect(wrapper.find('[data-test-subj="webhookMethodSelect"]').length > 0).toBeTruthy(); expect(wrapper.find('[data-test-subj="webhookUrlText"]').length > 0).toBeTruthy(); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.tsx index 57c88607c0884..f6872cbaa3b5f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.tsx @@ -31,13 +31,13 @@ const HTTP_VERBS = ['post', 'put']; const WebhookActionConnectorFields: React.FunctionComponent> = ({ action, editActionConfig, editActionSecrets, errors }) => { + const { user, password } = action.secrets; + const { method, url, headers } = action.config; + const [httpHeaderKey, setHttpHeaderKey] = useState(''); const [httpHeaderValue, setHttpHeaderValue] = useState(''); const [hasHeaders, setHasHeaders] = useState(false); - const { user, password } = action.secrets; - const { method, url, headers } = action.config; - editActionConfig('method', 'post'); // set method to POST by default const headerErrors = { @@ -80,7 +80,7 @@ const WebhookActionConnectorFields: React.FunctionComponent
- {hasHeaders && Object.keys(headers || {}).length > 0 ? ( - + {Object.keys(headers || {}).length > 0 ? ( + <>
@@ -351,10 +351,10 @@ const WebhookActionConnectorFields: React.FunctionComponent {headersList} - + ) : null} - {headerControl} + {hasHeaders && headerControl}
From bfc9076a63c12f04c130f6cb17552ca227c789cf Mon Sep 17 00:00:00 2001 From: Yuliia Naumenko Date: Wed, 15 Jul 2020 18:22:33 -0700 Subject: [PATCH 2/2] fixed method --- .../builtin_action_types/webhook/webhook_connectors.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.tsx index f6872cbaa3b5f..2321d5b4b5479 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.tsx @@ -38,7 +38,9 @@ const WebhookActionConnectorFields: React.FunctionComponent(''); const [hasHeaders, setHasHeaders] = useState(false); - editActionConfig('method', 'post'); // set method to POST by default + if (!method) { + editActionConfig('method', 'post'); // set method to POST by default + } const headerErrors = { keyHeader: new Array(),