[8.9] [Ingest Pipelines] Fix bug in reroute processor (#162872) (#162991)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Ingest Pipelines] Fix bug in reroute processor
(#162872)](https://github.com/elastic/kibana/pull/162872)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"59341489+ElenaStoeva@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-08-02T15:53:55Z","message":"[Ingest
Pipelines] Fix bug in reroute processor (#162872)\n\nFixes
https://github.com/elastic/kibana/issues/162823\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug in the Reroute processor form which
makes the page\r\ncrash when switching from another processor type to
reroute processor.\r\n\r\n**How to test:**\r\n\r\n1. Start Es with `yarn
es snapshot` and Kibana with `yarn start`.\r\n2. Go to Stack Management
> Ingest Pipeline.\r\n3. Click **Create pipeline**, and then select
**New pipeline**.\r\n4. Click **Add a processor**.\r\n5. In the
**Configure processor** form, open the Processor dropdown, and\r\nselect
Reroute.\r\n6. From the Processor dropdown, select Bytes (or any other
processor\r\ntype).\r\n7. From the Processor dropdown, select
Reroute.\r\n8. Verify that the form works as
expected.\r\n\r\nCo-authored-by: Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"190a98f48734668d0c2a970348ca9852da086769","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Deployment
Management","release_note:skip","Feature:Ingest Node
Pipelines","backport:prev-minor","v8.10.0","v8.9.1"],"number":162872,"url":"https://github.com/elastic/kibana/pull/162872","mergeCommit":{"message":"[Ingest
Pipelines] Fix bug in reroute processor (#162872)\n\nFixes
https://github.com/elastic/kibana/issues/162823\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug in the Reroute processor form which
makes the page\r\ncrash when switching from another processor type to
reroute processor.\r\n\r\n**How to test:**\r\n\r\n1. Start Es with `yarn
es snapshot` and Kibana with `yarn start`.\r\n2. Go to Stack Management
> Ingest Pipeline.\r\n3. Click **Create pipeline**, and then select
**New pipeline**.\r\n4. Click **Add a processor**.\r\n5. In the
**Configure processor** form, open the Processor dropdown, and\r\nselect
Reroute.\r\n6. From the Processor dropdown, select Bytes (or any other
processor\r\ntype).\r\n7. From the Processor dropdown, select
Reroute.\r\n8. Verify that the form works as
expected.\r\n\r\nCo-authored-by: Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"190a98f48734668d0c2a970348ca9852da086769"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/162872","number":162872,"mergeCommit":{"message":"[Ingest
Pipelines] Fix bug in reroute processor (#162872)\n\nFixes
https://github.com/elastic/kibana/issues/162823\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug in the Reroute processor form which
makes the page\r\ncrash when switching from another processor type to
reroute processor.\r\n\r\n**How to test:**\r\n\r\n1. Start Es with `yarn
es snapshot` and Kibana with `yarn start`.\r\n2. Go to Stack Management
> Ingest Pipeline.\r\n3. Click **Create pipeline**, and then select
**New pipeline**.\r\n4. Click **Add a processor**.\r\n5. In the
**Configure processor** form, open the Processor dropdown, and\r\nselect
Reroute.\r\n6. From the Processor dropdown, select Bytes (or any other
processor\r\ntype).\r\n7. From the Processor dropdown, select
Reroute.\r\n8. Verify that the form works as
expected.\r\n\r\nCo-authored-by: Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"190a98f48734668d0c2a970348ca9852da086769"}},{"branch":"8.9","label":"v8.9.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-08-02 13:02:55 -04:00 committed by GitHub
parent 59aff4a6f2
commit e38b2c7f24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,7 +114,10 @@ export const Reroute: FunctionComponent = () => {
const [{ fields }] = useFormData({ watch: ['fields.dataset', 'fields.namespace'] });
useEffect(() => {
if (fields?.dataset.length > 0 || fields?.namespace.length > 0) {
if (
(fields?.dataset && fields.dataset.length > 0) ||
(fields?.namespace && fields.namespace.length > 0)
) {
form.setFieldValue('fields.destination', '');
}
}, [form, fields]);
@ -127,7 +130,9 @@ export const Reroute: FunctionComponent = () => {
component={Field}
componentProps={{
euiFieldProps: {
disabled: fields?.dataset.length > 0 || fields?.namespace.length > 0,
disabled:
(fields?.dataset && fields.dataset.length > 0) ||
(fields?.namespace && fields.namespace.length > 0),
},
}}
path="fields.destination"