@rh-support/cases 2.6.186 → 2.6.187

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 (134) hide show
  1. package/lib/esm/components/case-list/CaseList.d.ts +0 -7
  2. package/lib/esm/components/case-list/CaseList.d.ts.map +1 -1
  3. package/lib/esm/components/case-list/CaseList.js +195 -113
  4. package/lib/esm/components/case-list/CaseListContext.d.ts.map +1 -1
  5. package/lib/esm/components/case-list/CaseListContext.js +5 -2
  6. package/lib/esm/components/case-list/CaseListFilterContext.d.ts.map +1 -1
  7. package/lib/esm/components/case-list/CaseListFilterContext.js +2 -1
  8. package/lib/esm/components/case-list/CaseListFilterHelpers.d.ts +3 -2
  9. package/lib/esm/components/case-list/CaseListFilterHelpers.d.ts.map +1 -1
  10. package/lib/esm/components/case-list/CaseListFilterHelpers.js +19 -6
  11. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts +35 -4
  12. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts.map +1 -1
  13. package/lib/esm/components/case-list/CaseListFilterReducer.js +4 -12
  14. package/lib/esm/components/case-list/CaseListReducer.d.ts +22 -10
  15. package/lib/esm/components/case-list/CaseListReducer.d.ts.map +1 -1
  16. package/lib/esm/components/case-list/CaseListReducer.js +25 -7
  17. package/lib/esm/components/case-list/case-list-filters/AccountsFilter.d.ts.map +1 -1
  18. package/lib/esm/components/case-list/case-list-filters/AccountsFilter.js +18 -11
  19. package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.d.ts.map +1 -1
  20. package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.js +6 -2
  21. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts +1 -7
  22. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts.map +1 -1
  23. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.js +12 -16
  24. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts +2 -5
  25. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts.map +1 -1
  26. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.js +12 -13
  27. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilterChip.d.ts.map +1 -1
  28. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilterChip.js +3 -0
  29. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.d.ts +11 -1
  30. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.d.ts.map +1 -1
  31. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.js +116 -71
  32. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts +1 -3
  33. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts.map +1 -1
  34. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.js +2 -2
  35. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts +5 -4
  36. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts.map +1 -1
  37. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.js +15 -54
  38. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts +0 -3
  39. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts.map +1 -1
  40. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.js +18 -44
  41. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts +0 -3
  42. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts.map +1 -1
  43. package/lib/esm/components/case-list/case-list-filters/StatusFilter.js +14 -44
  44. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts +1 -3
  45. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts.map +1 -1
  46. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.js +60 -59
  47. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts +7 -3
  48. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts.map +1 -1
  49. package/lib/esm/components/case-list/case-list-table/CaseListTable.js +77 -60
  50. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts +0 -5
  51. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts.map +1 -1
  52. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.js +38 -68
  53. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.d.ts.map +1 -1
  54. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.js +5 -15
  55. package/lib/esm/components/case-list/case-list-table/SeverityLabel.js +1 -1
  56. package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.d.ts.map +1 -1
  57. package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.js +2 -3
  58. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.d.ts +8 -0
  59. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.d.ts.map +1 -0
  60. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.js +8 -0
  61. package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.d.ts.map +1 -1
  62. package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.js +1 -0
  63. package/lib/esm/components/case-list/case-search/CaseSearch.d.ts.map +1 -1
  64. package/lib/esm/components/case-list/case-search/CaseSearch.js +55 -24
  65. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.d.ts +10 -0
  66. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.d.ts.map +1 -0
  67. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.js +29 -0
  68. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.d.ts +10 -0
  69. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.d.ts.map +1 -0
  70. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.js +16 -0
  71. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts +9 -0
  72. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts.map +1 -0
  73. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.js +21 -0
  74. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.d.ts +12 -0
  75. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.d.ts.map +1 -0
  76. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.js +31 -0
  77. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts +10 -0
  78. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts.map +1 -0
  79. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.js +10 -0
  80. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts +10 -0
  81. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts.map +1 -0
  82. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.js +92 -0
  83. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts +9 -0
  84. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts.map +1 -0
  85. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.js +20 -0
  86. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.d.ts +9 -0
  87. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.d.ts.map +1 -0
  88. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.js +28 -0
  89. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.d.ts +9 -0
  90. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.d.ts.map +1 -0
  91. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.js +241 -0
  92. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts +11 -0
  93. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts.map +1 -0
  94. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.js +23 -0
  95. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.d.ts.map +1 -1
  96. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.js +2 -1
  97. package/lib/esm/css/caseList.css +111 -22
  98. package/lib/esm/css/caseSearch.css +114 -0
  99. package/lib/esm/enums/case.d.ts +2 -1
  100. package/lib/esm/enums/case.d.ts.map +1 -1
  101. package/lib/esm/enums/case.js +14 -1
  102. package/lib/esm/enums/caseSearch.d.ts +1 -0
  103. package/lib/esm/enums/caseSearch.d.ts.map +1 -1
  104. package/lib/esm/enums/caseSearch.js +1 -1
  105. package/lib/esm/hooks/useExportCaseListCSV.d.ts.map +1 -1
  106. package/lib/esm/hooks/useExportCaseListCSV.js +1 -9
  107. package/lib/esm/hooks/useFilterStateOnLoad.d.ts +1 -1
  108. package/lib/esm/hooks/useFilterStateOnLoad.d.ts.map +1 -1
  109. package/lib/esm/test-utils/mockData.js +1 -1
  110. package/lib/esm/utils/advanceSearchFormMapper.d.ts +11 -0
  111. package/lib/esm/utils/advanceSearchFormMapper.d.ts.map +1 -0
  112. package/lib/esm/utils/advanceSearchFormMapper.js +71 -0
  113. package/lib/esm/utils/advanceSearchUtils.d.ts +24 -0
  114. package/lib/esm/utils/advanceSearchUtils.d.ts.map +1 -0
  115. package/lib/esm/utils/advanceSearchUtils.js +149 -0
  116. package/lib/esm/utils/caseListGraphQLUtils.d.ts +28 -0
  117. package/lib/esm/utils/caseListGraphQLUtils.d.ts.map +1 -0
  118. package/lib/esm/utils/caseListGraphQLUtils.js +280 -0
  119. package/lib/esm/utils/caseListMapper.d.ts +6 -0
  120. package/lib/esm/utils/caseListMapper.d.ts.map +1 -0
  121. package/lib/esm/utils/caseListMapper.js +36 -0
  122. package/lib/esm/utils/caseListVariablesBuilder.d.ts +15 -0
  123. package/lib/esm/utils/caseListVariablesBuilder.d.ts.map +1 -0
  124. package/lib/esm/utils/caseListVariablesBuilder.js +399 -0
  125. package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
  126. package/lib/esm/utils/caseSearchUtils.js +26 -1
  127. package/lib/esm/utils/constants.d.ts +4 -1
  128. package/lib/esm/utils/constants.d.ts.map +1 -1
  129. package/lib/esm/utils/constants.js +20 -2
  130. package/lib/esm/utils/mockSolrResponse.js +1 -1
  131. package/lib/esm/utils/statusUtils.d.ts +4 -0
  132. package/lib/esm/utils/statusUtils.d.ts.map +1 -0
  133. package/lib/esm/utils/statusUtils.js +36 -0
  134. package/package.json +8 -8
