@rh-support/cases 2.6.218 → 2.6.227

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 (153) hide show
  1. package/lib/esm/components/case/NewCaseButton.js +1 -1
  2. package/lib/esm/components/case-list/CaseList.d.ts +7 -0
  3. package/lib/esm/components/case-list/CaseList.d.ts.map +1 -1
  4. package/lib/esm/components/case-list/CaseList.js +135 -366
  5. package/lib/esm/components/case-list/CaseListContext.d.ts.map +1 -1
  6. package/lib/esm/components/case-list/CaseListContext.js +2 -5
  7. package/lib/esm/components/case-list/CaseListFilterContext.d.ts.map +1 -1
  8. package/lib/esm/components/case-list/CaseListFilterContext.js +1 -2
  9. package/lib/esm/components/case-list/CaseListFilterHelpers.d.ts +2 -3
  10. package/lib/esm/components/case-list/CaseListFilterHelpers.d.ts.map +1 -1
  11. package/lib/esm/components/case-list/CaseListFilterHelpers.js +6 -19
  12. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts +4 -36
  13. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts.map +1 -1
  14. package/lib/esm/components/case-list/CaseListFilterReducer.js +12 -6
  15. package/lib/esm/components/case-list/CaseListReducer.d.ts +10 -22
  16. package/lib/esm/components/case-list/CaseListReducer.d.ts.map +1 -1
  17. package/lib/esm/components/case-list/CaseListReducer.js +7 -25
  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 +11 -18
  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 +2 -6
  22. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts +7 -1
  23. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts.map +1 -1
  24. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.js +16 -12
  25. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts +5 -2
  26. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts.map +1 -1
  27. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.js +13 -14
  28. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilter.d.ts.map +1 -1
  29. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilter.js +14 -21
  30. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilterChip.d.ts.map +1 -1
  31. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilterChip.js +0 -3
  32. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.d.ts +1 -11
  33. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.d.ts.map +1 -1
  34. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.js +70 -90
  35. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts +3 -1
  36. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts.map +1 -1
  37. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.js +2 -2
  38. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts +4 -5
  39. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts.map +1 -1
  40. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.js +54 -15
  41. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts +3 -0
  42. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts.map +1 -1
  43. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.js +44 -18
  44. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts +3 -0
  45. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts.map +1 -1
  46. package/lib/esm/components/case-list/case-list-filters/StatusFilter.js +44 -14
  47. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts +3 -1
  48. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts.map +1 -1
  49. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.js +59 -60
  50. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts +3 -8
  51. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts.map +1 -1
  52. package/lib/esm/components/case-list/case-list-table/CaseListTable.js +61 -77
  53. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts +5 -0
  54. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts.map +1 -1
  55. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.js +70 -42
  56. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.d.ts.map +1 -1
  57. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.js +15 -5
  58. package/lib/esm/components/case-list/case-list-table/SeverityLabel.js +1 -1
  59. package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.d.ts.map +1 -1
  60. package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.js +3 -2
  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 +0 -1
  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 +24 -55
  65. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.d.ts.map +1 -1
  66. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.js +1 -2
  67. package/lib/esm/css/caseList.css +22 -111
  68. package/lib/esm/css/caseSearch.css +0 -114
  69. package/lib/esm/enums/case.d.ts +4 -10
  70. package/lib/esm/enums/case.d.ts.map +1 -1
  71. package/lib/esm/enums/case.js +3 -21
  72. package/lib/esm/enums/caseSearch.d.ts +0 -3
  73. package/lib/esm/enums/caseSearch.d.ts.map +1 -1
  74. package/lib/esm/enums/caseSearch.js +1 -2
  75. package/lib/esm/enums/filters.d.ts +1 -3
  76. package/lib/esm/enums/filters.d.ts.map +1 -1
  77. package/lib/esm/enums/filters.js +0 -2
  78. package/lib/esm/hooks/useCloseCase.d.ts.map +1 -1
  79. package/lib/esm/hooks/useCloseCase.js +21 -38
  80. package/lib/esm/hooks/useExportCaseListCSV.d.ts.map +1 -1
  81. package/lib/esm/hooks/useExportCaseListCSV.js +9 -1
  82. package/lib/esm/hooks/useFilterStateOnLoad.d.ts +1 -1
  83. package/lib/esm/hooks/useFilterStateOnLoad.d.ts.map +1 -1
  84. package/lib/esm/hooks/useFilterStateOnLoad.js +5 -7
  85. package/lib/esm/index.js +0 -1
  86. package/lib/esm/test-utils/mockData.js +1 -1
  87. package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
  88. package/lib/esm/utils/caseSearchUtils.js +2 -39
  89. package/lib/esm/utils/constants.d.ts +1 -5
  90. package/lib/esm/utils/constants.d.ts.map +1 -1
  91. package/lib/esm/utils/constants.js +2 -10
  92. package/lib/esm/utils/mockSolrResponse.js +1 -1
  93. package/package.json +8 -10
  94. package/lib/esm/components/case-list/case-list-filters/CaseLabelsFilter.d.ts +0 -3
  95. package/lib/esm/components/case-list/case-list-filters/CaseLabelsFilter.d.ts.map +0 -1
  96. package/lib/esm/components/case-list/case-list-filters/CaseLabelsFilter.js +0 -177
  97. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.d.ts +0 -8
  98. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.d.ts.map +0 -1
  99. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.js +0 -8
  100. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.d.ts +0 -10
  101. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.d.ts.map +0 -1
  102. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.js +0 -29
  103. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.d.ts +0 -10
  104. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.d.ts.map +0 -1
  105. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.js +0 -16
  106. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts +0 -9
  107. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts.map +0 -1
  108. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.js +0 -21
  109. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.d.ts +0 -12
  110. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.d.ts.map +0 -1
  111. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.js +0 -31
  112. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts +0 -10
  113. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts.map +0 -1
  114. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.js +0 -10
  115. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts +0 -10
  116. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts.map +0 -1
  117. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.js +0 -92
  118. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts +0 -9
  119. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts.map +0 -1
  120. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.js +0 -20
  121. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.d.ts +0 -9
  122. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.d.ts.map +0 -1
  123. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.js +0 -28
  124. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.d.ts +0 -9
  125. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.d.ts.map +0 -1
  126. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.js +0 -241
  127. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts +0 -11
  128. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts.map +0 -1
  129. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.js +0 -23
  130. package/lib/esm/hooks/useCaseLabels.d.ts +0 -14
  131. package/lib/esm/hooks/useCaseLabels.d.ts.map +0 -1
  132. package/lib/esm/hooks/useCaseLabels.js +0 -55
  133. package/lib/esm/utils/advanceSearchFormMapper.d.ts +0 -11
  134. package/lib/esm/utils/advanceSearchFormMapper.d.ts.map +0 -1
  135. package/lib/esm/utils/advanceSearchFormMapper.js +0 -71
  136. package/lib/esm/utils/advanceSearchUtils.d.ts +0 -24
  137. package/lib/esm/utils/advanceSearchUtils.d.ts.map +0 -1
  138. package/lib/esm/utils/advanceSearchUtils.js +0 -150
  139. package/lib/esm/utils/caseGroupDefaultFilterUtils.d.ts +0 -12
  140. package/lib/esm/utils/caseGroupDefaultFilterUtils.d.ts.map +0 -1
  141. package/lib/esm/utils/caseGroupDefaultFilterUtils.js +0 -34
  142. package/lib/esm/utils/caseGroupDefaultUtils.d.ts +0 -10
  143. package/lib/esm/utils/caseGroupDefaultUtils.d.ts.map +0 -1
  144. package/lib/esm/utils/caseGroupDefaultUtils.js +0 -20
  145. package/lib/esm/utils/caseListGraphQLUtils.d.ts +0 -28
  146. package/lib/esm/utils/caseListGraphQLUtils.d.ts.map +0 -1
  147. package/lib/esm/utils/caseListGraphQLUtils.js +0 -280
  148. package/lib/esm/utils/caseListMapper.d.ts +0 -6
  149. package/lib/esm/utils/caseListMapper.d.ts.map +0 -1
  150. package/lib/esm/utils/caseListMapper.js +0 -37
  151. package/lib/esm/utils/caseListVariablesBuilder.d.ts +0 -15
  152. package/lib/esm/utils/caseListVariablesBuilder.d.ts.map +0 -1
  153. package/lib/esm/utils/caseListVariablesBuilder.js +0 -517
