From 958f51709386b02522de0acefcb703a2c5127c42 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 1 Apr 2020 15:46:12 +0200 Subject: [PATCH] [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. --- .../transform/public/app/common/request.ts | 2 +- .../step_define/step_define_form.tsx | 1 + .../step_define/step_define_summary.tsx | 41 +++++++++++-------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/transform/public/app/common/request.ts b/x-pack/plugins/transform/public/app/common/request.ts index 79fb3acb9fcaf1..7e965dbe802c06 100644 --- a/x-pack/plugins/transform/public/app/common/request.ts +++ b/x-pack/plugins/transform/public/app/common/request.ts @@ -81,7 +81,7 @@ export function getPreviewRequestBody( }, }; - if (!isDefaultQuery(query)) { + if (!isDefaultQuery(query) && !isMatchAllQuery(query)) { request.source.query = query; } diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx index df22c3f3eb2e2e..5e0eb7ee083618 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx @@ -705,6 +705,7 @@ export const StepDefineForm: FC = React.memo(({ overrides = {}, onChange, width="100%" value={advancedEditorSourceConfig} onChange={(d: string) => { + setSearchString(undefined); setAdvancedEditorSourceConfig(d); // Disable the "Apply"-Button if the config hasn't changed. diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.tsx index 54cc1e8c071faf..f31514e67003b2 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.tsx @@ -17,7 +17,7 @@ import { EuiText, } from '@elastic/eui'; -import { getPivotQuery } from '../../../../common'; +import { getPivotQuery, isDefaultQuery, isMatchAllQuery } from '../../../../common'; import { PivotPreview } from '../../../../components/pivot_preview'; import { SearchItems } from '../../../../hooks/use_search_items'; @@ -60,24 +60,29 @@ export const StepDefineSummary: FC = ({ {searchString} )} - {typeof searchString === 'undefined' && ( - - - {JSON.stringify(searchQuery, null, 2)} - - - )} + + {JSON.stringify(pivotQuery, null, 2)} + + + )} )}