@@ -1,8 +1,8 @@
1
- import { Button, MenuFooter, MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, } from '@patternfly/react-core';
1
+ import { useApolloClient } from '@apollo/client/react';
2
+ import { Badge, Button, MenuFooter, MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, } from '@patternfly/react-core';
2
3
  import TimesIcon from '@patternfly/react-icons/dist/js/icons/times-icon';
3
- import { GlobalMetadataStateContext } from '@rh-support/react-context';
4
4
  import { ability, resourceActions, resources } from '@rh-support/user-permissions';
5
- import { getDropdownBtnPlaceholder } from '@rh-support/utils';
5
+ import { GET_CASE_GROUP, getDropdownBtnPlaceholder, handleGraphQLCaseGroupsResponse, } from '@rh-support/utils';
6
6
  import isEmpty from 'lodash/isEmpty';
7
7
  import isUndefined from 'lodash/isUndefined';
8
8
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
@@ -12,83 +12,125 @@ 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;
16
18
  const { t } = useTranslation();
17
- const { globalMetadataState: { caseGroups }, } = useContext(GlobalMetadataStateContext);
19
+ const apolloClient = useApolloClient();
18
20
  const { filterInfo } = useContext(CaseListFilterStateContext);
19
21
  const dispatch = useContext(CaseListFilterDispatchContext);
22
+ const isControlled = typeof onGroupsChange === 'function';
23
+ // Prefer the filterInfo array reference in basic/uncontrolled mode so empty selection
24
+ // does not create a new [] each render and re-fire the selectedItems sync effect.
25
+ const selectedGroups = isControlled
26
+ ? controlledSelectedGroups || EMPTY_GROUPS
27
+ : (_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.group]) !== null && _a !== void 0 ? _a : EMPTY_GROUPS;
20
28
  const [inputValue, setInputValue] = useState('');
29
+ const [caseGroups, setCaseGroups] = useState([]);
30
+ const [isLoading, setIsLoading] = useState(false);
21
31
  const [focusedItemIndex, setFocusedItemIndex] = useState(null);
22
32
  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
