From c014f32ae8ebdf9f7df29e674ce00c6f619b4ed4 Mon Sep 17 00:00:00 2001 From: Julian Gernun <17549662+jcger@users.noreply.github.com> Date: Thu, 7 Dec 2023 18:38:54 +0100 Subject: [PATCH 1/4] first commit --- .../components/all_cases/assignees_filter.tsx | 80 +++++----- .../all_cases/multi_select_filter.tsx | 144 ++++++++++-------- .../more_filters_selectable.tsx | 1 + .../components/all_cases/table_filters.tsx | 33 ++-- 4 files changed, 142 insertions(+), 116 deletions(-) diff --git a/x-pack/plugins/cases/public/components/all_cases/assignees_filter.tsx b/x-pack/plugins/cases/public/components/all_cases/assignees_filter.tsx index 8e88eec447e6c..7e556ee46eeab 100644 --- a/x-pack/plugins/cases/public/components/all_cases/assignees_filter.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/assignees_filter.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { EuiFilterButton } from '@elastic/eui'; +import { EuiFilterButton, EuiFilterGroup } from '@elastic/eui'; import { UserProfilesPopover } from '@kbn/user-profile-components'; import { isEmpty } from 'lodash'; import React, { useCallback, useMemo, useState } from 'react'; @@ -91,44 +91,46 @@ const AssigneesFilterPopoverComponent: React.FC = ( const isLoadingData = isLoading || isLoadingSuggest; return ( - 0} - numActiveFilters={selectedAssignees.length} - aria-label={i18n.FILTER_ASSIGNEES_ARIA_LABEL} - > - {i18n.ASSIGNEES} - - } - selectableProps={{ - onChange, - onSearchChange, - selectedStatusMessage, - options: searchResultProfiles, - selectedOptions: selectedAssignees, - isLoading: isLoadingData || isUserTyping, - height: 'full', - searchPlaceholder: i18n.SEARCH_USERS, - clearButtonLabel: i18n.CLEAR_FILTERS, - emptyMessage: , - noMatchesMessage: !isUserTyping && !isLoadingData ? : , - limit: MAX_ASSIGNEES_FILTER_LENGTH, - limitReachedMessage, - singleSelection: false, - nullOptionLabel: i18n.NO_ASSIGNEES, - }} - /> + + 0} + numActiveFilters={selectedAssignees.length} + aria-label={i18n.FILTER_ASSIGNEES_ARIA_LABEL} + > + {i18n.ASSIGNEES} + + } + selectableProps={{ + onChange, + onSearchChange, + selectedStatusMessage, + options: searchResultProfiles, + selectedOptions: selectedAssignees, + isLoading: isLoadingData || isUserTyping, + height: 'full', + searchPlaceholder: i18n.SEARCH_USERS, + clearButtonLabel: i18n.CLEAR_FILTERS, + emptyMessage: , + noMatchesMessage: !isUserTyping && !isLoadingData ? : , + limit: MAX_ASSIGNEES_FILTER_LENGTH, + limitReachedMessage, + singleSelection: false, + nullOptionLabel: i18n.NO_ASSIGNEES, + }} + /> + ); }; AssigneesFilterPopoverComponent.displayName = 'AssigneesFilterPopover'; diff --git a/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx b/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx index cbfdb30d122aa..992000921771e 100644 --- a/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx @@ -18,6 +18,9 @@ import { EuiTextColor, EuiSpacer, useEuiTheme, + EuiFilterGroup, + EuiTextTruncate, + EuiText, } from '@elastic/eui'; import { isEqual } from 'lodash/fp'; import * as i18n from './translations'; @@ -63,16 +66,17 @@ const getEuiSelectableCheckedOptions = ( ) => options.filter((option) => option.checked === 'on') as Array>; interface UseFilterParams { - buttonLabel?: string; buttonIconType?: string; + buttonLabel?: string; hideActiveOptionsNumber?: boolean; id: string; limit?: number; limitReachedMessage?: string; onChange: (params: { filterId: string; selectedOptionKeys: string[] }) => void; options: Array>; - selectedOptionKeys?: string[]; renderOption?: (option: FilterOption) => React.ReactNode; + selectedOptionKeys?: string[]; + transparentBackground?: boolean; } export const MultiSelectFilter = ({ buttonLabel, @@ -85,6 +89,7 @@ export const MultiSelectFilter = ({ options: rawOptions, selectedOptionKeys = [], renderOption, + transparentBackground, }: UseFilterParams) => { const { euiTheme } = useEuiTheme(); const [isPopoverOpen, setIsPopoverOpen] = useState(false); @@ -118,74 +123,91 @@ export const MultiSelectFilter = ({ }; return ( - 0 : undefined} - numActiveFilters={showActiveOptionsNumber ? selectedOptionKeys.length : undefined} - aria-label={buttonLabel} - > - {buttonLabel} - - } - isOpen={isPopoverOpen} - closePopover={() => setIsPopoverOpen(false)} - panelPaddingSize="none" - repositionOnScroll + - {isInvalid && ( - <> - - - - - )} - > - options={options} - searchable - searchProps={{ - placeholder: buttonLabel, - compressed: false, - 'data-test-subj': `${id}-search-input`, - }} - emptyMessage={i18n.EMPTY_FILTER_MESSAGE} - onChange={_onChange} - singleSelection={false} - renderOption={renderOption} - > - {(list, search) => ( -
0 : undefined} + numActiveFilters={showActiveOptionsNumber ? selectedOptionKeys.length : undefined} + aria-label={buttonLabel} > - {search} + + {(truncatedText: string) => ( + + )} + + + } + isOpen={isPopoverOpen} + closePopover={() => setIsPopoverOpen(false)} + panelPaddingSize="none" + repositionOnScroll + > + {isInvalid && ( + <> + + + + + )} + > + options={options} + searchable + searchProps={{ + placeholder: buttonLabel, + compressed: false, + 'data-test-subj': `${id}-search-input`, + }} + emptyMessage={i18n.EMPTY_FILTER_MESSAGE} + onChange={_onChange} + singleSelection={false} + renderOption={renderOption} + > + {(list, search) => (
- {i18n.OPTIONS(options.length)} + {search} +
+ {i18n.OPTIONS(options.length)} +
+ + {list}
- - {list} -
- )} - -
+ )} + + + ); }; diff --git a/x-pack/plugins/cases/public/components/all_cases/table_filter_config/more_filters_selectable.tsx b/x-pack/plugins/cases/public/components/all_cases/table_filter_config/more_filters_selectable.tsx index e89ff2af07242..d191b339a05aa 100644 --- a/x-pack/plugins/cases/public/components/all_cases/table_filter_config/more_filters_selectable.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/table_filter_config/more_filters_selectable.tsx @@ -27,6 +27,7 @@ export const MoreFiltersSelectable = ({ onChange={onChange} options={options} selectedOptionKeys={activeFilters} + transparentBackground={true} /> ); }; diff --git a/x-pack/plugins/cases/public/components/all_cases/table_filters.tsx b/x-pack/plugins/cases/public/components/all_cases/table_filters.tsx index 8d472402b4e77..2c9ec26de739b 100644 --- a/x-pack/plugins/cases/public/components/all_cases/table_filters.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/table_filters.tsx @@ -6,7 +6,7 @@ */ import React, { useCallback, useState } from 'react'; -import { EuiFlexGroup, EuiFlexItem, EuiFieldSearch, EuiFilterGroup, EuiButton } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiFieldSearch, EuiButton } from '@elastic/eui'; import { mergeWith, isEqual } from 'lodash'; import { MoreFiltersSelectable } from './table_filter_config/more_filters_selectable'; import type { CaseStatuses } from '../../../common/types/domain'; @@ -126,7 +126,7 @@ const CasesTableFiltersComponent = ({ }, [onCreateCasePressed]); return ( - + {isSelectorView && onCreateCasePressed ? ( - - - {activeFilters.map((filter) => ( - {filter.render({ filterOptions })} - ))} - {isSelectorView || ( - - )} - - + {activeFilters.map((filter) => ( + + {filter.render({ filterOptions })} + + ))} + + {isSelectorView || ( + + + + )} ); }; From 26b1affedb8ee0584c477363633ab6e3e0a426ee Mon Sep 17 00:00:00 2001 From: Julian Gernun <17549662+jcger@users.noreply.github.com> Date: Thu, 7 Dec 2023 18:45:06 +0100 Subject: [PATCH 2/4] remove comment --- .../public/components/all_cases/multi_select_filter.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx b/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx index 992000921771e..64659b50a443e 100644 --- a/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx @@ -146,11 +146,7 @@ export const MultiSelectFilter = ({ > {(truncatedText: string) => ( - + )} From 0e9963634df37b3534b674c899d6e5275fed7f34 Mon Sep 17 00:00:00 2001 From: Julian Gernun <17549662+jcger@users.noreply.github.com> Date: Mon, 11 Dec 2023 09:20:46 +0100 Subject: [PATCH 3/4] truncate by class and fix test --- .../components/all_cases/multi_select_filter.tsx | 8 +++----- .../components/all_cases/table_filters.test.tsx | 12 ++++++------ .../public/components/all_cases/table_filters.tsx | 7 ++++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx b/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx index 64659b50a443e..afb2d9930d9bb 100644 --- a/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx @@ -144,11 +144,9 @@ export const MultiSelectFilter = ({ numActiveFilters={showActiveOptionsNumber ? selectedOptionKeys.length : undefined} aria-label={buttonLabel} > - - {(truncatedText: string) => ( - - )} - + + {buttonLabel} + } isOpen={isPopoverOpen} diff --git a/x-pack/plugins/cases/public/components/all_cases/table_filters.test.tsx b/x-pack/plugins/cases/public/components/all_cases/table_filters.test.tsx index 17854c7c33547..ad8c63350e3ab 100644 --- a/x-pack/plugins/cases/public/components/all_cases/table_filters.test.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/table_filters.test.tsx @@ -534,7 +534,7 @@ describe('CasesTableFilters ', () => { userEvent.click(screen.getByRole('option', { name: 'Toggle' })); expect(screen.getByRole('button', { name: 'Toggle' })).toBeInTheDocument(); - const filterBar = screen.getByTestId('cases-table-filters-group'); + const filterBar = screen.getByTestId('cases-table-filters'); const allFilters = within(filterBar).getAllByRole('button'); const orderedFilterLabels = ['Severity', 'Status', 'Tags', 'Categories', 'Toggle', 'More']; orderedFilterLabels.forEach((label, index) => { @@ -587,7 +587,7 @@ describe('CasesTableFilters ', () => { userEvent.click(screen.getByRole('option', { name: 'Status' })); expect(screen.queryByRole('button', { name: 'Status' })).not.toBeInTheDocument(); - const filterBar = screen.getByTestId('cases-table-filters-group'); + const filterBar = screen.getByTestId('cases-table-filters'); const allFilters = within(filterBar).getAllByRole('button'); const orderedFilterLabels = ['Severity', 'Tags', 'Categories', 'More']; orderedFilterLabels.forEach((label, index) => { @@ -673,7 +673,7 @@ describe('CasesTableFilters ', () => { appMockRender.render(); - const filterBar = screen.getByTestId('cases-table-filters-group'); + const filterBar = screen.getByTestId('cases-table-filters'); let allFilters: HTMLElement[]; await waitFor(() => { allFilters = within(filterBar).getAllByRole('button'); @@ -703,7 +703,7 @@ describe('CasesTableFilters ', () => { appMockRender.render(); - const filterBar = screen.getByTestId('cases-table-filters-group'); + const filterBar = screen.getByTestId('cases-table-filters'); let allFilters: HTMLElement[]; await waitFor(() => { allFilters = within(filterBar).getAllByRole('button'); @@ -756,7 +756,7 @@ describe('CasesTableFilters ', () => { it('when a filter is active and isnt last in the list, it should move the filter to last position after deactivating and activating', async () => { appMockRender.render(); - const filterBar = screen.getByTestId('cases-table-filters-group'); + const filterBar = screen.getByTestId('cases-table-filters'); let allFilters = within(filterBar).getAllByRole('button'); let orderedFilterLabels = ['Severity', 'Status', 'Tags', 'Categories', 'More']; orderedFilterLabels.forEach((label, index) => { @@ -788,7 +788,7 @@ describe('CasesTableFilters ', () => { }); appMockRender.render(); - const filterBar = screen.getByTestId('cases-table-filters-group'); + const filterBar = screen.getByTestId('cases-table-filters'); let allFilters: HTMLElement[]; await waitFor(() => { allFilters = within(filterBar).getAllByRole('button'); diff --git a/x-pack/plugins/cases/public/components/all_cases/table_filters.tsx b/x-pack/plugins/cases/public/components/all_cases/table_filters.tsx index 2c9ec26de739b..8672671bd8ab6 100644 --- a/x-pack/plugins/cases/public/components/all_cases/table_filters.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/table_filters.tsx @@ -126,7 +126,12 @@ const CasesTableFiltersComponent = ({ }, [onCreateCasePressed]); return ( - + {isSelectorView && onCreateCasePressed ? ( Date: Mon, 11 Dec 2023 09:31:01 +0100 Subject: [PATCH 4/4] remove truncate component --- .../cases/public/components/all_cases/multi_select_filter.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx b/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx index afb2d9930d9bb..b56c926bab965 100644 --- a/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/multi_select_filter.tsx @@ -19,7 +19,6 @@ import { EuiSpacer, useEuiTheme, EuiFilterGroup, - EuiTextTruncate, EuiText, } from '@elastic/eui'; import { isEqual } from 'lodash/fp';