Skip to content

Commit

Permalink
[Enterprise Search] Only show specifically enabled filtering features
Browse files Browse the repository at this point in the history
  • Loading branch information
sphilipse committed Nov 16, 2022
1 parent 8a6e91b commit 73d71b6
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 } =
Expand All @@ -41,6 +42,8 @@ export const ConnectorFiltering: React.FC = () => {
<>
{isEditing && (
<EditFilteringFlyout
hasAdvancedFilteringFeature={hasAdvancedFilteringFeature}
hasBasicFilteringFeature={hasBasicFilteringFeature}
revertLocalFilteringRules={() => setLocalFilteringRules(filteringRules)}
revertLocalAdvancedFiltering={() => setLocalAdvancedSnippet(advancedSnippet)}
setIsEditing={setIsEditing}
Expand Down Expand Up @@ -115,37 +118,39 @@ export const ConnectorFiltering: React.FC = () => {
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem>
<EuiPanel color="plain" hasShadow={false} hasBorder>
<EuiFlexGroup direction="column">
<EuiFlexItem>
<EuiTitle size="s">
<h3>
{i18n.translate(
'xpack.enterpriseSearch.content.index.connector.filtering.basicFiltersTitle',
{
defaultMessage: 'Basic filters',
}
)}
</h3>
</EuiTitle>
<EuiSpacer />
<EuiText size="s">
<p>
{i18n.translate(
'xpack.enterpriseSearch.content.index.connector.filtering.basicFiltersDescription',
{
defaultMessage: 'These filters apply to documents in post-processing.',
}
)}
</p>
</EuiText>
</EuiFlexItem>
<FilteringRulesTable filteringRules={filteringRules} showOrder />
</EuiFlexGroup>
</EuiPanel>
</EuiFlexItem>
{!!advancedSnippet && (
{hasBasicFilteringFeature && (
<EuiFlexItem>
<EuiPanel color="plain" hasShadow={false} hasBorder>
<EuiFlexGroup direction="column">
<EuiFlexItem>
<EuiTitle size="s">
<h3>
{i18n.translate(
'xpack.enterpriseSearch.content.index.connector.filtering.basicFiltersTitle',
{
defaultMessage: 'Basic filters',
}
)}
</h3>
</EuiTitle>
<EuiSpacer />
<EuiText size="s">
<p>
{i18n.translate(
'xpack.enterpriseSearch.content.index.connector.filtering.basicFiltersDescription',
{
defaultMessage: 'These filters apply to documents in post-processing.',
}
)}
</p>
</EuiText>
</EuiFlexItem>
<FilteringRulesTable filteringRules={filteringRules} showOrder />
</EuiFlexGroup>
</EuiPanel>
</EuiFlexItem>
)}
{hasAdvancedFilteringFeature && !!advancedSnippet && (
<EuiFlexItem>
<EuiPanel color="plain" hasShadow={false} hasBorder>
<EuiFlexGroup direction="column">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,39 +36,49 @@ enum FilteringTabs {
}

export const EditFilteringFlyout: React.FC<EditFilteringFlyoutProps> = ({
hasAdvancedFilteringFeature,
hasBasicFilteringFeature,
revertLocalFilteringRules,
revertLocalAdvancedFiltering,
setIsEditing,
}) => {
const tabs: EuiTabbedContentTab[] = [
{
content: (
<EditFilteringTab revertAction={revertLocalFilteringRules}>
<FilteringRulesTable />
</EditFilteringTab>
),
id: FilteringTabs.BASIC,
name: i18n.translate(
'xpack.enterpriseSearch.content.index.connector.filtering.basicTabTitle',
{
defaultMessage: 'Basic filters',
}
),
},
{
content: (
<EditFilteringTab revertAction={revertLocalAdvancedFiltering}>
<AdvancedFilteringRules />
</EditFilteringTab>
),
id: FilteringTabs.ADVANCED,
name: i18n.translate(
'xpack.enterpriseSearch.content.index.connector.filtering.advancedTabTitle',
{
defaultMessage: 'Advanced filters',
}
),
},
...(hasBasicFilteringFeature
? [
{
content: (
<EditFilteringTab revertAction={revertLocalFilteringRules}>
<FilteringRulesTable />
</EditFilteringTab>
),
id: FilteringTabs.BASIC,
name: i18n.translate(
'xpack.enterpriseSearch.content.index.connector.filtering.basicTabTitle',
{
defaultMessage: 'Basic filters',
}
),
},
]
: []),
...(hasAdvancedFilteringFeature
? [
{
content: (
<EditFilteringTab revertAction={revertLocalAdvancedFiltering}>
<AdvancedFilteringRules />
</EditFilteringTab>
),
id: FilteringTabs.ADVANCED,
name: i18n.translate(
'xpack.enterpriseSearch.content.index.connector.filtering.advancedTabTitle',
{
defaultMessage: 'Advanced filters',
}
),
},
]
: []),
];

return (
Expand Down

0 comments on commit 73d71b6

Please sign in to comment.