- ];
33
+ useEffect(() => {
34
+ setIsLoading(true);
35
+ apolloClient
36
+ .query({
37
+ query: GET_CASE_GROUP,
38
+ fetchPolicy: 'cache-first',
39
+ })
40
+ .then(({ data }) => {
41
+ var _a, _b, _c, _d;
42
+ const edges = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.salesforce_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.SalesforceSupportCaseGroup__c) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
43
+ setCaseGroups(handleGraphQLCaseGroupsResponse(edges));
44
+ })
45
+ .catch((err) => {
46
+ console.error('[GroupsFilter] Failed to fetch case groups:', err);
47
+ setCaseGroups([]);
48
+ })
49
+ .finally(() => setIsLoading(false));
50
+ // eslint-disable-next-line react-hooks/exhaustive-deps
51
+ }, []);
52
+ const list = useMemo(() => caseGroups.map((group) => ({ value: group.name, key: group.groupNum })), [caseGroups]);
26
53
  const [selectOptions, setSelectOptions] = useState(list);
27
54
  const canViewManageTab = ability.can(resourceActions.READ, resources.MANAGE);
28
55
  const canViewCaseGroups = ability.can(resourceActions.READ, resources.CASE_GROUPS) && canViewManageTab;
29
56
  const [isOpen, setIsOpen] = useState(false);
30
57
  const [selectedItems, setSelectedItems] = useState({});
31
58
  const textInputRef = useRef();
32
- const onToggleClick = (e) => {
59
+ const applyGroupSelection = (updatedFilterValues) => {
60
+ if (isControlled) {
61
+ onGroupsChange(updatedFilterValues);
62
+ return;
63
+ }
64
+ updateFilter(dispatch, {
65
+ filterKey: SolrKeys.group,
66
+ values: updatedFilterValues,
67
+ });
68
+ };
69
+ const onToggleClick = () => {
33
70
  setIsOpen(!isOpen);
34
71
  };
35
72
  const onSelect = (option) => {
73
+ const optionValue = typeof option === 'string' ? option : option === null || option === void 0 ? void 0 : option.value;
74
+ if (!optionValue || optionValue === 'no results') {
75
+ return;
76
+ }
36
77
  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);
78
+ if (selectedItems[optionValue]) {
79
+ setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [optionValue]: !prevData[optionValue] })));
80
+ const indexOfGroup = prevSelectedGroups.indexOf(optionValue);
40
81
  prevSelectedGroups.splice(indexOfGroup, 1);
41
82
  }
42
83
  else {
43
- setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
44
- prevSelectedGroups.push(option.value);
84
+ setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [optionValue]: true })));
85
+ prevSelectedGroups.push(optionValue);
45
86
  }
46
- const mapValueToKey = (value) => {
87
+ const updatedFilterValues = prevSelectedGroups
88
+ .map((value) => {
47
89
  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
- });
90
+ if (!(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.key)) {
91
+ return null;
92
+ }
93
+ return { key: String(selectedItem.key), value: String(selectedItem.value) };
94
+ })
95
+ .filter(Boolean);
96
+ applyGroupSelection(updatedFilterValues);
55
97
  };
56
98
  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
- }
99
+ if (!isOpen || !list.length) {
100
+ return;
101
+ }
102
+ let indexToFocus = 0;
103
+ if (key === 'ArrowUp') {
104
+ if (focusedItemIndex === null || focusedItemIndex === 0) {
105
+ indexToFocus = list.length - 1;
67
106
  }
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
- }
107
+ else {
108
+ indexToFocus = focusedItemIndex - 1;
76
109
  }
77
- setFocusedItemIndex(indexToFocus);
78
- const focusedItem = list[indexToFocus];
79
- setActiveItem(`select-multi-typeahead-checkbox-${focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.value.replace(' ', '-')}`);
110
+ }
111
+ if (key === 'ArrowDown') {
112
+ if (focusedItemIndex === null || focusedItemIndex === list.length - 1) {
113
+ indexToFocus = 0;
114
+ }
115
+ else {
116
+ indexToFocus = focusedItemIndex + 1;
117
+ }
118
+ }
119
+ setFocusedItemIndex(indexToFocus);
120
+ const focusedItem = list[indexToFocus];
121
+ if (focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.value) {
122
+ setActiveItem(`select-multi-typeahead-checkbox-${String(focusedItem.value).replace(' ', '-')}`);
80
123
  }
81
124
  };
82
125
  const onInputKeyDown = (event) => {
83
- const focusedItem = focusedItemIndex ? list[focusedItemIndex] : list[0];
126
+ const focusedItem = focusedItemIndex !== null ? list[focusedItemIndex] : list[0];
84
127
  switch (event.key) {
85
- // Select the first available option
86
128
  case 'Enter':
87
129
  if (!isOpen) {
88
130
  setIsOpen((prevIsOpen) => !prevIsOpen);
89
131
  }
90
132
  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);
133
+ onSelect(focusedItem);
92
134
  }
