Skip to content

Commit a058636

Browse files
authored
[ML] Transforms: Fix handling of default and advanced search on step summary view. (#61799)
Fixes handling of default and advanced search on the summary view of the define step. - Before this, default searches would should up in the Query section, they are now hidden. - Before this, instead of the full query DSL, only the query string would be shown when the advanced query editor was used.
1 parent 01880ac commit a058636

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

x-pack/plugins/transform/public/app/common/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function getPreviewRequestBody(
8181
},
8282
};
8383

84-
if (!isDefaultQuery(query)) {
84+
if (!isDefaultQuery(query) && !isMatchAllQuery(query)) {
8585
request.source.query = query;
8686
}
8787

x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ export const StepDefineForm: FC<Props> = React.memo(({ overrides = {}, onChange,
705705
width="100%"
706706
value={advancedEditorSourceConfig}
707707
onChange={(d: string) => {
708+
setSearchString(undefined);
708709
setAdvancedEditorSourceConfig(d);
709710

710711
// Disable the "Apply"-Button if the config hasn't changed.

x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.tsx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
EuiText,
1818
} from '@elastic/eui';
1919

20-
import { getPivotQuery } from '../../../../common';
20+
import { getPivotQuery, isDefaultQuery, isMatchAllQuery } from '../../../../common';
2121
import { PivotPreview } from '../../../../components/pivot_preview';
2222
import { SearchItems } from '../../../../hooks/use_search_items';
2323

@@ -60,24 +60,29 @@ export const StepDefineSummary: FC<Props> = ({
6060
<span>{searchString}</span>
6161
</EuiFormRow>
6262
)}
63-
{typeof searchString === 'undefined' && (
64-
<EuiFormRow
65-
label={i18n.translate('xpack.transform.stepDefineSummary.queryCodeBlockLabel', {
66-
defaultMessage: 'Query',
67-
})}
68-
>
69-
<EuiCodeBlock
70-
language="js"
71-
fontSize="s"
72-
paddingSize="s"
73-
color="light"
74-
overflowHeight={300}
75-
isCopyable
63+
{typeof searchString === 'undefined' &&
64+
!isDefaultQuery(pivotQuery) &&
65+
!isMatchAllQuery(pivotQuery) && (
66+
<EuiFormRow
67+
label={i18n.translate(
68+
'xpack.transform.stepDefineSummary.queryCodeBlockLabel',
69+
{
70+
defaultMessage: 'Query',
71+
}
72+
)}
7673
>
77-
{JSON.stringify(searchQuery, null, 2)}
78-
</EuiCodeBlock>
79-
</EuiFormRow>
80-
)}
74+
<EuiCodeBlock
75+
language="js"
76+
fontSize="s"
77+
paddingSize="s"
78+
color="light"
79+
overflowHeight={300}
80+
isCopyable
81+
>
82+
{JSON.stringify(pivotQuery, null, 2)}
83+
</EuiCodeBlock>
84+
</EuiFormRow>
85+
)}
8186
</Fragment>
8287
)}
8388

0 commit comments

Comments
 (0)