From 796825f0e3c5f8223b4653a3e463c000c5a3cf3b Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Mon, 30 Mar 2020 15:00:40 +0200 Subject: [PATCH 1/2] [ML] Fix handling of default and advanced search on step summary view. --- .../components/step_define/step_define_form.tsx | 1 + .../components/step_define/step_define_summary.tsx | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) 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 df22c3f3eb2e2..5e0eb7ee08361 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 54cc1e8c071fa..a1e00fcd3b8ed 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 } from '../../../../common'; import { PivotPreview } from '../../../../components/pivot_preview'; import { SearchItems } from '../../../../hooks/use_search_items'; @@ -60,7 +60,7 @@ export const StepDefineSummary: FC = ({ {searchString} )} - {typeof searchString === 'undefined' && ( + {typeof searchString === 'undefined' && !isDefaultQuery(pivotQuery) && ( = ({ overflowHeight={300} isCopyable > - {JSON.stringify(searchQuery, null, 2)} + {JSON.stringify(pivotQuery, null, 2)} )} From 3664138217b15e37bf95237fa712c7bddb2ba36c Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 1 Apr 2020 10:12:26 +0200 Subject: [PATCH 2/2] [ML] Adds a check if query is a match_all query. --- .../transform/public/app/common/request.ts | 2 +- .../step_define/step_define_summary.tsx | 41 +++++++++++-------- 2 files changed, 24 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 79fb3acb9fcaf..7e965dbe802c0 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_summary.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_summary.tsx index a1e00fcd3b8ed..f31514e67003b 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, isDefaultQuery } 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' && !isDefaultQuery(pivotQuery) && ( - - - {JSON.stringify(pivotQuery, null, 2)} - - - )} + + {JSON.stringify(pivotQuery, null, 2)} + + + )} )}