Skip to content

Commit 0f5cfe9

Browse files
opensearch-trigger-bot[bot]github-actions[bot]Kama Huang
authored
hide search query section when version is less than 2.19 (#605) (#607)
(cherry picked from commit 4e46cf3) Signed-off-by: Kama Huang <kamahuan@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kama Huang <kamahuan@amazon.com>
1 parent 8998cf8 commit 0f5cfe9

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

public/pages/workflow_detail/workflow_inputs/search_inputs/search_inputs.tsx

+33-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import React, { useEffect } from 'react';
6+
import React, { useEffect, useState } from 'react';
7+
import semver from 'semver';
78
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule } from '@elastic/eui';
89
import { ConfigureSearchRequest } from './configure_search_request';
910
import { EnrichSearchRequest } from './enrich_search_request';
@@ -15,6 +16,7 @@ import {
1516
} from '../../../../../common';
1617
import { catIndices, useAppDispatch } from '../../../../store';
1718
import { getDataSourceId } from '../../../../utils';
19+
import { getEffectiveVersion } from '../../../workflows/new_workflow/new_workflow';
1820

1921
interface SearchInputsProps {
2022
uiConfig: WorkflowConfig;
@@ -28,13 +30,29 @@ interface SearchInputsProps {
2830
export function SearchInputs(props: SearchInputsProps) {
2931
const dispatch = useAppDispatch();
3032
const dataSourceId = getDataSourceId();
33+
const [showTransformQuery, setShowTransformQuery] = useState(true);
34+
3135
// re-fetch indices on initial load. When users are first creating,
3236
// they may enter this page without getting the updated index info
3337
// for a newly-created index, so we re-fetch that here.
3438
useEffect(() => {
3539
dispatch(catIndices({ pattern: OMIT_SYSTEM_INDEX_PATTERN, dataSourceId }));
3640
}, []);
3741

42+
useEffect(() => {
43+
const checkVersion = async () => {
44+
try {
45+
const version = await getEffectiveVersion(dataSourceId);
46+
setShowTransformQuery(semver.gte(version, '2.19.0'));
47+
} catch (error) {
48+
console.error('Error checking version:', error);
49+
setShowTransformQuery(true);
50+
}
51+
};
52+
53+
checkVersion();
54+
}, [dataSourceId]);
55+
3856
return (
3957
<EuiFlexGroup direction="column">
4058
<EuiFlexItem grow={false}>
@@ -43,16 +61,20 @@ export function SearchInputs(props: SearchInputsProps) {
4361
<EuiFlexItem grow={false}>
4462
<EuiHorizontalRule margin="m" />
4563
</EuiFlexItem>
46-
<EuiFlexItem grow={false}>
47-
<EnrichSearchRequest
48-
uiConfig={props.uiConfig}
49-
setUiConfig={props.setUiConfig}
50-
setCachedFormikState={props.setCachedFormikState}
51-
/>
52-
</EuiFlexItem>
53-
<EuiFlexItem grow={false}>
54-
<EuiHorizontalRule margin="m" />
55-
</EuiFlexItem>
64+
{showTransformQuery && (
65+
<>
66+
<EuiFlexItem grow={false}>
67+
<EnrichSearchRequest
68+
uiConfig={props.uiConfig}
69+
setUiConfig={props.setUiConfig}
70+
setCachedFormikState={props.setCachedFormikState}
71+
/>
72+
</EuiFlexItem>
73+
<EuiFlexItem grow={false}>
74+
<EuiHorizontalRule margin="m" />
75+
</EuiFlexItem>
76+
</>
77+
)}
5678
<EuiFlexItem grow={false}>
5779
<EnrichSearchResponse
5880
uiConfig={props.uiConfig}

0 commit comments

Comments
 (0)