From fcdaf0bbd6b7ed4adb330f9915f949c566ca2647 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 17 Jan 2025 03:55:38 +1100 Subject: [PATCH] =?UTF-8?q?[8.x]=20=F0=9F=8C=8A=20Streams:=20Fix=20routing?= =?UTF-8?q?=20UI=20for=20no-condition=20routing=20(#206752)=20(#206965)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.x`: - [🌊 Streams: Fix routing UI for no-condition routing (#206752)](https://github.com/elastic/kibana/pull/206752) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Joe Reuter --- .../components/condition_editor/index.tsx | 48 ++++++++++----- .../stream_detail_routing/index.tsx | 58 +++++++------------ 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/x-pack/solutions/observability/plugins/streams_app/public/components/condition_editor/index.tsx b/x-pack/solutions/observability/plugins/streams_app/public/components/condition_editor/index.tsx index 0b08ca68dc6f7..0b81072d661ab 100644 --- a/x-pack/solutions/observability/plugins/streams_app/public/components/condition_editor/index.tsx +++ b/x-pack/solutions/observability/plugins/streams_app/public/components/condition_editor/index.tsx @@ -7,6 +7,7 @@ import { EuiBadge, + EuiButton, EuiFieldText, EuiFlexGroup, EuiFlexItem, @@ -14,6 +15,7 @@ import { EuiSelect, EuiSwitch, EuiText, + EuiToolTip, } from '@elastic/eui'; import { AndCondition, @@ -32,9 +34,6 @@ export function ConditionEditor(props: { readonly?: boolean; onConditionChange?: (condition: Condition) => void; }) { - if (!props.condition) { - return null; - } if (props.readonly) { return ( @@ -67,7 +66,7 @@ export function ConditionForm(props: { }, [syntaxEditor, props.condition]); return ( - + + + props.onConditionChange(undefined)} + disabled={props.condition === undefined} + > + {i18n.translate('xpack.streams.conditionEditor.disable', { + defaultMessage: 'Disable routing', + })} + + + + ) : !props.condition || 'operator' in props.condition ? ( + ) : ( - props.condition && - ('operator' in props.condition ? ( - - ) : ( -
{JSON.stringify(props.condition, null, 2)}
- )) +
{JSON.stringify(props.condition, null, 2)}
)}
); @@ -213,7 +227,13 @@ function FilterForm(props: { export function ConditionDisplay(props: { condition: Condition }) { if (!props.condition) { - return null; + return ( + <> + {i18n.translate('xpack.streams.streamDetailRouting.noCondition', { + defaultMessage: 'No condition, no documents will be routed', + })} + + ); } return ( <> diff --git a/x-pack/solutions/observability/plugins/streams_app/public/components/stream_detail_routing/index.tsx b/x-pack/solutions/observability/plugins/streams_app/public/components/stream_detail_routing/index.tsx index 5c9d5f0931585..2c848575eb570 100644 --- a/x-pack/solutions/observability/plugins/streams_app/public/components/stream_detail_routing/index.tsx +++ b/x-pack/solutions/observability/plugins/streams_app/public/components/stream_detail_routing/index.tsx @@ -906,25 +906,16 @@ function RoutingStreamEntry({ })} />
- {child.condition && ( - { - onChildChange({ - ...child, - condition, - }); - }} - /> - )} - {!child.condition && ( - - {i18n.translate('xpack.streams.streamDetailRouting.noCondition', { - defaultMessage: 'No condition, no documents will be routed', - })} - - )} + { + onChildChange({ + ...child, + condition, + }); + }} + />
); } @@ -958,25 +949,16 @@ function NewRoutingStreamEntry({ }} /> - {child.condition && ( - { - onChildChange({ - ...child, - condition, - }); - }} - /> - )} - {!child.condition && ( - - {i18n.translate('xpack.streams.streamDetailRouting.noCondition', { - defaultMessage: 'No condition, no documents will be routed', - })} - - )} + { + onChildChange({ + ...child, + condition, + }); + }} + /> );