@rh-support/cases 2.6.227 → 2.6.229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/lib/esm/components/case/NewCaseButton.js +1 -1
  2. package/lib/esm/components/case-list/CaseList.d.ts +0 -7
  3. package/lib/esm/components/case-list/CaseList.d.ts.map +1 -1
  4. package/lib/esm/components/case-list/CaseList.js +368 -137
  5. package/lib/esm/components/case-list/CaseListContext.d.ts.map +1 -1
  6. package/lib/esm/components/case-list/CaseListContext.js +5 -2
  7. package/lib/esm/components/case-list/CaseListFilterContext.d.ts.map +1 -1
  8. package/lib/esm/components/case-list/CaseListFilterContext.js +2 -1
  9. package/lib/esm/components/case-list/CaseListFilterHelpers.d.ts +3 -2
  10. package/lib/esm/components/case-list/CaseListFilterHelpers.d.ts.map +1 -1
  11. package/lib/esm/components/case-list/CaseListFilterHelpers.js +19 -6
  12. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts +36 -4
  13. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts.map +1 -1
  14. package/lib/esm/components/case-list/CaseListFilterReducer.js +6 -12
  15. package/lib/esm/components/case-list/CaseListReducer.d.ts +22 -10
  16. package/lib/esm/components/case-list/CaseListReducer.d.ts.map +1 -1
  17. package/lib/esm/components/case-list/CaseListReducer.js +25 -7
  18. package/lib/esm/components/case-list/case-list-filters/AccountsFilter.d.ts.map +1 -1
  19. package/lib/esm/components/case-list/case-list-filters/AccountsFilter.js +18 -11
  20. package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.d.ts.map +1 -1
  21. package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.js +6 -2
  22. package/lib/esm/components/case-list/case-list-filters/CaseLabelsFilter.d.ts +3 -0
  23. package/lib/esm/components/case-list/case-list-filters/CaseLabelsFilter.d.ts.map +1 -0
  24. package/lib/esm/components/case-list/case-list-filters/CaseLabelsFilter.js +177 -0
  25. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts +1 -7
  26. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts.map +1 -1
  27. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.js +12 -16
  28. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts +2 -5
  29. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts.map +1 -1
  30. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.js +14 -13
  31. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilter.d.ts.map +1 -1
  32. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilter.js +21 -14
  33. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilterChip.d.ts.map +1 -1
  34. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilterChip.js +3 -0
  35. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.d.ts +11 -1
  36. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.d.ts.map +1 -1
  37. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.js +90 -70
  38. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts +1 -3
  39. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts.map +1 -1
  40. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.js +2 -2
  41. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts +5 -4
  42. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts.map +1 -1
  43. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.js +15 -54
  44. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts +0 -3
  45. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts.map +1 -1
  46. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.js +18 -44
  47. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts +0 -3
  48. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts.map +1 -1
  49. package/lib/esm/components/case-list/case-list-filters/StatusFilter.js +14 -44
  50. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts +1 -3
  51. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts.map +1 -1
  52. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.js +60 -59
  53. package/lib/esm/components/case-list/case-list-table/ArchivedCaseLabel.d.ts +3 -0
  54. package/lib/esm/components/case-list/case-list-table/ArchivedCaseLabel.d.ts.map +1 -0
  55. package/lib/esm/components/case-list/case-list-table/ArchivedCaseLabel.js +8 -0
  56. package/lib/esm/components/case-list/case-list-table/CaseListLabelGroup.d.ts +9 -0
  57. package/lib/esm/components/case-list/case-list-table/CaseListLabelGroup.d.ts.map +1 -0
  58. package/lib/esm/components/case-list/case-list-table/CaseListLabelGroup.js +105 -0
  59. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts +8 -3
  60. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts.map +1 -1
  61. package/lib/esm/components/case-list/case-list-table/CaseListTable.js +87 -84
  62. package/lib/esm/components/case-list/case-list-table/CaseListTableRow.d.ts +33 -0
  63. package/lib/esm/components/case-list/case-list-table/CaseListTableRow.d.ts.map +1 -0
  64. package/lib/esm/components/case-list/case-list-table/CaseListTableRow.js +51 -0
  65. package/lib/esm/components/case-list/case-list-table/CaseListTableSkeletonRow.d.ts +9 -0
  66. package/lib/esm/components/case-list/case-list-table/CaseListTableSkeletonRow.d.ts.map +1 -0
  67. package/lib/esm/components/case-list/case-list-table/CaseListTableSkeletonRow.js +10 -0
  68. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts +0 -5
  69. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts.map +1 -1
  70. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.js +51 -70
  71. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.d.ts.map +1 -1
  72. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.js +5 -15
  73. package/lib/esm/components/case-list/case-list-table/SeverityLabel.js +1 -1
  74. package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.d.ts.map +1 -1
  75. package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.js +2 -3
  76. package/lib/esm/components/case-list/case-list-table/table-column-selector/TableColumnSelector.d.ts.map +1 -1
  77. package/lib/esm/components/case-list/case-list-table/table-column-selector/TableColumnSelector.js +1 -0
  78. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.d.ts +8 -0
  79. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.d.ts.map +1 -0
  80. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.js +8 -0
  81. package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.d.ts.map +1 -1
  82. package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.js +1 -0
  83. package/lib/esm/components/case-list/case-search/CaseSearch.d.ts.map +1 -1
  84. package/lib/esm/components/case-list/case-search/CaseSearch.js +55 -24
  85. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.d.ts +10 -0
  86. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.d.ts.map +1 -0
  87. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.js +29 -0
  88. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.d.ts +10 -0
  89. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.d.ts.map +1 -0
  90. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.js +16 -0
  91. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts +9 -0
  92. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts.map +1 -0
  93. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.js +21 -0
  94. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.d.ts +12 -0
  95. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.d.ts.map +1 -0
  96. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.js +31 -0
  97. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts +10 -0
  98. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts.map +1 -0
  99. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.js +10 -0
  100. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts +10 -0
  101. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts.map +1 -0
  102. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.js +92 -0
  103. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts +9 -0
  104. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts.map +1 -0
  105. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.js +20 -0
  106. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.d.ts +9 -0
  107. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.d.ts.map +1 -0
  108. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.js +28 -0
  109. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.d.ts +9 -0
  110. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.d.ts.map +1 -0
  111. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.js +241 -0
  112. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts +11 -0
  113. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts.map +1 -0
  114. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.js +23 -0
  115. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.d.ts.map +1 -1
  116. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.js +2 -1
  117. package/lib/esm/css/caseList.css +183 -22
  118. package/lib/esm/css/caseSearch.css +114 -0
  119. package/lib/esm/enums/case.d.ts +13 -5
  120. package/lib/esm/enums/case.d.ts.map +1 -1
  121. package/lib/esm/enums/case.js +23 -3
  122. package/lib/esm/enums/caseSearch.d.ts +3 -0
  123. package/lib/esm/enums/caseSearch.d.ts.map +1 -1
  124. package/lib/esm/enums/caseSearch.js +2 -1
  125. package/lib/esm/enums/filters.d.ts +3 -1
  126. package/lib/esm/enums/filters.d.ts.map +1 -1
  127. package/lib/esm/enums/filters.js +2 -0
  128. package/lib/esm/hooks/useCaseLabels.d.ts +14 -0
  129. package/lib/esm/hooks/useCaseLabels.d.ts.map +1 -0
  130. package/lib/esm/hooks/useCaseLabels.js +56 -0
  131. package/lib/esm/hooks/useCloseCase.d.ts.map +1 -1
  132. package/lib/esm/hooks/useCloseCase.js +38 -21
  133. package/lib/esm/hooks/useExportCaseListCSV.d.ts.map +1 -1
  134. package/lib/esm/hooks/useExportCaseListCSV.js +1 -9
  135. package/lib/esm/hooks/useFilterStateOnLoad.d.ts +1 -1
  136. package/lib/esm/hooks/useFilterStateOnLoad.d.ts.map +1 -1
  137. package/lib/esm/hooks/useFilterStateOnLoad.js +7 -5
  138. package/lib/esm/index.js +1 -0
  139. package/lib/esm/models/caseList.d.ts +1 -0
  140. package/lib/esm/models/caseList.d.ts.map +1 -1
  141. package/lib/esm/test-utils/mockData.d.ts +1 -0
  142. package/lib/esm/test-utils/mockData.d.ts.map +1 -1
  143. package/lib/esm/test-utils/mockData.js +2 -1
  144. package/lib/esm/utils/advanceSearchFormMapper.d.ts +11 -0
  145. package/lib/esm/utils/advanceSearchFormMapper.d.ts.map +1 -0
  146. package/lib/esm/utils/advanceSearchFormMapper.js +71 -0
  147. package/lib/esm/utils/advanceSearchUtils.d.ts +24 -0
  148. package/lib/esm/utils/advanceSearchUtils.d.ts.map +1 -0
  149. package/lib/esm/utils/advanceSearchUtils.js +150 -0
  150. package/lib/esm/utils/caseGroupDefaultFilterUtils.d.ts +12 -0
  151. package/lib/esm/utils/caseGroupDefaultFilterUtils.d.ts.map +1 -0
  152. package/lib/esm/utils/caseGroupDefaultFilterUtils.js +34 -0
  153. package/lib/esm/utils/caseGroupDefaultUtils.d.ts +10 -0
  154. package/lib/esm/utils/caseGroupDefaultUtils.d.ts.map +1 -0
  155. package/lib/esm/utils/caseGroupDefaultUtils.js +20 -0
  156. package/lib/esm/utils/caseListGraphQLUtils.d.ts +28 -0
  157. package/lib/esm/utils/caseListGraphQLUtils.d.ts.map +1 -0
  158. package/lib/esm/utils/caseListGraphQLUtils.js +280 -0
  159. package/lib/esm/utils/caseListMapper.d.ts +6 -0
  160. package/lib/esm/utils/caseListMapper.d.ts.map +1 -0
  161. package/lib/esm/utils/caseListMapper.js +47 -0
  162. package/lib/esm/utils/caseListVariablesBuilder.d.ts +15 -0
  163. package/lib/esm/utils/caseListVariablesBuilder.d.ts.map +1 -0
  164. package/lib/esm/utils/caseListVariablesBuilder.js +526 -0
  165. package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
  166. package/lib/esm/utils/caseSearchUtils.js +39 -2
  167. package/lib/esm/utils/constants.d.ts +5 -1
  168. package/lib/esm/utils/constants.d.ts.map +1 -1
  169. package/lib/esm/utils/constants.js +10 -2
  170. package/lib/esm/utils/mockSolrResponse.js +1 -1
  171. package/package.json +10 -8
