From ed14ba0e29ae17f176d8fc87db4ccf4a1edf73a5 Mon Sep 17 00:00:00 2001 From: Sander Philipse <94373878+sphilipse@users.noreply.github.com> Date: Thu, 17 Nov 2022 12:46:00 +0100 Subject: [PATCH] [Enterprise Search] Only show specifically enabled filtering features (#145383) This hides a specific filtering feature from the user if it's not enabled for the connector they're using. --- .../filtering/connector_filtering.tsx | 69 ++++++++++--------- .../filtering/edit_filtering_flyout.tsx | 68 ++++++++++-------- 2 files changed, 77 insertions(+), 60 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/filtering/connector_filtering.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/filtering/connector_filtering.tsx index 875a4e9a9c6a2..fac8afe06ccc3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/filtering/connector_filtering.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/filtering/connector_filtering.tsx @@ -31,7 +31,8 @@ import { EditFilteringFlyout } from './edit_filtering_flyout'; import { FilteringStateCallouts } from './filtering_callouts'; export const ConnectorFiltering: React.FC = () => { - const { indexName } = useValues(IndexViewLogic); + const { indexName, hasAdvancedFilteringFeature, hasBasicFilteringFeature } = + useValues(IndexViewLogic); const { applyDraft, setLocalFilteringRules, setLocalAdvancedSnippet, setIsEditing } = useActions(ConnectorFilteringLogic); const { advancedSnippet, draftState, filteringRules, hasDraft, isEditing } = @@ -41,6 +42,8 @@ export const ConnectorFiltering: React.FC = () => { <> {isEditing && ( setLocalFilteringRules(filteringRules)} revertLocalAdvancedFiltering={() => setLocalAdvancedSnippet(advancedSnippet)} setIsEditing={setIsEditing} @@ -115,37 +118,39 @@ export const ConnectorFiltering: React.FC = () => { - - - - - -

- {i18n.translate( - 'xpack.enterpriseSearch.content.index.connector.filtering.basicFiltersTitle', - { - defaultMessage: 'Basic filters', - } - )} -

-
- - -

- {i18n.translate( - 'xpack.enterpriseSearch.content.index.connector.filtering.basicFiltersDescription', - { - defaultMessage: 'These filters apply to documents in post-processing.', - } - )} -

-
-
- -
-
-
- {!!advancedSnippet && ( + {hasBasicFilteringFeature && ( + + + + + +

+ {i18n.translate( + 'xpack.enterpriseSearch.content.index.connector.filtering.basicFiltersTitle', + { + defaultMessage: 'Basic filters', + } + )} +

+
+ + +

+ {i18n.translate( + 'xpack.enterpriseSearch.content.index.connector.filtering.basicFiltersDescription', + { + defaultMessage: 'These filters apply to documents in post-processing.', + } + )} +

+
+
+ +
+
+
+ )} + {hasAdvancedFilteringFeature && !!advancedSnippet && ( diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/filtering/edit_filtering_flyout.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/filtering/edit_filtering_flyout.tsx index 7d4fe096fd998..fecaabc6b1566 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/filtering/edit_filtering_flyout.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/filtering/edit_filtering_flyout.tsx @@ -23,6 +23,8 @@ import { EditFilteringTab } from './edit_filtering_tab'; import { FilteringRulesTable } from './editable_filtering_rules_table'; interface EditFilteringFlyoutProps { + hasAdvancedFilteringFeature: boolean; + hasBasicFilteringFeature: boolean; revertLocalAdvancedFiltering: () => void; revertLocalFilteringRules: () => void; setIsEditing: (value: boolean) => void; @@ -34,39 +36,49 @@ enum FilteringTabs { } export const EditFilteringFlyout: React.FC = ({ + hasAdvancedFilteringFeature, + hasBasicFilteringFeature, revertLocalFilteringRules, revertLocalAdvancedFiltering, setIsEditing, }) => { const tabs: EuiTabbedContentTab[] = [ - { - content: ( - - - - ), - id: FilteringTabs.BASIC, - name: i18n.translate( - 'xpack.enterpriseSearch.content.index.connector.filtering.basicTabTitle', - { - defaultMessage: 'Basic filters', - } - ), - }, - { - content: ( - - - - ), - id: FilteringTabs.ADVANCED, - name: i18n.translate( - 'xpack.enterpriseSearch.content.index.connector.filtering.advancedTabTitle', - { - defaultMessage: 'Advanced filters', - } - ), - }, + ...(hasBasicFilteringFeature + ? [ + { + content: ( + + + + ), + id: FilteringTabs.BASIC, + name: i18n.translate( + 'xpack.enterpriseSearch.content.index.connector.filtering.basicTabTitle', + { + defaultMessage: 'Basic filters', + } + ), + }, + ] + : []), + ...(hasAdvancedFilteringFeature + ? [ + { + content: ( + + + + ), + id: FilteringTabs.ADVANCED, + name: i18n.translate( + 'xpack.enterpriseSearch.content.index.connector.filtering.advancedTabTitle', + { + defaultMessage: 'Advanced filters', + } + ), + }, + ] + : []), ]; return (