Skip to content

Commit

Permalink
[ML] Transforms: Fix handling of default and advanced search on step …
Browse files Browse the repository at this point in the history
…summary view. (#61799) (#62162)

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.
  • Loading branch information
walterra authored Apr 1, 2020
1 parent ec61c6c commit f79c3a6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/transform/public/app/common/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function getPreviewRequestBody(
},
};

if (!isDefaultQuery(query)) {
if (!isDefaultQuery(query) && !isMatchAllQuery(query)) {
request.source.query = query;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ export const StepDefineForm: FC<Props> = 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -60,24 +60,29 @@ export const StepDefineSummary: FC<Props> = ({
<span>{searchString}</span>
</EuiFormRow>
)}
{typeof searchString === 'undefined' && (
<EuiFormRow
label={i18n.translate('xpack.transform.stepDefineSummary.queryCodeBlockLabel', {
defaultMessage: 'Query',
})}
>
<EuiCodeBlock
language="js"
fontSize="s"
paddingSize="s"
color="light"
overflowHeight={300}
isCopyable
{typeof searchString === 'undefined' &&
!isDefaultQuery(pivotQuery) &&
!isMatchAllQuery(pivotQuery) && (
<EuiFormRow
label={i18n.translate(
'xpack.transform.stepDefineSummary.queryCodeBlockLabel',
{
defaultMessage: 'Query',
}
)}
>
{JSON.stringify(searchQuery, null, 2)}
</EuiCodeBlock>
</EuiFormRow>
)}
<EuiCodeBlock
language="js"
fontSize="s"
paddingSize="s"
color="light"
overflowHeight={300}
isCopyable
>
{JSON.stringify(pivotQuery, null, 2)}
</EuiCodeBlock>
</EuiFormRow>
)}
</Fragment>
)}

Expand Down

0 comments on commit f79c3a6

Please sign in to comment.