@@ -1,4 +1,4 @@
1
- import { Button, MenuFooter, MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, } from '@patternfly/react-core';
1
+ import { Badge, Button, MenuFooter, MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, } from '@patternfly/react-core';
2
2
  import TimesIcon from '@patternfly/react-icons/dist/js/icons/times-icon';
3
3
  import { GlobalMetadataStateContext } from '@rh-support/react-context';
4
4
  import { ability, resourceActions, resources } from '@rh-support/user-permissions';
@@ -12,83 +12,105 @@ import { SolrKeys } from '../../../enums/filters';
12
12
  import { filterNamesMap } from '../../../utils/constants';
13
13
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
14
14
  import { updateFilter } from '../CaseListFilterReducer';
15
- export function GroupsFilter() {
15
+ const EMPTY_GROUPS = [];
16
+ export function GroupsFilter({ selectedGroups: controlledSelectedGroups, onGroupsChange, hideLabel = false, idPrefix = 'case-list-group-filter', showSelectionCountBadge = false, placeholder: placeholderProp, } = {}) {
17
+ var _a, _b;
16
18
  const { t } = useTranslation();
17
- const { globalMetadataState: { caseGroups }, } = useContext(GlobalMetadataStateContext);
18
19
  const { filterInfo } = useContext(CaseListFilterStateContext);
19
20
  const dispatch = useContext(CaseListFilterDispatchContext);
21
+ const isControlled = typeof onGroupsChange === 'function';
22
+ // Prefer the filterInfo array reference in basic/uncontrolled mode so empty selection
23
+ // does not create a new [] each render and re-fire the selectedItems sync effect.
24
+ const selectedGroups = isControlled
25
+ ? controlledSelectedGroups || EMPTY_GROUPS
26
+ : (_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.group]) !== null && _a !== void 0 ? _a : EMPTY_GROUPS;
27
+ const { globalMetadataState: { caseGroups }, } = useContext(GlobalMetadataStateContext);
28
+ const isLoading = caseGroups.isFetching;
20
29
  const [inputValue, setInputValue] = useState('');
21
30
  const [focusedItemIndex, setFocusedItemIndex] = useState(null);
22
31
  const [activeItem, setActiveItem] = useState(null);
23
- const list = [
24
- ...(caseGroups.data ? caseGroups === null || caseGroups === void 0 ? void 0 : caseGroups.data.map((group) => ({ value: group.name, key: group.groupNum })) : []),
25
- ];
32
+ const list = useMemo(() => (caseGroups.data || []).map((group) => ({ value: group.name, key: group.groupNum })), [caseGroups.data]);
26
33
  const [selectOptions, setSelectOptions] = useState(list);
27
34
  const canViewManageTab = ability.can(resourceActions.READ, resources.MANAGE);
28
35
  const canViewCaseGroups = ability.can(resourceActions.READ, resources.CASE_GROUPS) && canViewManageTab;
29
36
  const [isOpen, setIsOpen] = useState(false);
30
37
  const [selectedItems, setSelectedItems] = useState({});
31
38
  const textInputRef = useRef();
32
- const onToggleClick = (e) => {
39
+ const applyGroupSelection = (updatedFilterValues) => {
40
+ if (isControlled) {
41
+ onGroupsChange(updatedFilterValues);
42
+ return;
43
+ }
44
+ updateFilter(dispatch, {
45
+ filterKey: SolrKeys.group,
46
+ values: updatedFilterValues,
47
+ });
48
+ };
49
+ const onToggleClick = () => {
33
50
  setIsOpen(!isOpen);
34
51
  };
35
52
  const onSelect = (option) => {
53
+ const optionValue = typeof option === 'string' ? option : option === null || option === void 0 ? void 0 : option.value;
54
+ if (!optionValue || optionValue === 'no results') {
55
+ return;
56
+ }
36
57
  const prevSelectedGroups = Object.keys(selectedItems).filter((item) => selectedItems[item] && item);
37
- if (selectedItems[option.value]) {
38
- setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: !prevData[option.value] })));
39
- const indexOfGroup = prevSelectedGroups.indexOf(option.value);
58
+ if (selectedItems[optionValue]) {
59
+ setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [optionValue]: !prevData[optionValue] })));
60
+ const indexOfGroup = prevSelectedGroups.indexOf(optionValue);
40
61
  prevSelectedGroups.splice(indexOfGroup, 1);