93
135
  break;
94
136
  case 'Tab':
@@ -106,36 +148,37 @@ export function GroupsFilter() {
106
148
  const onTextInputChange = (_event, value) => {
107
149
  setInputValue(value);
108
150
  };
109
- const placeholder = getDropdownBtnPlaceholder(t('Select a group'), filterInfo[SolrKeys.group], '', (caseGroups.data || []).length, t('All selected'));
151
+ const defaultEmptyPlaceholder = placeholderProp || t('Select a group');
152
+ const placeholder = showSelectionCountBadge
153
+ ? isLoading
154
+ ? t('Loading...')
155
+ : defaultEmptyPlaceholder
156
+ : getDropdownBtnPlaceholder(isLoading ? t('Loading...') : defaultEmptyPlaceholder, selectedGroups, '', caseGroups.length, t('All selected'));
157
+ const hasSelectedGroups = selectedGroups.length > 0;
110
158
  const onClick = () => {
111
159
  var _a;
112
160
  setInputValue('');
113
161
  setSelectedItems({});
114
- updateFilter(dispatch, {
115
- filterKey: SolrKeys.group,
116
- values: [],
117
- });
162
+ applyGroupSelection([]);
118
163
  (_a = textInputRef === null || textInputRef === void 0 ? void 0 : textInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
119
164
  };
120
165
  const toggle = (toggleRef) => (React.createElement(MenuToggle, { variant: "typeahead", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true },
121
166
  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" }))) : (''))));
167
+ 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` })),
168
+ hasSelectedGroups ? (React.createElement(TextInputGroupUtilities, null,
169
+ showSelectionCountBadge && (React.createElement(Badge, { className: "advance-search-dropdown-toggle-badge pf-v6-u-mr-sm" }, t('{{count}} selected', { count: selectedGroups.length }))),
170
+ React.createElement(Button, { icon: React.createElement(TimesIcon, { "aria-hidden": true }), variant: "plain", onClick: onClick, "aria-label": t('Clear input value') }))) : null)));
125
171
  const dropdownOptions = useMemo(() => {
126
172
  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
173
  // eslint-disable-next-line react-hooks/exhaustive-deps
128
- }, [selectedItems, caseGroups === null || caseGroups === void 0 ? void 0 : caseGroups.data, selectOptions, focusedItemIndex]);
174
+ }, [selectedItems, caseGroups, selectOptions, focusedItemIndex]);
129
175
  useEffect(() => {
130
176
  let newSelectOptions = list;
131
- // Filter menu items based on the text input value when one exists
132
177
  if (inputValue) {
133
178
  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
179
  if (!newSelectOptions.length) {
136
180
  newSelectOptions = [{ isDisabled: false, children: `No results found` }];
137
181
  }
138
- // Open the menu when the input value changes and the new value is not empty
139
182
  if (!isOpen) {
140
183
  setIsOpen(true);
141
184
  }
@@ -146,27 +189,29 @@ export function GroupsFilter() {
146
189
  // eslint-disable-next-line react-hooks/exhaustive-deps
147
190
  }, [inputValue]);
148
191
  useEffect(() => {
149
- var _a;
150
- if (isEmpty(filterInfo[SolrKeys.group])) {
192
+ if (!inputValue) {
193
+ setSelectOptions(list);
194
+ }
195
+ }, [list, inputValue]);
196
+ useEffect(() => {
197
+ if (isEmpty(selectedGroups)) {
151
198
  setSelectedItems({});
152
199
  }
153
200
  else {
154
- const selectedGroups = (_a = filterInfo[SolrKeys.group]) === null || _a === void 0 ? void 0 : _a.reduce((selection, group) => {
201
+ const nextSelectedItems = selectedGroups.reduce((selection, group) => {
155
202
  selection[group === null || group === void 0 ? void 0 : group.value] = true;
156
203
  return selection;
157
204
  }, {});
158
- setSelectedItems(selectedGroups);
205
+ setSelectedItems(nextSelectedItems);
159
206
  }
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])),
207
+ }, [selectedGroups]);
208
+ return (React.createElement("div", { className: "group-filter", "data-testid": "groups-filter" },
209
+ !hideLabel && (React.createElement("label", { htmlFor: idPrefix, className: "pf-v6-u-mb-sm group-filter-label" }, t(filterNamesMap[SolrKeys.group]))),
164
210
  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 },
211
+ 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
212
  React.createElement(SelectList, null,
167
213
  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"))))))))));
214
+ canViewCaseGroups && (React.createElement(MenuFooter, { className: "group-filter-manage-groups-footer" },
215
+ React.createElement(Link, { className: "cta cta-link", to: "/manage/groups" },
216
+ React.createElement(Trans, null, "Manage groups")))))))));
172
217
  }
@@ -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"}