@@ -1,241 +0,0 @@
1
- import { useApolloClient } from '@apollo/client/react';
2
- import { Badge, Divider, DrilldownMenu, Flex, FlexItem, Menu, MenuContainer, MenuContent, MenuItem, MenuList, MenuToggle, SearchInput, Spinner, } from '@patternfly/react-core';
3
- import { GlobalMetadataStateContext } from '@rh-support/react-context';
4
- import { compareVersions, GET_PRODUCTS, handleGraphQLVersionsResponse } from '@rh-support/utils';
5
- import React, { useContext, useMemo, useRef, useState } from 'react';
6
- import { useTranslation } from 'react-i18next';
7
- import { SolrKeys } from '../../../../enums/filters';
8
- const ROOT_MENU_ID = 'advance-search-product-version-root';
9
- export function ProductVersionDrilldownSelect({ products, onChange }) {
10
- var _a;
11
- const { t } = useTranslation();
12
- const apolloClient = useApolloClient();
13
- const { globalMetadataState: { allProducts }, } = useContext(GlobalMetadataStateContext);
14
- const [isOpen, setIsOpen] = useState(false);
15
- const [productSearch, setProductSearch] = useState('');
16
- const [menuDrilledIn, setMenuDrilledIn] = useState([]);
17
- const [drilldownPath, setDrilldownPath] = useState([]);
18
- const [activeMenu, setActiveMenu] = useState(ROOT_MENU_ID);
19
- const [menuHeights, setMenuHeights] = useState({});
20
- const [versionsByProductId, setVersionsByProductId] = useState({});
21
- const [loadingProductIds, setLoadingProductIds] = useState({});
22
- const toggleRef = useRef(null);
23
- const menuRef = useRef(null);
24
- const productOptions = useMemo(() => {
25
- var _a, _b;
26
- return ((_b = (_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult) === null || _b === void 0 ? void 0 : _b.map((product) => ({
27
- name: product.product || product.name || '',
28
- productId: product.productId || '',
29
- }))) || [];
30
- }, [(_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult]);
31
- const filteredProducts = useMemo(() => {
32
- if (!productSearch.trim()) {
33
- return productOptions;
34
- }
35
- const formattedValue = productSearch.replace(/\\/g, '');
36
- const searchPattern = new RegExp(formattedValue, 'i');
37
- return productOptions.filter((product) => searchPattern.test(product.name));
38
- }, [productOptions, productSearch]);
39
- const selectedFilterCount = useMemo(() => products.reduce((count, product) => {
40
- const versions = product[SolrKeys.version] || [];
41
- return count + (versions.length > 0 ? versions.length : 1);
42
- }, 0), [products]);
43
- const resetDrilldownState = () => {
44
- setMenuDrilledIn([]);
45
- setDrilldownPath([]);
46
- setActiveMenu(ROOT_MENU_ID);
47
- setProductSearch('');
48
- setMenuHeights({});
49
- };
50
- const handleOpenChange = (open) => {
51
- setIsOpen(open);
52
- if (!open) {
53
- resetDrilldownState();
54
- }
55
- };
56
- const setHeight = (menuId, height) => {
57
- setMenuHeights((previousHeights) => {
58
- if (previousHeights[menuId] === undefined ||
59
- (menuId !== ROOT_MENU_ID && previousHeights[menuId] !== height)) {
60
- return Object.assign(Object.assign({}, previousHeights), { [menuId]: height });
61
- }
62
- return previousHeights;
63
- });
64
- };
65
- const updateMenuHeight = (menuId) => {
66
- requestAnimationFrame(() => {
67
- var _a;
68
- const menuContent = (_a = document.getElementById(menuId)) === null || _a === void 0 ? void 0 : _a.querySelector('.pf-v6-c-menu__content');
69
- if (menuContent instanceof HTMLElement) {
70
- setHeight(menuId, menuContent.clientHeight);
71
- }
72
- });
73
- };
74
- const drillIn = (_event, fromMenuId, toMenuId, pathId) => {
75
- setMenuDrilledIn((previousMenus) => [...previousMenus, fromMenuId]);
76
- setDrilldownPath((previousPath) => [...previousPath, pathId]);
77
- setActiveMenu(toMenuId);
78
- const productId = pathId.replace('product-', '');
79
- const product = productOptions.find((item) => item.productId === productId);
80
- if (product) {
81
- fetchVersionsForProduct(product);
82
- }
83
- };
84
- const drillOut = (_event, toMenuId) => {
85
- setMenuDrilledIn((previousMenus) => previousMenus.slice(0, -1));
86
- setDrilldownPath((previousPath) => previousPath.slice(0, -1));
87
- setActiveMenu(toMenuId);
88
- };
89
- const fetchVersionsForProduct = (product) => {
90
- if (!product.productId || versionsByProductId[product.productId] || loadingProductIds[product.productId]) {
91
- return;
92
- }
93
- setLoadingProductIds((previousState) => (Object.assign(Object.assign({}, previousState), { [product.productId]: true })));
94
- apolloClient
95
- .query({
96
- query: GET_PRODUCTS,
97
- variables: {
98
- where: { ParentProduct__c: { eq: product.productId }, IsActive: { eq: true } },
99
- first: 200,
100
- orderBy: { Name: { order: 'ASC' } },
101
- },
102
- fetchPolicy: 'cache-first',
103
- })
104
- .then(({ data }) => {
105
- var _a, _b, _c, _d;
106
- const edges = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportProduct2) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
107
- const versionData = handleGraphQLVersionsResponse(edges, product.name);
108
- const sortedVersions = [...versionData].sort((versionA, versionB) => compareVersions(versionA.name, versionB.name));
109
- setVersionsByProductId((previousState) => (Object.assign(Object.assign({}, previousState), { [product.productId]: sortedVersions })));
110
- updateMenuHeight(`versions-menu-${product.productId}`);
111
- })
112
- .catch((error) => {
113
- console.error('[ProductVersionDrilldownSelect] Failed to fetch versions:', error);
114
- setVersionsByProductId((previousState) => (Object.assign(Object.assign({}, previousState), { [product.productId]: [] })));
115
- updateMenuHeight(`versions-menu-${product.productId}`);
116
- })
117
- .finally(() => {
118
- setLoadingProductIds((previousState) => (Object.assign(Object.assign({}, previousState), { [product.productId]: false })));
119
- });
120
- };
121
- const getProductAppliedFilterCount = (product) => {
122
- const selectedProduct = products.find((item) => item.value === product.name);
123
- if (!selectedProduct) {
124
- return 0;
125
- }
126
- const versions = selectedProduct[SolrKeys.version] || [];
127
- return versions.length > 0 ? versions.length : 1;
128
- };
129
- const isProductOnlySelected = (product) => {
130
- var _a;
131
- const selectedProduct = products.find((item) => item.value === product.name);
132
- return !!selectedProduct && !((_a = selectedProduct[SolrKeys.version]) === null || _a === void 0 ? void 0 : _a.length);
133
- };
134
- const toggleProductOnlySelection = (product) => {
135
- var _a;
136
- const productIndex = products.findIndex((item) => item.value === product.name);
137
- if (productIndex === -1) {
138
- onChange([
139
- ...products,
140
- {
141
- field: SolrKeys.product,
142
- value: product.name,
143
- productId: product.productId,
144
- [SolrKeys.version]: [],
145
- },
146
- ]);
147
- return;
148
- }
149
- const currentProduct = products[productIndex];
150
- const hasVersions = (((_a = currentProduct[SolrKeys.version]) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0;
151
- if (!hasVersions) {
152
- onChange(products.filter((_, index) => index !== productIndex));
153
- return;
154
- }
155
- const nextProducts = [...products];
156
- nextProducts[productIndex] = Object.assign(Object.assign({}, currentProduct), { [SolrKeys.version]: [] });
157
- onChange(nextProducts);
158
- };
159
- const isVersionSelected = (productName, versionName) => {
160
- var _a, _b;
161
- const selectedProduct = products.find((product) => product.value === productName);
162
- return (_b = (_a = selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct[SolrKeys.version]) === null || _a === void 0 ? void 0 : _a.some((version) => version.value === versionName)) !== null && _b !== void 0 ? _b : false;
163
- };
164
- const toggleVersionSelection = (product, version) => {
165
- const nextProducts = [...products];
166
- const productIndex = nextProducts.findIndex((item) => item.value === product.name);
167
- if (productIndex === -1) {
168
- onChange([
169
- ...nextProducts,
170
- {
171
- field: SolrKeys.product,
172
- value: product.name,
173
- productId: product.productId,
174
- [SolrKeys.version]: [
175
- {
176
- field: SolrKeys.version,
177
- value: version.name,
178
- productId: version.id,
179
- },
180
- ],
181
- },
182
- ]);
183
- return;
184
- }
185
- const currentProduct = nextProducts[productIndex];
186
- const currentVersions = currentProduct[SolrKeys.version] || [];
187
- const versionIndex = currentVersions.findIndex((item) => item.value === version.name);
188
- const nextVersions = versionIndex >= 0
189
- ? currentVersions.filter((_, index) => index !== versionIndex)
190
- : [
191
- ...currentVersions,
192
- {
193
- field: SolrKeys.version,
194
- value: version.name,
195
- productId: version.id,
196
- },
197
- ];
198
- if (nextVersions.length === 0) {
199
- onChange(nextProducts.filter((_, index) => index !== productIndex));
200
- return;
201
- }
202
- nextProducts[productIndex] = Object.assign(Object.assign({}, currentProduct), { [SolrKeys.version]: nextVersions });
203
- onChange(nextProducts);
204
- };
205
- const renderVersionItems = (product) => {
206
- const versions = versionsByProductId[product.productId];
207
- const isLoading = loadingProductIds[product.productId];
208
- if (isLoading || versions === undefined) {
209
- return (React.createElement(MenuItem, { itemId: `loading-${product.productId}`, isDisabled: true },
210
- React.createElement(Spinner, { size: "sm", "aria-label": t('Loading versions') }),
211
- " ",
212
- t('Loading...')));
213
- }
214
- if (!versions.length) {
215
- return (React.createElement(MenuItem, { itemId: `no-versions-${product.productId}`, isDisabled: true }, t('No versions found')));
216
- }
217
- return versions.map((version) => (React.createElement(MenuItem, { key: `${product.productId}-${version.name}`, itemId: `version-${product.productId}-${version.name}`, hasCheckbox: true, isSelected: isVersionSelected(product.name, version.name), onClick: () => toggleVersionSelection(product, version) }, version.name)));
218
- };
219
- const renderProductDrilldownMenu = (product) => (React.createElement(DrilldownMenu, { id: `versions-menu-${product.productId}` },
220
- React.createElement(MenuItem, { itemId: `breadcrumb-${product.productId}`, direction: "up" }, product.name),
221
- React.createElement(Divider, { component: "li" }),
222
- React.createElement(MenuItem, { itemId: `product-only-${product.productId}`, hasCheckbox: true, isSelected: isProductOnlySelected(product), onClick: () => toggleProductOnlySelection(product) }, t('Entire product')),
223
- React.createElement(Divider, { component: "li" }),
224
- renderVersionItems(product)));
225
- const toggleLabel = t('Select Product & version');
226
- const isRootMenuActive = activeMenu === ROOT_MENU_ID;
227
- return (React.createElement(MenuContainer, { isOpen: isOpen, onOpenChange: handleOpenChange, menuRef: menuRef, toggleRef: toggleRef, popperProps: { direction: 'down', enableFlip: false, width: 'trigger' }, toggle: React.createElement(MenuToggle, { ref: toggleRef, onClick: () => handleOpenChange(!isOpen), isExpanded: isOpen, isFullWidth: true, "aria-label": t('Select Product & version') },
228
- React.createElement(Flex, { alignItems: { default: 'alignItemsCenter' }, justifyContent: { default: 'justifyContentSpaceBetween' }, className: "pf-v6-u-w-100 advance-search-dropdown-toggle-content" },
229
- React.createElement(FlexItem, { className: "pf-v6-u-text-align-left" }, toggleLabel),
230
- selectedFilterCount > 0 ? (React.createElement(FlexItem, { className: "advance-search-dropdown-toggle-badge-wrap" },
231
- React.createElement(Badge, { className: "advance-search-dropdown-toggle-badge" }, t('{{count}} selected', { count: selectedFilterCount })))) : null)), menu: React.createElement(Menu, { id: ROOT_MENU_ID, ref: menuRef, containsDrilldown: true, drilldownItemPath: drilldownPath, drilledInMenus: menuDrilledIn, activeMenu: activeMenu, onDrillIn: drillIn, onDrillOut: drillOut, onGetMenuHeight: setHeight, isScrollable: true, "data-tracking-id": "advance-search-product-version-drilldown" },
232
- React.createElement(MenuContent, { menuHeight: `${menuHeights[activeMenu]}px` },
233
- !isRootMenuActive ? null : (React.createElement("div", { className: "advance-search-product-version-search pf-v6-u-p-sm", onMouseDown: (event) => event.stopPropagation() },
234
- React.createElement(SearchInput, { placeholder: t('Find product by name'), value: productSearch, onChange: (_event, value) => setProductSearch(value), onClear: () => setProductSearch(''), "aria-label": t('Find product by name') }))),
235
- React.createElement(MenuList, null, filteredProducts.length === 0 ? (React.createElement(MenuItem, { itemId: "no-products-found", isDisabled: true }, t('No results found'))) : (filteredProducts.map((product) => {
236
- const productAppliedCount = getProductAppliedFilterCount(product);
237
- return (React.createElement(MenuItem, { key: product.productId, itemId: `product-${product.productId}`, direction: "down", actions: productAppliedCount > 0 ? (React.createElement(Badge, { className: "advance-search-product-menu-item-badge pf-v6-u-mx-sm", "aria-label": t('{{count}} filters applied', {
238
- count: productAppliedCount,
239
- }) }, productAppliedCount)) : undefined, drilldownMenu: renderProductDrilldownMenu(product) }, product.name));
240
- }))))) }));
241
- }
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- interface IProps {
3
- label: string;
4
- options: string[];
5
- selected: string[];
6
- onChange: (selected: string[]) => void;
7
- sectionId: string;
8
- }
9
- export declare function SelectableLabelFilter({ label, options, selected, onChange, sectionId }: IProps): React.JSX.Element;
10
- export {};
11
- //# sourceMappingURL=SelectableLabelFilter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectableLabelFilter.d.ts","sourceRoot":"","sources":["../../../../../../src/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,UAAU,MAAM;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACvC,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,MAAM,qBAwD9F"}
@@ -1,23 +0,0 @@
1
- import { Button, Flex, Label } from '@patternfly/react-core';
2
- import CloseIcon from '@patternfly/react-icons/dist/esm/icons/close-icon';
3
- import React from 'react';
4
- import { useTranslation } from 'react-i18next';
5
- import { AdvanceSearchFieldBlock } from './AdvanceSearchFieldBlock';
6
- export function SelectableLabelFilter({ label, options, selected, onChange, sectionId }) {
7
- const { t } = useTranslation();
8
- const toggleOption = (option) => {
9
- if (selected.includes(option)) {
10
- onChange(selected.filter((value) => value !== option));
11
- return;
12
- }
13
- onChange([...selected, option]);
14
- };
15
- const clearSelection = () => onChange([]);
16
- return (React.createElement(AdvanceSearchFieldBlock, { label: React.createElement(React.Fragment, null,
17
- label,
18
- selected.length > 0 ? ` (${selected.length})` : ''), headerActions: selected.length > 0 ? (React.createElement(Button, { variant: "plain", onClick: clearSelection, "aria-label": t('Clear {{label}} selection', { label }), icon: React.createElement(CloseIcon, { "aria-hidden": true }), className: "pf-v6-u-p-0" })) : undefined },
19
- React.createElement(Flex, { flexWrap: { default: 'wrap' }, spaceItems: { default: 'spaceItemsSm' }, rowGap: { default: 'rowGapSm' } }, options.map((option) => {
20
- const isSelected = selected.includes(option);
21
- return (React.createElement(Label, { key: option, color: isSelected ? 'blue' : 'grey', variant: isSelected ? 'filled' : 'outline', isCompact: true, onClick: () => toggleOption(option), id: `${sectionId}-${option.replace(/\s+/g, '-')}` }, option));
22
- }))));
23
- }
@@ -1,14 +0,0 @@
1
- export interface ICaseLabelOption {
2
- id: string;
3
- name: string;
4
- }
5
- interface UseCaseLabelsResult {
6
- labels: ICaseLabelOption[];
7
- loading: boolean;
8
- error: Error | undefined;
9
- refetch: () => Promise<void>;
10
- }
11
- /** Fetches account-scoped case labels for the Case List Case labels filter. */
12
- export declare function useCaseLabels(accountId?: string): UseCaseLabelsResult;
13
- export {};
14
- //# sourceMappingURL=useCaseLabels.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCaseLabels.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCaseLabels.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CAChB;AAOD,UAAU,mBAAmB;IACzB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAmCrE"}
@@ -1,55 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { useApolloClient } from '@apollo/client/react';
11
- import { GET_CASE_LABELS, } from '@rh-support/utils';
12
- import { useCallback, useEffect, useState } from 'react';
13
- const mapCaseLabelNode = (node) => {
14
- var _a, _b;
15
- return ({
16
- id: node.Id,
17
- name: (_b = (_a = node.Name) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '',
18
- });
19
- };
20
- /** Fetches account-scoped case labels for the Case List Case labels filter. */
21
- export function useCaseLabels(accountId) {
22
- const client = useApolloClient();
23
- const [labels, setLabels] = useState([]);
24
- const [loading, setLoading] = useState(false);
25
- const [error, setError] = useState(undefined);
26
- const fetchLabels = useCallback(() => __awaiter(this, void 0, void 0, function* () {
27
- var _a, _b, _c, _d;
28
- if (!accountId) {
29
- setLabels([]);
30
- return;
31
- }
32
- setLoading(true);
33
- setError(undefined);
34
- try {
35
- const { data } = yield client.query({
36
- query: GET_CASE_LABELS,
37
- variables: { where: { Account__c: { eq: accountId } } },
38
- fetchPolicy: 'cache-first',
39
- });
40
- const edges = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportCaseLabel__c) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
41
- setLabels(edges.map(({ node }) => mapCaseLabelNode(node)).filter((label) => label.id && label.name));
42
- }
43
- catch (e) {
44
- setError(e);
45
- setLabels([]);
46
- }
47
- finally {
48
- setLoading(false);
49
- }
50
- }), [accountId, client]);
51
- useEffect(() => {
52
- fetchLabels();
53
- }, [fetchLabels]);
54
- return { labels, loading, error, refetch: fetchLabels };
55
- }
@@ -1,11 +0,0 @@
1
- import { IAdvanceSearchDateRanges, IAdvanceSearchFormState, ICaseListFilterState, IFilterInfo } from '../components/case-list/CaseListFilterReducer';
2
- import { CaseSearchQueryType } from '../enums/caseSearch';
3
- export declare const hasAdvanceSearchActiveState: (filterState: ICaseListFilterState) => boolean;
4
- export declare const deriveSearchQueryType: (filterState: ICaseListFilterState) => CaseSearchQueryType;
5
- export declare const toNameOrSsoFilterValues: (value: string) => string[];
6
- export declare const mapAdvanceSearchFormToFilterInfo: (formState: IAdvanceSearchFormState) => IFilterInfo;
7
- export declare const mergeAdvanceSearchFormIntoFilterInfo: (formState: IAdvanceSearchFormState, currentFilterInfo?: Partial<IFilterInfo>) => IFilterInfo;
8
- export declare const buildAdvanceSearchParsedQuery: (formState: IAdvanceSearchFormState, filterInfo: Partial<IFilterInfo>) => string;
9
- export declare const mapAdvanceSearchFormToDateRanges: (formState: IAdvanceSearchFormState) => IAdvanceSearchDateRanges;
10
- export declare const createCaseListFilterStateFromAdvanceSearchForm: (formState: IAdvanceSearchFormState, currentFilterState: ICaseListFilterState) => ICaseListFilterState;
11
- //# sourceMappingURL=advanceSearchFormMapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"advanceSearchFormMapper.d.ts","sourceRoot":"","sources":["../../../src/utils/advanceSearchFormMapper.ts"],"names":[],"mappings":"AAIA,OAAO,EAGH,wBAAwB,EACxB,uBAAuB,EACvB,oBAAoB,EACpB,WAAW,EACd,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1D,eAAO,MAAM,2BAA2B,GAAI,aAAa,oBAAoB,KAAG,OACwB,CAAC;AAEzG,eAAO,MAAM,qBAAqB,GAAI,aAAa,oBAAoB,KAAG,mBAC6B,CAAC;AAIxG,eAAO,MAAM,uBAAuB,GAAI,OAAO,MAAM,KAAG,MAAM,EAc7D,CAAC;AAEF,eAAO,MAAM,gCAAgC,GAAI,WAAW,uBAAuB,KAAG,WAsBrF,CAAC;AAEF,eAAO,MAAM,oCAAoC,GAC7C,WAAW,uBAAuB,EAClC,oBAAmB,OAAO,CAAC,WAAW,CAAM,KAC7C,WAoBF,CAAC;AAmBF,eAAO,MAAM,6BAA6B,GACtC,WAAW,uBAAuB,EAClC,YAAY,OAAO,CAAC,WAAW,CAAC,KACjC,MASF,CAAC;AAEF,eAAO,MAAM,gCAAgC,GAAI,WAAW,uBAAuB,KAAG,wBAIpF,CAAC;AAEH,eAAO,MAAM,8CAA8C,GACvD,WAAW,uBAAuB,EAClC,oBAAoB,oBAAoB,KACzC,oBA0BF,CAAC"}
@@ -1,71 +0,0 @@
1
- import { toOldCaseTypeMapper } from '@rh-support/utils';
2
- import { initialPaginationInfo } from '../components/case-list/CaseListFilterContext';
3
- import { hasAdvanceSearchDateRanges } from '../components/case-list/CaseListFilterHelpers';
4
- import { emptyFilters, } from '../components/case-list/CaseListFilterReducer';
5
- import { CaseSearchQueryType } from '../enums/caseSearch';
6
- import { SolrKeys, SolrPivotKeys } from '../enums/filters';
7
- import { isAdvanceSearchFormEmpty } from './advanceSearchUtils';
8
- import { createUserFriendlyQueryFromFilterStateAdvancedSearch } from './caseSearchUtils';
9
- export const hasAdvanceSearchActiveState = (filterState) => { var _a, _b; return Boolean((_b = (_a = filterState.filterQueryInfo) === null || _a === void 0 ? void 0 : _a.parsedQuery) === null || _b === void 0 ? void 0 : _b.trim()) || hasAdvanceSearchDateRanges(filterState); };
10
- export const deriveSearchQueryType = (filterState) => hasAdvanceSearchActiveState(filterState) ? CaseSearchQueryType.ADVANCED : CaseSearchQueryType.BASIC;
11
- const splitSearchTokens = (value) => value.trim().split(/\s+/).filter(Boolean);
12
- export const toNameOrSsoFilterValues = (value) => {
13
- const trimmed = value.trim();
14
- if (!trimmed) {
15
- return [];
16
- }
17
- if (trimmed.includes(',')) {
18
- return trimmed
19
- .split(',')
20
- .map((entry) => entry.trim())
21
- .filter(Boolean);
22
- }
23
- return [trimmed];
24
- };
25
- export const mapAdvanceSearchFormToFilterInfo = (formState) => {
26
- const escalation = formState.showEscalatedOnly ? [{ key: 'true', value: 'true' }] : [];
27
- return Object.assign(Object.assign({}, emptyFilters), { [SolrPivotKeys.product_version]: formState.products.map((product) => (Object.assign(Object.assign({}, product), { [SolrKeys.version]: [...(product[SolrKeys.version] || [])] }))), [SolrKeys.status]: [...formState.statuses], [SolrKeys.severity]: [...formState.severities], [SolrKeys.type]: toOldCaseTypeMapper(formState.supportTypes), [SolrKeys.escalation]: escalation, [SolrKeys.accountNumber]: [...formState.accountNumbers], [SolrKeys.alternateId]: splitSearchTokens(formState.personalReferenceNumber), [SolrKeys.openshiftClusterId]: splitSearchTokens(formState.openshiftClusterId), [SolrKeys.caseContactSSO]: toNameOrSsoFilterValues(formState.ownerNameAndSso), [SolrKeys.caseOwner]: toNameOrSsoFilterValues(formState.assignedToNameAndSso), [SolrKeys.group]: [...formState.groups], [SolrKeys.createdBySsoUsername]: toNameOrSsoFilterValues(formState.createdByNameAndSso), [SolrKeys.modifiedBy]: toNameOrSsoFilterValues(formState.lastModifiedByNameAndSso) });
28
- };
29
- export const mergeAdvanceSearchFormIntoFilterInfo = (formState, currentFilterInfo = {}) => {
30
- const advanceSearchValues = mapAdvanceSearchFormToFilterInfo(formState);
31
- return Object.assign(Object.assign(Object.assign({}, emptyFilters), currentFilterInfo), { [SolrPivotKeys.product_version]: advanceSearchValues[SolrPivotKeys.product_version], [SolrKeys.status]: advanceSearchValues[SolrKeys.status], [SolrKeys.severity]: advanceSearchValues[SolrKeys.severity], [SolrKeys.type]: advanceSearchValues[SolrKeys.type], [SolrKeys.escalation]: advanceSearchValues[SolrKeys.escalation], [SolrKeys.accountNumber]: advanceSearchValues[SolrKeys.accountNumber], [SolrKeys.alternateId]: advanceSearchValues[SolrKeys.alternateId], [SolrKeys.openshiftClusterId]: advanceSearchValues[SolrKeys.openshiftClusterId], [SolrKeys.caseContactSSO]: advanceSearchValues[SolrKeys.caseContactSSO], [SolrKeys.caseOwner]: advanceSearchValues[SolrKeys.caseOwner], [SolrKeys.group]: advanceSearchValues[SolrKeys.group], [SolrKeys.createdBySsoUsername]: advanceSearchValues[SolrKeys.createdBySsoUsername], [SolrKeys.modifiedBy]: advanceSearchValues[SolrKeys.modifiedBy] });
32
- };
33
- const formatDateRangeParsedQuery = (fieldLabel, range) => {
34
- const { startDate, endDate } = range;
35
- if (!startDate && !endDate) {
36
- return null;
37
- }
38
- if (startDate && endDate) {
39
- return `${fieldLabel}: ${startDate} to ${endDate}`;
40
- }
41
- if (startDate) {
42
- return `${fieldLabel}: >= ${startDate}`;
43
- }
44
- return `${fieldLabel}: <= ${endDate}`;
45
- };
46
- export const buildAdvanceSearchParsedQuery = (formState, filterInfo) => {
47
- const filterQueryParts = [
48
- createUserFriendlyQueryFromFilterStateAdvancedSearch(filterInfo, ''),
49
- formatDateRangeParsedQuery('createdDate', formState.createdDateRange),
50
- formatDateRangeParsedQuery('lastModifiedDate', formState.lastModifiedDateRange),
51
- formatDateRangeParsedQuery('closedDate', formState.closedDateRange),
52
- ].filter(Boolean);
53
- return filterQueryParts.join(' and ');
54
- };
55
- export const mapAdvanceSearchFormToDateRanges = (formState) => ({
56
- createdDateRange: Object.assign({}, formState.createdDateRange),
57
- lastModifiedDateRange: Object.assign({}, formState.lastModifiedDateRange),
58
- closedDateRange: Object.assign({}, formState.closedDateRange),
59
- });
60
- export const createCaseListFilterStateFromAdvanceSearchForm = (formState, currentFilterState) => {
61
- var _a;
62
- const filterInfo = mergeAdvanceSearchFormIntoFilterInfo(formState, currentFilterState.filterInfo);
63
- const hasActiveAdvanceSearch = !isAdvanceSearchFormEmpty(formState);
64
- const parsedQuery = hasActiveAdvanceSearch ? buildAdvanceSearchParsedQuery(formState, filterInfo) : '';
65
- const nextFilterState = Object.assign(Object.assign({}, currentFilterState), { filterInfo, filterQueryInfo: {
66
- queryString: ((_a = currentFilterState.filterQueryInfo) === null || _a === void 0 ? void 0 : _a.queryString) || '',
67
- parsedQuery,
68
- type: hasActiveAdvanceSearch ? CaseSearchQueryType.ADVANCED : CaseSearchQueryType.BASIC,
69
- }, paginationInfo: Object.assign(Object.assign({}, (currentFilterState.paginationInfo || initialPaginationInfo)), { currentPage: 1 }), advanceSearchDateRanges: hasActiveAdvanceSearch ? mapAdvanceSearchFormToDateRanges(formState) : undefined });
70
- return Object.assign(Object.assign({}, nextFilterState), { filterQueryInfo: Object.assign(Object.assign({}, nextFilterState.filterQueryInfo), { type: deriveSearchQueryType(nextFilterState) }) });
71
- };
@@ -1,24 +0,0 @@
1
- import { IAdvanceSearchDateRange, IAdvanceSearchFormState, ICaseListFilterState } from '../components/case-list/CaseListFilterReducer';
2
- /** Matches PatternFly DatePicker yyyy-MM-dd parsing and rejects impossible dates (e.g. 2024-02-31). */
3
- export declare const parseAdvanceSearchDate: (value: string) => Date | undefined;
4
- export declare const isValidAdvanceSearchDateInput: (value: string) => boolean;
5
- export declare const isAdvanceSearchDateRangeValid: (range: IAdvanceSearchDateRange) => boolean;
6
- export declare const hasInvalidAdvanceSearchDates: (ranges: {
7
- createdDateRange: IAdvanceSearchDateRange;
8
- lastModifiedDateRange: IAdvanceSearchDateRange;
9
- closedDateRange: IAdvanceSearchDateRange;
10
- }) => boolean;
11
- export interface IAdvanceSearchDateRangeFieldErrors {
12
- startDate?: string;
13
- endDate?: string;
14
- }
15
- export declare const getAdvanceSearchDateRangeFieldErrors: (range: IAdvanceSearchDateRange, messages: {
16
- invalidDateFormat: string;
17
- invalidDateRange: string;
18
- }) => IAdvanceSearchDateRangeFieldErrors;
19
- export declare const createInitialAdvanceSearchFormState: () => IAdvanceSearchFormState;
20
- export declare const mapFilterStateToAdvanceSearchForm: (filterState: ICaseListFilterState) => IAdvanceSearchFormState;
21
- export declare const isAdvanceSearchFormEmpty: (formState: IAdvanceSearchFormState) => boolean;
22
- /** Counts total applied advanced-search filter values across all fields. */
23
- export declare const getAdvanceSearchAppliedFilterCount: (filterState: ICaseListFilterState) => number;
24
- //# sourceMappingURL=advanceSearchUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"advanceSearchUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/advanceSearchUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EAEvB,MAAM,+CAA+C,CAAC;AAKvD,uGAAuG;AACvG,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,KAAG,IAAI,GAAG,SAsB7D,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,OAAO,MAAM,KAAG,OACE,CAAC;AAEjE,eAAO,MAAM,6BAA6B,GAAI,OAAO,uBAAuB,KAAG,OAa9E,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,QAAQ;IACjD,gBAAgB,EAAE,uBAAuB,CAAC;IAC1C,qBAAqB,EAAE,uBAAuB,CAAC;IAC/C,eAAe,EAAE,uBAAuB,CAAC;CAC5C,KAAG,OAGsD,CAAC;AAE3D,MAAM,WAAW,kCAAkC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,oCAAoC,GAC7C,OAAO,uBAAuB,EAC9B,UAAU;IACN,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC5B,KACF,kCAqBF,CAAC;AAOF,eAAO,MAAM,mCAAmC,QAAO,uBAiBrD,CAAC;AAEH,eAAO,MAAM,iCAAiC,GAAI,aAAa,oBAAoB,KAAG,uBA6BrF,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,WAAW,uBAAuB,KAAG,OAG7E,CAAC;AAuBF,4EAA4E;AAC5E,eAAO,MAAM,kCAAkC,GAAI,aAAa,oBAAoB,KAAG,MA0BtF,CAAC"}
@@ -1,150 +0,0 @@
1
- import { toNewCaseTypeMapper } from '@rh-support/utils';
2
- import isEqual from 'lodash/isEqual';
3
- import { SolrKeys, SolrPivotKeys } from '../enums/filters';
4
- const YYYY_MM_DD_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
5
- /** Matches PatternFly DatePicker yyyy-MM-dd parsing and rejects impossible dates (e.g. 2024-02-31). */
6
- export const parseAdvanceSearchDate = (value) => {
7
- const trimmed = value.trim();
8
- if (!trimmed) {
9
- return undefined;
10
- }
11
- if (!YYYY_MM_DD_PATTERN.test(trimmed)) {
12
- return undefined;
13
- }
14
- const [year, month, day] = trimmed.split('-').map(Number);
15
- const parsedDate = new Date(`${trimmed}T00:00:00`);
16
- if (Number.isNaN(parsedDate.getTime())) {
17
- return undefined;
18
- }
19
- if (parsedDate.getFullYear() !== year || parsedDate.getMonth() + 1 !== month || parsedDate.getDate() !== day) {
20
- return undefined;
21
- }
22
- return parsedDate;
23
- };
24
- export const isValidAdvanceSearchDateInput = (value) => !value.trim() || parseAdvanceSearchDate(value) !== undefined;
25
- export const isAdvanceSearchDateRangeValid = (range) => {
26
- if (!isValidAdvanceSearchDateInput(range.startDate) || !isValidAdvanceSearchDateInput(range.endDate)) {
27
- return false;
28
- }
29
- const startDate = parseAdvanceSearchDate(range.startDate);
30
- const endDate = parseAdvanceSearchDate(range.endDate);
31
- if (startDate && endDate && startDate > endDate) {
32
- return false;
33
- }
34
- return true;
35
- };
36
- export const hasInvalidAdvanceSearchDates = (ranges) => !isAdvanceSearchDateRangeValid(ranges.createdDateRange) ||
37
- !isAdvanceSearchDateRangeValid(ranges.lastModifiedDateRange) ||
38
- !isAdvanceSearchDateRangeValid(ranges.closedDateRange);
39
- export const getAdvanceSearchDateRangeFieldErrors = (range, messages) => {
40
- const errors = {};
41
- if (!isValidAdvanceSearchDateInput(range.startDate)) {
42
- errors.startDate = messages.invalidDateFormat;
43
- }
44
- if (!isValidAdvanceSearchDateInput(range.endDate)) {
45
- errors.endDate = messages.invalidDateFormat;
46
- }
47
- if (!errors.startDate && !errors.endDate) {
48
- const startDate = parseAdvanceSearchDate(range.startDate);
49
- const endDate = parseAdvanceSearchDate(range.endDate);
50
- if (startDate && endDate && startDate > endDate) {
51
- errors.endDate = messages.invalidDateRange;
52
- }
53
- }
54
- return errors;
55
- };
56
- const emptyDateRange = () => ({
57
- startDate: '',
58
- endDate: '',
59
- });
60
- export const createInitialAdvanceSearchFormState = () => ({
61
- statuses: [],
62
- severities: [],
63
- supportTypes: [],
64
- showEscalatedOnly: false,
65
- accountNumbers: [],
66
- personalReferenceNumber: '',
67
- openshiftClusterId: '',
68
- ownerNameAndSso: '',
69
- assignedToNameAndSso: '',
70
- groups: [],
71
- createdByNameAndSso: '',
72
- lastModifiedByNameAndSso: '',
73
- createdDateRange: emptyDateRange(),
74
- lastModifiedDateRange: emptyDateRange(),
75
- closedDateRange: emptyDateRange(),
76
- products: [],
77
- });
78
- export const mapFilterStateToAdvanceSearchForm = (filterState) => {
79
- var _a, _b, _c;
80
- const { filterInfo } = filterState;
81
- if (!filterInfo) {
82
- return createInitialAdvanceSearchFormState();
83
- }
84
- const escalationValues = filterInfo[SolrKeys.escalation] || [];
85
- return {
86
- statuses: [...(filterInfo[SolrKeys.status] || [])],
87
- severities: [...(filterInfo[SolrKeys.severity] || [])],
88
- supportTypes: toNewCaseTypeMapper(filterInfo[SolrKeys.type] || []),
89
- showEscalatedOnly: escalationValues.some((item) => item.key === 'true'),
90
- accountNumbers: [...(filterInfo[SolrKeys.accountNumber] || [])],
91
- personalReferenceNumber: (filterInfo[SolrKeys.alternateId] || []).join(' '),
92
- openshiftClusterId: (filterInfo[SolrKeys.openshiftClusterId] || []).join(' '),
93
- ownerNameAndSso: (filterInfo[SolrKeys.caseContactSSO] || []).join(', '),
94
- assignedToNameAndSso: (filterInfo[SolrKeys.caseOwner] || []).join(', '),
95
- groups: [...(filterInfo[SolrKeys.group] || [])],
96
- createdByNameAndSso: (filterInfo[SolrKeys.createdBySsoUsername] || []).join(', '),
97
- lastModifiedByNameAndSso: (filterInfo[SolrKeys.modifiedBy] || []).join(', '),
98
- createdDateRange: Object.assign({}, (((_a = filterState.advanceSearchDateRanges) === null || _a === void 0 ? void 0 : _a.createdDateRange) || emptyDateRange())),
99
- lastModifiedDateRange: Object.assign({}, (((_b = filterState.advanceSearchDateRanges) === null || _b === void 0 ? void 0 : _b.lastModifiedDateRange) || emptyDateRange())),
100
- closedDateRange: Object.assign({}, (((_c = filterState.advanceSearchDateRanges) === null || _c === void 0 ? void 0 : _c.closedDateRange) || emptyDateRange())),
101
- products: (filterInfo[SolrPivotKeys.product_version] || []).map((product) => (Object.assign(Object.assign({}, product), { [SolrKeys.version]: [...(product[SolrKeys.version] || [])] }))),
102
- };
103
- };
104
- export const isAdvanceSearchFormEmpty = (formState) => {
105
- const initialState = createInitialAdvanceSearchFormState();
106
- return isEqual(formState, initialState);
107
- };
108
- const countDateRangeValues = (range) => {
109
- if (!range) {
110
- return 0;
111
- }
112
- let count = 0;
113
- if (range.startDate.trim()) {
114
- count++;
115
- }
116
- if (range.endDate.trim()) {
117
- count++;
118
- }
119
- return count;
120
- };
121
- const countProductFilterValues = (products) => products.reduce((total, product) => {
122
- const versions = product[SolrKeys.version] || [];
123
- return total + (versions.length > 0 ? versions.length : 1);
124
- }, 0);
125
- /** Counts total applied advanced-search filter values across all fields. */
126
- export const getAdvanceSearchAppliedFilterCount = (filterState) => {
127
- const { filterInfo, advanceSearchDateRanges } = filterState;
128
- if (!filterInfo) {
129
- return 0;
130
- }
131
- let count = 0;
132
- count += (filterInfo[SolrKeys.status] || []).length;
133
- count += (filterInfo[SolrKeys.severity] || []).length;
134
- count += (filterInfo[SolrKeys.type] || []).length;
135
- count += (filterInfo[SolrKeys.escalation] || []).length;
136
- count += (filterInfo[SolrKeys.accountNumber] || []).length;
137
- count += (filterInfo[SolrKeys.alternateId] || []).length;
138
- count += (filterInfo[SolrKeys.openshiftClusterId] || []).length;
139
- count += (filterInfo[SolrKeys.caseContactSSO] || []).length;
140
- count += (filterInfo[SolrKeys.caseOwner] || []).length;
141
- count += (filterInfo[SolrKeys.group] || []).length;
142
- count += (filterInfo[SolrKeys.caseLabel] || []).length;
143
- count += (filterInfo[SolrKeys.createdBySsoUsername] || []).length;
144
- count += (filterInfo[SolrKeys.modifiedBy] || []).length;
145
- count += countProductFilterValues(filterInfo[SolrPivotKeys.product_version] || []);
146
- count += countDateRangeValues(advanceSearchDateRanges === null || advanceSearchDateRanges === void 0 ? void 0 : advanceSearchDateRanges.createdDateRange);
147
- count += countDateRangeValues(advanceSearchDateRanges === null || advanceSearchDateRanges === void 0 ? void 0 : advanceSearchDateRanges.lastModifiedDateRange);
148
- count += countDateRangeValues(advanceSearchDateRanges === null || advanceSearchDateRanges === void 0 ? void 0 : advanceSearchDateRanges.closedDateRange);
149
- return count;
150
- };
@@ -1,12 +0,0 @@
1
- import { ICaseGroup } from '@cee-eng/hydrajs/@types/api/public/caseGroups';
2
- import { IPreference } from '@cee-eng/hydrajs/@types/models/general';
3
- import type { ILoggedInSsoContact } from '@rh-support/utils';
4
- export declare function decodeCaseListUrlFilterQuery(queryFromUrl?: string): string;
5
- export declare function hasDefaultSavedSearch(hydraUserPreferences?: IPreference[]): boolean;
6
- /** Default group filter applies only when URL and saved-search do not own the filter state. */
7
- export declare function shouldApplyDefaultGroupFilter(queryFromUrl?: string, hydraUserPreferences?: IPreference[]): boolean;
8
- export declare function getDefaultGroupFilterSelection(caseGroups: ICaseGroup[] | undefined, loggedInUser?: ILoggedInSsoContact): Array<{
9
- key: string;
10
- value: string;
11
- }>;
12
- //# sourceMappingURL=caseGroupDefaultFilterUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"caseGroupDefaultFilterUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseGroupDefaultFilterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAErE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAM7D,wBAAgB,4BAA4B,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAa1E;AAED,wBAAgB,qBAAqB,CAAC,oBAAoB,GAAE,WAAW,EAAO,GAAG,OAAO,CAOvF;AAED,+FAA+F;AAC/F,wBAAgB,6BAA6B,CACzC,YAAY,CAAC,EAAE,MAAM,EACrB,oBAAoB,GAAE,WAAW,EAAO,GACzC,OAAO,CAMT;AAED,wBAAgB,8BAA8B,CAC1C,UAAU,EAAE,UAAU,EAAE,GAAG,SAAS,EACpC,YAAY,CAAC,EAAE,mBAAmB,GACnC,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAGvC"}