41
62
  }
42
63
  else {
43
- setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
44
- prevSelectedGroups.push(option.value);
64
+ setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [optionValue]: true })));
65
+ prevSelectedGroups.push(optionValue);
45
66
  }
46
- const mapValueToKey = (value) => {
67
+ const updatedFilterValues = prevSelectedGroups
68
+ .map((value) => {
47
69
  const selectedItem = list.find((item) => item.value === value);
48
- return selectedItem;
49
- };
50
- const updatedFilterValues = prevSelectedGroups.map((item) => mapValueToKey(item));
51
- updateFilter(dispatch, {
52
- filterKey: SolrKeys.group,
53
- values: updatedFilterValues,
54
- });
70
+ if (!(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.key)) {
71
+ return null;
72
+ }
73
+ return { key: String(selectedItem.key), value: String(selectedItem.value) };
74
+ })
75
+ .filter(Boolean);
76
+ applyGroupSelection(updatedFilterValues);
55
77
  };
56
78
  const handleMenuArrowKeys = (key) => {
57
- let indexToFocus;
58
- if (isOpen) {
59
- if (key === 'ArrowUp') {
60
- // When no index is set or at the first index, focus to the last, otherwise decrement focus index
61
- if (focusedItemIndex === null || focusedItemIndex === 0) {
62
- indexToFocus = (list === null || list === void 0 ? void 0 : list.length) - 1;
63
- }
64
- else {
65
- indexToFocus = focusedItemIndex - 1;
66
- }
79
+ if (!isOpen || !list.length) {
80
+ return;
81
+ }
82
+ let indexToFocus = 0;
83
+ if (key === 'ArrowUp') {
84
+ if (focusedItemIndex === null || focusedItemIndex === 0) {
85
+ indexToFocus = list.length - 1;
67
86
  }
68
- if (key === 'ArrowDown') {
69
- // When no index is set or at the last index, focus to the first, otherwise increment focus index
70
- if (focusedItemIndex === null || focusedItemIndex === (list === null || list === void 0 ? void 0 : list.length) - 1) {
71
- indexToFocus = 0;
72
- }
73
- else {
74
- indexToFocus = focusedItemIndex + 1;
75
- }
87
+ else {
88
+ indexToFocus = focusedItemIndex - 1;
89
+ }
90
+ }
91
+ if (key === 'ArrowDown') {
92
+ if (focusedItemIndex === null || focusedItemIndex === list.length - 1) {
93
+ indexToFocus = 0;
76
94
  }
77
- setFocusedItemIndex(indexToFocus);
78
- const focusedItem = list[indexToFocus];
79
- setActiveItem(`select-multi-typeahead-checkbox-${focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.value.replace(' ', '-')}`);
95
+ else {
96
+ indexToFocus = focusedItemIndex + 1;
97
+ }
98
+ }
99
+ setFocusedItemIndex(indexToFocus);
100
+ const focusedItem = list[indexToFocus];
101
+ if (focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.value) {
102
+ setActiveItem(`select-multi-typeahead-checkbox-${String(focusedItem.value).replace(' ', '-')}`);
80
103
  }
81
104
  };
82
105
  const onInputKeyDown = (event) => {
83
- const focusedItem = focusedItemIndex ? list[focusedItemIndex] : list[0];
106
+ const focusedItem = focusedItemIndex !== null ? list[focusedItemIndex] : list[0];
84
107
  switch (event.key) {
85
- // Select the first available option
86
108
  case 'Enter':
87
109
  if (!isOpen) {
88
110
  setIsOpen((prevIsOpen) => !prevIsOpen);
89
111
  }
90
112
  else if (isOpen && (focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.value) !== 'no results') {
91
- onSelect(focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.value);
113
+ onSelect(focusedItem);
92
114
  }
93
115
  break;
94
116
  case 'Tab':
@@ -106,36 +128,37 @@ export function GroupsFilter() {
106
128
  const onTextInputChange = (_event, value) => {
107
129
  setInputValue(value);
108
130
  };
109
- const placeholder = getDropdownBtnPlaceholder(t('Select a group'), filterInfo[SolrKeys.group], '', (caseGroups.data || []).length, t('All selected'));
131
+ const defaultEmptyPlaceholder = placeholderProp || t('Select a group');
132
+ const placeholder = showSelectionCountBadge
133
+ ? isLoading
134
+ ? t('Loading...')
135
+ : defaultEmptyPlaceholder
136
+ : getDropdownBtnPlaceholder(isLoading ? t('Loading...') : defaultEmptyPlaceholder, selectedGroups, '', ((_b = caseGroups.data) === null || _b === void 0 ? void 0 : _b.length) || 0, t('All selected'));
137
+ const hasSelectedGroups = selectedGroups.length > 0;
110
138
  const onClick = () => {
111
139
  var _a;
112
140
  setInputValue('');
113
141
  setSelectedItems({});
114
- updateFilter(dispatch, {
115
- filterKey: SolrKeys.group,
116
- values: [],
117
- });
142
+ applyGroupSelection([]);
118
143
  (_a = textInputRef === null || textInputRef === void 0 ? void 0 : textInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
119
144
  };
120
145
  const toggle = (toggleRef) => (React.createElement(MenuToggle, { variant: "typeahead", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true },
121
146
  React.createElement(TextInputGroup, { isPlain: true },
122
- React.createElement(TextInputGroupMain, Object.assign({ value: inputValue, onClick: onToggleClick, onChange: onTextInputChange, onKeyDown: onInputKeyDown, id: "multi-typeahead-select-checkbox-input", autoComplete: "off", innerRef: textInputRef, placeholder: placeholder }, (activeItem && { 'aria-activedescendant': activeItem }), { role: "combobox", isExpanded: isOpen, "aria-controls": "select-multi-typeahead-checkbox-listbox" })),
123
- Object.keys(selectedItems).filter((key) => selectedItems[key] === true).length ? (React.createElement(TextInputGroupUtilities, null,
124
- React.createElement(Button, { icon: React.createElement(TimesIcon, { "aria-hidden": true }), variant: "plain", onClick: onClick, "aria-label": "Clear input value" }))) : (''))));
147
+ React.createElement(TextInputGroupMain, Object.assign({ value: inputValue, onClick: onToggleClick, onChange: onTextInputChange, onKeyDown: onInputKeyDown, id: `${idPrefix}-input`, autoComplete: "off", innerRef: textInputRef, placeholder: placeholder }, (activeItem && { 'aria-activedescendant': activeItem }), { role: "combobox", isExpanded: isOpen, "aria-controls": `${idPrefix}-listbox` })),
148
+ hasSelectedGroups ? (React.createElement(TextInputGroupUtilities, null,
149
+ showSelectionCountBadge && (React.createElement(Badge, { className: "advance-search-dropdown-toggle-badge pf-v6-u-mr-sm" }, t('{{count}} selected', { count: selectedGroups.length }))),
150
+ React.createElement(Button, { icon: React.createElement(TimesIcon, { "aria-hidden": true }), variant: "plain", onClick: onClick, "aria-label": t('Clear input value') }))) : null)));
125
151
  const dropdownOptions = useMemo(() => {
126
152
  return (!isEmpty(selectOptions) ? selectOptions : list).map((option, index) => !isUndefined(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: true, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-multi-typeahead-${option.value.replace(' ', '-')}` }, option.value)));
127
153
  // eslint-disable-next-line react-hooks/exhaustive-deps
128
- }, [selectedItems, caseGroups === null || caseGroups === void 0 ? void 0 : caseGroups.data, selectOptions, focusedItemIndex]);
154
+ }, [selectedItems, caseGroups, selectOptions, focusedItemIndex]);
129
155
  useEffect(() => {
130
156
  let newSelectOptions = list;
131
- // Filter menu items based on the text input value when one exists
132
157
  if (inputValue) {
133
158
  newSelectOptions = list.filter((option) => String(option === null || option === void 0 ? void 0 : option.value).toLowerCase().startsWith(inputValue.toLowerCase()));
134
- // When no options are found after filtering, display 'No results found'
135
159
  if (!newSelectOptions.length) {
136
160
  newSelectOptions = [{ isDisabled: false, children: `No results found` }];
137
161
  }
138
- // Open the menu when the input value changes and the new value is not empty
139
162
  if (!isOpen) {
140
163
  setIsOpen(true);
141
164
  }
@@ -144,29 +167,26 @@ export function GroupsFilter() {
144
167
  setFocusedItemIndex(null);
145
168
  setActiveItem(null);
146
169
  // eslint-disable-next-line react-hooks/exhaustive-deps
147
- }, [inputValue]);
170
+ }, [inputValue, list]);
148
171
  useEffect(() => {
149
- var _a;
150
- if (isEmpty(filterInfo[SolrKeys.group])) {
172
+ if (isEmpty(selectedGroups)) {
151
173
  setSelectedItems({});
152
174
  }
153
175
  else {
154
- const selectedGroups = (_a = filterInfo[SolrKeys.group]) === null || _a === void 0 ? void 0 : _a.reduce((selection, group) => {
176
+ const nextSelectedItems = selectedGroups.reduce((selection, group) => {
155
177
  selection[group === null || group === void 0 ? void 0 : group.value] = true;
156
178
  return selection;
157
179
  }, {});
158
- setSelectedItems(selectedGroups);
180
+ setSelectedItems(nextSelectedItems);
159
181
  }
160
- // eslint-disable-next-line react-hooks/exhaustive-deps
161
- }, [filterInfo[SolrKeys.group]]);
162
- return (React.createElement("div", { className: "group-filter" },
163
- React.createElement("label", { htmlFor: "case-list-group-filter", className: "pf-v6-u-mb-sm group-filter-label" }, t(filterNamesMap[SolrKeys.group])),
182
+ }, [selectedGroups]);
183
+ return (React.createElement("div", { className: "group-filter", "data-testid": "groups-filter" },
184
+ !hideLabel && (React.createElement("label", { htmlFor: idPrefix, className: "pf-v6-u-mb-sm group-filter-label" }, t(filterNamesMap[SolrKeys.group]))),
164
185
  React.createElement("div", { className: "pf-v6-c-select" },
165
- React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, "data-tracking-id": "groups-filter", id: "case-list-group-filter", title: t(filterNamesMap[SolrKeys.group]), isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), popperProps: { direction: 'down', enableFlip: false }, toggle: toggle, isScrollable: true },
186
+ React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, "data-tracking-id": "groups-filter", id: idPrefix, title: t(filterNamesMap[SolrKeys.group]), isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), popperProps: { direction: 'down', enableFlip: false }, toggle: toggle, isScrollable: true },
166
187
  React.createElement(SelectList, null,
167
188
  dropdownOptions,
168
- canViewCaseGroups && (React.createElement(React.Fragment, null,
169
- React.createElement(MenuFooter, { className: "group-filter-manage-groups-footer" },
170
- React.createElement(Link, { className: "cta cta-link", to: "/manage/groups" },
171
- React.createElement(Trans, null, "Manage groups"))))))))));
189
+ canViewCaseGroups && (React.createElement(MenuFooter, { className: "group-filter-manage-groups-footer" },
190
+ React.createElement(Link, { className: "cta cta-link", to: "/manage/groups" },
191
+ React.createElement(Trans, null, "Manage groups")))))))));
172
192
  }
@@ -1,10 +1,8 @@
1
1
  import React from 'react';
2
- import { IProductVersionPivotMap } from '../CaseList';
3
2
  import { IProductFilter } from '../CaseListFilterReducer';
4
3
  interface IProps {
5
4
  productList: IProductFilter[];
6
- productVersionPivot: IProductVersionPivotMap[];
7
5
  }
8
- export declare function ProductFilterChip({ productList, productVersionPivot }: IProps): React.JSX.Element;
6
+ export declare function ProductFilterChip({ productList }: IProps): React.JSX.Element;
9
7
  export {};
10
8
  //# sourceMappingURL=ProductFilterChip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProductFilterChip.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductFilterChip.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAGxE,UAAU,MAAM;IACZ,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,mBAAmB,EAAE,uBAAuB,EAAE,CAAC;CAClD;AAED,wBAAgB,iBAAiB,CAAC,EAAE,WAAW,EAAE,mBAAwB,EAAE,EAAE,MAAM,qBAsElF"}
1
+ {"version":3,"file":"ProductFilterChip.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductFilterChip.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAE,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAGxE,UAAU,MAAM;IACZ,WAAW,EAAE,cAAc,EAAE,CAAC;CACjC;AAED,wBAAgB,iBAAiB,CAAC,EAAE,WAAW,EAAE,EAAE,MAAM,qBAsExD"}
@@ -7,7 +7,7 @@ import { filterNamesMap } from '../../../utils/constants';
7
7
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
8
8
  import { updateFilter } from '../CaseListFilterReducer';
9
9
  import { VersionsFilter } from './VersionsFilter';
10
- export function ProductFilterChip({ productList, productVersionPivot = [] }) {
10
+ export function ProductFilterChip({ productList }) {
11
11
  const { filterInfo } = useContext(CaseListFilterStateContext);
12
12
  const dispatch = useContext(CaseListFilterDispatchContext);
13
13
  const canAccessVersionsFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.VERSIONS_FILTER);
@@ -26,7 +26,7 @@ export function ProductFilterChip({ productList, productVersionPivot = [] }) {
26
26
  return (React.createElement("div", { className: "filter-chip" },
27
27
  React.createElement("span", { className: "filter-chip__heading" }, filterNamesMap[SolrKeys.product]),
28
28
  canAccessVersionsFilter ? (React.createElement(React.Fragment, null, productList.map((currentProduct, index) => (React.createElement(LabelGroup, { numLabels: 10, key: `${currentProduct.value}-${index}`, categoryName: currentProduct.value },
29
- React.createElement(VersionsFilter, { productInfo: currentProduct, productVersionPivot: productVersionPivot }),
29
+ React.createElement(VersionsFilter, { productInfo: currentProduct }),
30
30
  currentProduct[SolrKeys.version].map((chip) => (React.createElement(Label, { variant: "outline", key: chip.value, onClose: () => deleteVersion(currentProduct, chip) }, chip.value))),
31
31
  React.createElement(Button, { icon: React.createElement(TimesCircleIcon, { "aria-hidden": "true" }), className: "pf-v6-c-button__icon", variant: ButtonVariant.plain, "aria-label": "Remove product", onClick: () => deleteProduct(currentProduct) })))))) : (React.createElement(LabelGroup, { numLabels: 10, categoryName: "Product", key: "products" }, productList.map((currentProduct, index) => (React.createElement(Label, { variant: "outline", key: `${currentProduct.value}-${index}`, onClose: () => deleteProduct(currentProduct) }, currentProduct.value)))))));
32
32
  }
@@ -1,9 +1,10 @@
1
- import { IFacetResponse } from '@rh-support/types/shared';
2
1
  import React from 'react';
2
+ interface IProductOption {
3
+ name: string;
4
+ productId: string;
5
+ }
3
6
  interface IProps {
4
- filterValues: IFacetResponse[];
5
- isSolrSearchDown: boolean;
6
- allProducts: string[];
7
+ allProducts: IProductOption[];
7
8
  }
8
9
  export declare function ProductsFilter(props: IProps): React.JSX.Element;
9
10
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ProductsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductsFilter.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D,OAAO,KAAkD,MAAM,OAAO,CAAC;AAQvE,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,qBA+O3C"}
1
+ {"version":3,"file":"ProductsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductsFilter.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAQvE,UAAU,cAAc;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,MAAM;IACZ,WAAW,EAAE,cAAc,EAAE,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,qBAoL3C"}
@@ -1,5 +1,5 @@
1
1
  import { MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, } from '@patternfly/react-core';
2
- import { SingleSelectDropdown, useSelectKeyboardNavigator } from '@rh-support/components';
2
+ import { useSelectKeyboardNavigator } from '@rh-support/components';
3
3
  import { getDropdownBtnPlaceholder } from '@rh-support/utils';
4
4
  import isEmpty from 'lodash/isEmpty';
5
5
  import isUndefined from 'lodash/isUndefined';
@@ -10,11 +10,11 @@ import { filterNamesMap } from '../../../utils/constants';
10
10
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
11
11
  import { updateFilter } from '../CaseListFilterReducer';
12
12
  export function ProductsFilter(props) {
13
- var _a, _b, _c, _d, _f;
13
+ var _a;
14
14
  const { t } = useTranslation();
15
15
  const dispatch = useContext(CaseListFilterDispatchContext);
16
16
  const { filterInfo } = useContext(CaseListFilterStateContext);
17
- const { allProducts, filterValues, isSolrSearchDown } = props;
17
+ const { allProducts } = props;
18
18
  const [isOpen, setIsOpen] = useState(false);
19
19
  const [selectedItems, setSelectedItems] = useState({});
20
20
  const [activeItem, setActiveItem] = useState(null);
@@ -23,51 +23,24 @@ export function ProductsFilter(props) {
23
23
  const selectedProducts = !isUndefined(filterInfo) && !isUndefined(filterInfo[SolrPivotKeys.product_version])
24
24
  ? filterInfo[SolrPivotKeys.product_version]
25
25
  : [];
26
- const productOptions = filterValues.map((product) => ({
26
+ const productOptions = allProducts.map((product) => ({
27
27
  field: SolrKeys.product,
28
- value: product.value,
28
+ value: product.name,
29
+ productId: product.productId,
29
30
  [SolrKeys.version]: [],
30
31
  }));
31
- const singleSelectOptions = allProducts.length > 0
32
- ? allProducts.map((product) => ({
33
- value: product,
34
- label: product,
35
- }))
36
- : [{ value: '', label: t('No products available') }];
37
- const selectedProduct = ((_b = (_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.value) || '';
38
- const selectedOption = {
39
- value: selectedProduct,
40
- label: selectedProduct,
41
- };
42
- // Single select mode for when Solr is down
43
- const onFilterChangeSingleSelect = (selection) => {
44
- updateFilter(dispatch, {
45
- filterKey: SolrPivotKeys.product_version,
46
- values: [{ field: SolrKeys.product, value: selection.value, [SolrKeys.version]: [] }],
47
- });
48
- setIsOpen(false);
49
- };
50
- const onSingleSelectChange = (option) => {
51
- // Don't update filter if no products are available
52
- if (allProducts.length === 0 || option.value === '') {
53
- return;
54
- }
55
- updateFilter(dispatch, {
56
- filterKey: SolrPivotKeys.product_version,
57
- values: [{ field: SolrKeys.product, value: option.value, [SolrKeys.version]: [] }],
58
- });
59
- };
60
- // Multi-select mode
61
32
  const onSelect = (option) => {
33
+ var _a;
62
34
  let newSelectedProducts = [];
63
35
  if (selectedProducts === null || selectedProducts === void 0 ? void 0 : selectedProducts.some((product) => option.value === product.value)) {
64
36
  newSelectedProducts = selectedProducts.filter((product) => option.value !== product.value);
65
37
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
66
38
  }
67
39
  else {
40
+ const productId = option.productId || ((_a = allProducts.find((p) => p.name === option.value)) === null || _a === void 0 ? void 0 : _a.productId) || '';
68
41
  newSelectedProducts = [
69
42
  ...selectedProducts,
70
- { field: SolrKeys.product, value: option.value, [SolrKeys.version]: [] },
43
+ { field: SolrKeys.product, value: option.value, productId, [SolrKeys.version]: [] },
71
44
  ];
72
45
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
73
46
  }
@@ -93,21 +66,12 @@ export function ProductsFilter(props) {
93
66
  resetIndexOnClose: true,
94
67
  isDisabled: false,
95
68
  setIsOpen,
96
- onSelect: (item) => {
97
- if (isSolrSearchDown) {
98
- onFilterChangeSingleSelect(item);
99
- }
100
- else {
101
- onSelect(item);
102
- }
103
- },
69
+ onSelect,
104
70
  });
105
71
  const onTextInputChange = (_event, value) => {
106
72
  setInputValue(value);
107
73
  };
108
- const placeholder = isSolrSearchDown
109
- ? ((_d = (_c = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version]) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.value) || t('Select a product')
110
- : getDropdownBtnPlaceholder(t('Select a product'), ((_f = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version]) === null || _f === void 0 ? void 0 : _f.map((i) => i.value)) || [], '', props.filterValues.length, t('All selected'));
74
+ const placeholder = getDropdownBtnPlaceholder(t('Select a product'), ((_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version]) === null || _a === void 0 ? void 0 : _a.map((i) => i.value)) || [], '', (allProducts === null || allProducts === void 0 ? void 0 : allProducts.length) || 0, t('All selected'));
111
75
  const toggleForMultiSelect = (toggleRef) => (React.createElement(MenuToggle, { variant: "typeahead", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true },
112
76
  React.createElement(TextInputGroup, { isPlain: true },
113
77
  React.createElement(TextInputGroupMain, Object.assign({ value: inputValue, onClick: onToggleClick, onChange: onTextInputChange, onKeyDown: onInputKeyDown, id: "multi-typeahead-product-filter-input", autoComplete: "off", innerRef: textInputRef, placeholder: placeholder }, (activeItem && { 'aria-activedescendant': activeItem }), { role: "combobox", isExpanded: isOpen, "aria-controls": "select-multi-typeahead-product-listbox" })))));
@@ -129,9 +93,6 @@ export function ProductsFilter(props) {
129
93
  }, [inputValue]);
130
94
  useEffect(() => {
131
95
  var _a;
132
- if (isSolrSearchDown) {
133
- return;
134
- }
135
96
  if (isEmpty(filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version])) {
136
97
  setSelectedItems({});
137
98
  }
@@ -142,13 +103,13 @@ export function ProductsFilter(props) {
142
103
  }, {});
143
104
  setSelectedItems(selectedProductItems || {});
144
105
  }
145
- }, [filterInfo, isSolrSearchDown]);
106
+ }, [filterInfo]);
146
107
  const renderOptions = () => {
147
108
  const filteredOptions = getFilteredOptions();
148
- return filteredOptions.map((option, index) => (React.createElement(SelectOption, { key: `product-option-${index}`, value: option, hasCheckbox: !isSolrSearchDown, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-product-${String(option.value).replace(/\s/g, '-')}` }, option.value)));
109
+ return filteredOptions.map((option, index) => (React.createElement(SelectOption, { key: `product-option-${index}`, value: option, hasCheckbox: true, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-product-${String(option.value).replace(/\s/g, '-')}` }, option.value)));
149
110
  };
150
111
  return (React.createElement("div", { className: "product-filter" },
151
112
  React.createElement("label", { htmlFor: "case-list-products-filter", className: "pf-v6-u-mb-sm products-filter-label" }, t(filterNamesMap[SolrKeys.product])),
152
- isSolrSearchDown ? (React.createElement(SingleSelectDropdown, { id: "case-list-products-filter", selected: selectedOption, options: singleSelectOptions, placeholder: allProducts.length > 0 ? t('Select a product') : t('No products available'), onSelect: (options) => onSingleSelectChange(options[0]), dataTrackingId: "products-filter", isScrollable: true, isDisabled: allProducts.length === 0 })) : (React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: "case-list-products-filter", "data-tracking-id": "products-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggleForMultiSelect, isScrollable: true, popperProps: { direction: 'down', enableFlip: false, maxWidth: '30rem' } },
153
- React.createElement(SelectList, null, renderOptions())))));
113
+ React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: "case-list-products-filter", "data-tracking-id": "products-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggleForMultiSelect, isScrollable: true, popperProps: { direction: 'down', enableFlip: false, maxWidth: '30rem' } },
114
+ React.createElement(SelectList, null, renderOptions()))));
154
115
  }
@@ -1,9 +1,6 @@
1
- import { IFacetResponse } from '@rh-support/types/shared';
2
1
  import React from 'react';
3
2
  interface IProps {
4
- filterValues: IFacetResponse[];
5
3
  allCaseSeverities: string[];
6
- isSolrSearchDown: boolean;
7
4
  }
8
5
  export declare function SeverityFilter(props: IProps): React.JSX.Element;
9
6
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"SeverityFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/SeverityFilter.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,KAA0C,MAAM,OAAO,CAAC;AAQ/D,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,qBAoL3C"}
1
+ {"version":3,"file":"SeverityFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/SeverityFilter.tsx"],"names":[],"mappings":"AAYA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAQ/D,UAAU,MAAM;IACZ,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,qBA0I3C"}
@@ -1,5 +1,5 @@
1
1
  import { Button, MenuToggle, Select, SelectList, SelectOption, } from '@patternfly/react-core';
2
- import { SingleSelectDropdown, useSelectKeyboardNavigator } from '@rh-support/components';
2
+ import { useSelectKeyboardNavigator } from '@rh-support/components';
3
3
  import { getDropdownBtnPlaceholder } from '@rh-support/utils';
4
4
  import isEmpty from 'lodash/isEmpty';
5
5
  import React, { useContext, useEffect, useState } from 'react';
@@ -9,56 +9,38 @@ import { filterNamesMap } from '../../../utils/constants';
9
9
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
10
10
  import { updateFilter } from '../CaseListFilterReducer';
11
11
  export function SeverityFilter(props) {
12
- var _a;
13
12
  const { t } = useTranslation();
14
13
  const { filterInfo } = useContext(CaseListFilterStateContext);
15
14
  const dispatch = useContext(CaseListFilterDispatchContext);
16
15
  const [isOpen, setIsOpen] = useState(false);
17
16
  const [selectedItems, setSelectedItems] = useState({});
18
- const list = props.isSolrSearchDown
19
- ? props.allCaseSeverities.map((severity) => ({ value: severity, key: severity }))
20
- : props.filterValues.map((filterValue) => ({ value: filterValue.value, key: filterValue.value }));
21
- const singleSelectOptions = list.map((item) => ({
22
- value: item.value,
23
- label: item.value,
17
+ const list = (props.allCaseSeverities || []).map((severity) => ({
18
+ value: severity,
19
+ key: severity,
24
20
  }));
25
- const selectedSeverity = ((_a = filterInfo[SolrKeys.severity]) === null || _a === void 0 ? void 0 : _a[0]) || '';
26
- const selectedOption = {
27
- value: selectedSeverity,
28
- label: selectedSeverity,
29
- };
30
21
  const onToggleClick = (e) => {
31
22
  setIsOpen(!isOpen);
32
23
  };
33
24
  const onSelect = (option) => {
34
- if (props.isSolrSearchDown) {
35
- updateFilter(dispatch, {
36
- filterKey: SolrKeys.severity,
37
- values: [option.value],
38
- });
39
- setIsOpen(false);
40
- return;
41
- }
42
25
  const prevSelectedSeverities = Object.keys(selectedItems).filter((item) => selectedItems[item] && item);
43
26
  if (selectedItems[option.value]) {
44
27
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
45
- const index = prevSelectedSeverities.indexOf(option.value);
46
- prevSelectedSeverities.splice(index, 1);
28
+ updateFilter(dispatch, {
29
+ filterKey: SolrKeys.severity,
30
+ values: prevSelectedSeverities.filter((item) => item !== option.value),
31
+ });
47
32
  }
48
33
  else {
49
34
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
50
- prevSelectedSeverities.push(option.value);
35
+ updateFilter(dispatch, {
36
+ filterKey: SolrKeys.severity,
37
+ values: [...prevSelectedSeverities, option.value],
38
+ });
51
39
  }
52
- updateFilter(dispatch, {
53
- filterKey: SolrKeys.severity,
54
- values: prevSelectedSeverities,
55
- });
56
40
  };
57
- // Use the keyboard navigator hook
58
41
  const { focusedItemIndex, onInputKeyDown } = useSelectKeyboardNavigator({
59
42
  list,
60
43
  isOpen,
61
- resetIndexOnClose: true,
62
44
  setIsOpen,
63
45
  onSelect,
64
46
  });
@@ -69,25 +51,17 @@ export function SeverityFilter(props) {
69
51
  values: [],
70
52
  });
71
53
  };
72
- const placeholder = props.isSolrSearchDown
73
- ? t('Select a severity')
74
- : getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', list.length, t('All selected'));
54
+ const placeholder = getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', list.length, t('All selected'));
75
55
  const toggle = (toggleRef) => (React.createElement(MenuToggle, { variant: "default", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true, onKeyDown: onInputKeyDown },
76
56
  placeholder,
77
57
  Object.keys(selectedItems).filter((key) => selectedItems[key] === true).length > 0 && (React.createElement(Button, { icon: "", variant: "plain", onClick: onClick, "aria-label": "Clear selection", className: "pf-v6-c-select__toggle-clear" }))));
78
- const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: !props.isSolrSearchDown, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-severity-${option.value.replace(' ', '-')}` }, option.value)));
79
- const onSingleSelectChange = (option) => {
80
- updateFilter(dispatch, {
81
- filterKey: SolrKeys.severity,
82
- values: [option.value],
83
- });
84
- };
58
+ const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: true, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-severity-${option.value.replace(' ', '-')}` }, option.value)));
85
59
  useEffect(() => {
86
60
  var _a;
87
61
  if (isEmpty(filterInfo[SolrKeys.severity])) {
88
62
  setSelectedItems({});
89
63
  }
90
- else if (!props.isSolrSearchDown) {
64
+ else {
91
65
  const selectedSeverities = (_a = filterInfo[SolrKeys.severity]) === null || _a === void 0 ? void 0 : _a.reduce((selection, severity) => {
92
66
  selection[severity] = true;
93
67
  return selection;
@@ -95,9 +69,9 @@ export function SeverityFilter(props) {
95
69
  setSelectedItems(selectedSeverities);
96
70
  }
97
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
98
- }, [filterInfo[SolrKeys.severity], props.isSolrSearchDown]);
72
+ }, [filterInfo[SolrKeys.severity]]);
99
73
  return (React.createElement("div", { className: "severity-filter" },
100
74
  React.createElement("label", { htmlFor: "case-list-severity-filter", className: "pf-v6-u-mb-sm severity-filter-label" }, t(filterNamesMap[SolrKeys.severity])),
101
- props.isSolrSearchDown ? (React.createElement(SingleSelectDropdown, { id: "case-list-severity-filter", selected: selectedOption, options: singleSelectOptions, placeholder: t('Select a severity'), onSelect: onSingleSelectChange, dataTrackingId: "severity-filter", isScrollable: true })) : (React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: "case-list-severity-filter", "data-tracking-id": "severity-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
102
- React.createElement(SelectList, null, dropdownOptions)))));
75
+ React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: "case-list-severity-filter", "data-tracking-id": "severity-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
76
+ React.createElement(SelectList, null, dropdownOptions))));
103
77
  }
@@ -1,8 +1,5 @@
1
- import { IFacetResponse } from '@rh-support/types/shared';
2
1
  import React from 'react';
3
2
  interface IProps {
4
- filterValues: IFacetResponse[];
5
- isSolrSearchDown: boolean;
6
3
  allCaseStatuses: string[];
7
4
  }
8
5
  export interface IStatusFilterOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"StatusFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/StatusFilter.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,qBAkNzC"}
1
+ {"version":3,"file":"StatusFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/StatusFilter.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAQ/D,UAAU,MAAM;IACZ,eAAe,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,qBAqKzC"}