@rh-support/cases 2.6.173 → 2.6.181
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.
- package/lib/esm/components/case-list/CaseList.d.ts +0 -7
- package/lib/esm/components/case-list/CaseList.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseList.js +143 -108
- package/lib/esm/components/case-list/CaseListContext.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseListContext.js +5 -2
- package/lib/esm/components/case-list/CaseListFilterReducer.d.ts +6 -4
- package/lib/esm/components/case-list/CaseListFilterReducer.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseListFilterReducer.js +3 -12
- package/lib/esm/components/case-list/CaseListReducer.d.ts +22 -10
- package/lib/esm/components/case-list/CaseListReducer.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseListReducer.js +25 -7
- package/lib/esm/components/case-list/case-list-filters/AccountsFilter.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/AccountsFilter.js +18 -11
- package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.js +4 -2
- package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts +1 -7
- package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.js +7 -15
- package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts +2 -5
- package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/CaseListFilters.js +14 -14
- package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts +1 -3
- package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.js +2 -2
- package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts +5 -4
- package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/ProductsFilter.js +15 -54
- package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts +0 -3
- package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/SeverityFilter.js +18 -44
- package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts +0 -3
- package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/StatusFilter.js +14 -44
- package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts +1 -3
- package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/VersionsFilter.js +61 -32
- package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts +7 -3
- package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-table/CaseListTable.js +69 -58
- package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts +0 -5
- package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.js +38 -68
- package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.js +5 -15
- package/lib/esm/components/case-list/case-list-table/SeverityLabel.js +1 -1
- package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.js +2 -3
- package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.js +1 -0
- package/lib/esm/components/case-list/case-search/CaseSearch.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-search/CaseSearch.js +6 -6
- package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.js +2 -1
- package/lib/esm/css/caseList.css +99 -22
- package/lib/esm/enums/case.d.ts +2 -1
- package/lib/esm/enums/case.d.ts.map +1 -1
- package/lib/esm/enums/case.js +14 -1
- package/lib/esm/hooks/useExportCaseListCSV.d.ts.map +1 -1
- package/lib/esm/hooks/useExportCaseListCSV.js +1 -9
- package/lib/esm/test-utils/mockData.js +1 -1
- package/lib/esm/utils/caseListGraphQLUtils.d.ts +28 -0
- package/lib/esm/utils/caseListGraphQLUtils.d.ts.map +1 -0
- package/lib/esm/utils/caseListGraphQLUtils.js +244 -0
- package/lib/esm/utils/caseListMapper.d.ts +6 -0
- package/lib/esm/utils/caseListMapper.d.ts.map +1 -0
- package/lib/esm/utils/caseListMapper.js +36 -0
- package/lib/esm/utils/caseListVariablesBuilder.d.ts +14 -0
- package/lib/esm/utils/caseListVariablesBuilder.d.ts.map +1 -0
- package/lib/esm/utils/caseListVariablesBuilder.js +193 -0
- package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
- package/lib/esm/utils/caseSearchUtils.js +26 -1
- package/lib/esm/utils/constants.d.ts +2 -1
- package/lib/esm/utils/constants.d.ts.map +1 -1
- package/lib/esm/utils/constants.js +14 -3
- package/lib/esm/utils/mockSolrResponse.js +1 -1
- package/lib/esm/utils/statusUtils.d.ts +3 -0
- package/lib/esm/utils/statusUtils.d.ts.map +1 -0
- package/lib/esm/utils/statusUtils.js +22 -0
- package/package.json +6 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button, MenuToggle, Select, SelectList, SelectOption, } from '@patternfly/react-core';
|
|
2
|
-
import {
|
|
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.
|
|
19
|
-
|
|
20
|
-
:
|
|
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
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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 =
|
|
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:
|
|
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
|
|
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]
|
|
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
|
-
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/StatusFilter.tsx"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1,43 +1,23 @@
|
|
|
1
1
|
import { Button, MenuToggle, Select, SelectList, SelectOption, } from '@patternfly/react-core';
|
|
2
|
-
import {
|
|
2
|
+
import { useSelectKeyboardNavigator } from '@rh-support/components';
|
|
3
3
|
import isEmpty from 'lodash/isEmpty';
|
|
4
4
|
import React, { useContext, useEffect, useState } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { SolrKeys } from '../../../enums/filters';
|
|
7
|
-
import { filterNamesMap } from '../../../utils/constants';
|
|
7
|
+
import { filterNamesMap, PORTAL_DISPLAY_STATUSES } from '../../../utils/constants';
|
|
8
8
|
import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
|
|
9
9
|
import { updateFilter } from '../CaseListFilterReducer';
|
|
10
10
|
export function StatusFilter(props) {
|
|
11
|
-
var _a;
|
|
12
11
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
13
12
|
const { t } = useTranslation();
|
|
14
13
|
const { filterInfo } = useContext(CaseListFilterStateContext);
|
|
15
14
|
const [isOpen, setIsOpen] = useState(false);
|
|
16
15
|
const [selectedItems, setSelectedItems] = useState({});
|
|
17
|
-
const list =
|
|
18
|
-
? props.allCaseStatuses.map((status) => ({ value: status, key: status }))
|
|
19
|
-
: props.filterValues.map((filterValue) => ({ value: filterValue.value, key: filterValue.value }));
|
|
20
|
-
const singleSelectOptions = list.map((item) => ({
|
|
21
|
-
value: item.value,
|
|
22
|
-
label: item.value,
|
|
23
|
-
}));
|
|
24
|
-
const selectedStatus = ((_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) === null || _a === void 0 ? void 0 : _a[0]) || '';
|
|
25
|
-
const selectedOption = {
|
|
26
|
-
value: selectedStatus,
|
|
27
|
-
label: selectedStatus,
|
|
28
|
-
};
|
|
16
|
+
const list = PORTAL_DISPLAY_STATUSES.map((status) => ({ value: status, key: status }));
|
|
29
17
|
const onToggleClick = (e) => {
|
|
30
18
|
setIsOpen(!isOpen);
|
|
31
19
|
};
|
|
32
20
|
const onSelect = (option) => {
|
|
33
|
-
if (props.isSolrSearchDown) {
|
|
34
|
-
updateFilter(dispatch, {
|
|
35
|
-
filterKey: SolrKeys.status,
|
|
36
|
-
values: [option.value],
|
|
37
|
-
});
|
|
38
|
-
setIsOpen(false);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
21
|
const prevSelectedStatuses = Object.keys(selectedItems).filter((item) => selectedItems[item] && item);
|
|
42
22
|
if (selectedItems[option.value]) {
|
|
43
23
|
setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
|
|
@@ -75,42 +55,32 @@ export function StatusFilter(props) {
|
|
|
75
55
|
else if (selectedValues && selectedValues.length === 1) {
|
|
76
56
|
return selectedValues[0];
|
|
77
57
|
}
|
|
78
|
-
else if (selectedValues && selectedValues.length ===
|
|
58
|
+
else if (selectedValues && totalLength && selectedValues.length === totalLength) {
|
|
79
59
|
return t('All cases');
|
|
80
60
|
}
|
|
81
61
|
else {
|
|
82
|
-
|
|
83
|
-
selectedValues.
|
|
84
|
-
selectedValues.
|
|
62
|
+
const hasAllOpenSelected = selectedValues.includes('In Progress') &&
|
|
63
|
+
selectedValues.includes('Waiting on Customer') &&
|
|
64
|
+
!selectedValues.includes('Closed');
|
|
65
|
+
if (hasAllOpenSelected) {
|
|
85
66
|
return t('All open cases');
|
|
86
67
|
}
|
|
87
|
-
else if (selectedValues && totalLength && selectedValues.length === totalLength) {
|
|
88
|
-
return totalLengthString || btnPlaceholder;
|
|
89
|
-
}
|
|
90
68
|
else {
|
|
91
69
|
return `${selectedValues.length} ${type} selected`;
|
|
92
70
|
}
|
|
93
71
|
}
|
|
94
72
|
};
|
|
95
|
-
const placeholder =
|
|
96
|
-
? t('Select a status')
|
|
97
|
-
: getBtnPlaceholder(t('Select a status'), (filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) || [], ' ', list.length, t('All selected'));
|
|
73
|
+
const placeholder = getBtnPlaceholder(t('Select a status'), (filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) || [], ' ', list.length, t('All selected'));
|
|
98
74
|
const toggle = (toggleRef) => (React.createElement(MenuToggle, { variant: "default", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true, onKeyDown: onInputKeyDown },
|
|
99
75
|
placeholder,
|
|
100
76
|
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" }))));
|
|
101
|
-
const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox:
|
|
102
|
-
const onSingleSelectChange = (option) => {
|
|
103
|
-
updateFilter(dispatch, {
|
|
104
|
-
filterKey: SolrKeys.status,
|
|
105
|
-
values: [option.value],
|
|
106
|
-
});
|
|
107
|
-
};
|
|
77
|
+
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-status-${option.value.replace(' ', '-')}` }, option.value)));
|
|
108
78
|
useEffect(() => {
|
|
109
79
|
var _a;
|
|
110
80
|
if (isEmpty(filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status])) {
|
|
111
81
|
setSelectedItems({});
|
|
112
82
|
}
|
|
113
|
-
else
|
|
83
|
+
else {
|
|
114
84
|
const selectedStatuses = (_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) === null || _a === void 0 ? void 0 : _a.reduce((selection, status) => {
|
|
115
85
|
selection[status] = true;
|
|
116
86
|
return selection;
|
|
@@ -118,10 +88,10 @@ export function StatusFilter(props) {
|
|
|
118
88
|
setSelectedItems(selectedStatuses || {});
|
|
119
89
|
}
|
|
120
90
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
-
}, [filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]
|
|
91
|
+
}, [filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]]);
|
|
122
92
|
const titleId = 'case-list-status-filter';
|
|
123
93
|
return (React.createElement("div", { className: "status-filter" },
|
|
124
94
|
React.createElement("label", { htmlFor: titleId, className: "pf-v6-u-mb-sm status-filter-label" }, t(filterNamesMap[SolrKeys.status])),
|
|
125
|
-
|
|
126
|
-
React.createElement(SelectList, null, dropdownOptions))))
|
|
95
|
+
React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: titleId, "data-tracking-id": "status-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
|
|
96
|
+
React.createElement(SelectList, null, dropdownOptions))));
|
|
127
97
|
}
|
|
@@ -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
|
productInfo: IProductFilter;
|
|
6
|
-
productVersionPivot: IProductVersionPivotMap[];
|
|
7
5
|
}
|
|
8
|
-
export declare function VersionsFilter({ productInfo
|
|
6
|
+
export declare function VersionsFilter({ productInfo }: IProps): React.JSX.Element;
|
|
9
7
|
export {};
|
|
10
8
|
//# sourceMappingURL=VersionsFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VersionsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/VersionsFilter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VersionsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/VersionsFilter.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAKhF,OAAO,EAAE,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAgCxE,UAAU,MAAM;IACZ,WAAW,EAAE,cAAc,CAAC;CAC/B;AAED,wBAAgB,cAAc,CAAC,EAAE,WAAW,EAAE,EAAE,MAAM,qBAiQrD"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { useApolloClient } from '@apollo/client/react';
|
|
1
2
|
import { Button, 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
4
|
import { useSelectKeyboardNavigator } from '@rh-support/components';
|
|
5
|
+
import { GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
6
|
+
import { GET_PRODUCTS, handleGraphQLVersionsResponse } from '@rh-support/utils';
|
|
4
7
|
import isEmpty from 'lodash/isEmpty';
|
|
5
8
|
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
9
|
import { useTranslation } from 'react-i18next';
|
|
7
10
|
import { SolrKeys, SolrPivotKeys } from '../../../enums/filters';
|
|
8
11
|
import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
|
|
9
12
|
import { updateFilter } from '../CaseListFilterReducer';
|
|
10
|
-
function getVersionValuesForProduct(productPivot = [], productName) {
|
|
11
|
-
return (productPivot.find((item) => item.value === productName) || {}).case_version;
|
|
12
|
-
}
|
|
13
13
|
//split version into parts
|
|
14
14
|
function parseVersionIntoParts(version) {
|
|
15
15
|
//keep unknown version at last
|
|
@@ -33,32 +33,62 @@ function compareVersions(versionA, versionB) {
|
|
|
33
33
|
//one is string and other is number => string takes precendence
|
|
34
34
|
if (typeof a === 'string')
|
|
35
35
|
return -1;
|
|
36
|
-
if (typeof b
|
|
36
|
+
if (typeof b === 'string')
|
|
37
37
|
return 1;
|
|
38
38
|
}
|
|
39
39
|
return 0;
|
|
40
40
|
}
|
|
41
|
-
export function VersionsFilter({ productInfo
|
|
41
|
+
export function VersionsFilter({ productInfo }) {
|
|
42
42
|
const { t } = useTranslation();
|
|
43
43
|
const { filterInfo } = useContext(CaseListFilterStateContext);
|
|
44
44
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
45
|
+
const apolloClient = useApolloClient();
|
|
46
|
+
const { globalMetadataState: { allProducts }, } = useContext(GlobalMetadataStateContext);
|
|
45
47
|
const [inputValue, setInputValue] = useState('');
|
|
46
48
|
const [activeItem, setActiveItem] = useState(null);
|
|
47
49
|
const [isOpen, setIsOpen] = useState(false);
|
|
48
50
|
const [selectedItems, setSelectedItems] = useState({});
|
|
51
|
+
const [fetchedVersions, setFetchedVersions] = useState([]);
|
|
52
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
49
53
|
const textInputRef = useRef();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const productObj = allProducts.data.productsResult.find((p) => p.name === productInfo.value || p.product === productInfo.value);
|
|
56
|
+
if (!(productObj === null || productObj === void 0 ? void 0 : productObj.productId))
|
|
57
|
+
return;
|
|
58
|
+
setIsLoading(true);
|
|
59
|
+
apolloClient
|
|
60
|
+
.query({
|
|
61
|
+
query: GET_PRODUCTS,
|
|
62
|
+
variables: {
|
|
63
|
+
where: { ParentProduct__c: { eq: productObj.productId }, IsActive: { eq: true } },
|
|
64
|
+
first: 200,
|
|
65
|
+
orderBy: { Name: { order: 'ASC' } },
|
|
66
|
+
},
|
|
67
|
+
fetchPolicy: 'cache-first',
|
|
68
|
+
})
|
|
69
|
+
.then(({ data }) => {
|
|
70
|
+
var _a, _b, _c, _d;
|
|
71
|
+
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.SalesforceSupportProduct2) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
|
|
72
|
+
const versionData = handleGraphQLVersionsResponse(edges, productObj.name || productInfo.value);
|
|
73
|
+
setFetchedVersions(versionData);
|
|
74
|
+
})
|
|
75
|
+
.catch((err) => {
|
|
76
|
+
console.error('[VersionsFilter] Failed to fetch versions:', err);
|
|
77
|
+
setFetchedVersions([]);
|
|
78
|
+
})
|
|
79
|
+
.finally(() => setIsLoading(false));
|
|
80
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
81
|
+
}, [productInfo.value, allProducts.data]);
|
|
82
|
+
const list = useMemo(() => {
|
|
83
|
+
const sorted = [...fetchedVersions].sort((a, b) => compareVersions(a.name, b.name));
|
|
84
|
+
return sorted.map((version) => ({
|
|
85
|
+
value: version.name,
|
|
86
|
+
key: version.name,
|
|
87
|
+
id: version.id,
|
|
88
|
+
}));
|
|
89
|
+
}, [fetchedVersions]);
|
|
60
90
|
const [selectOptions, setSelectOptions] = useState(list);
|
|
61
|
-
const onToggleClick = (
|
|
91
|
+
const onToggleClick = () => {
|
|
62
92
|
setIsOpen(!isOpen);
|
|
63
93
|
};
|
|
64
94
|
const onSelect = (option) => {
|
|
@@ -72,18 +102,17 @@ export function VersionsFilter({ productInfo, productVersionPivot }) {
|
|
|
72
102
|
setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
|
|
73
103
|
prevSelectedVersions.push(option.value);
|
|
74
104
|
}
|
|
75
|
-
const newVersionState = prevSelectedVersions.map((version) =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
105
|
+
const newVersionState = prevSelectedVersions.map((version) => {
|
|
106
|
+
const versionOption = list.find((item) => item.value === version);
|
|
107
|
+
return {
|
|
108
|
+
field: SolrKeys.version,
|
|
109
|
+
value: version,
|
|
110
|
+
productId: (versionOption === null || versionOption === void 0 ? void 0 : versionOption.id) || '',
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
const productNewState = [...((filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version]) || [])];
|
|
80
114
|
const objIndex = productNewState.findIndex((item) => item.value === productInfo.value);
|
|
81
|
-
|
|
82
|
-
productNewState[objIndex] = {
|
|
83
|
-
field: SolrKeys.product,
|
|
84
|
-
value: productInfo.value,
|
|
85
|
-
[SolrKeys.version]: newVersionState,
|
|
86
|
-
};
|
|
115
|
+
productNewState[objIndex] = Object.assign(Object.assign({}, productNewState[objIndex]), { field: SolrKeys.product, value: productInfo.value, [SolrKeys.version]: newVersionState });
|
|
87
116
|
updateFilter(dispatch, { filterKey: SolrPivotKeys.product_version, values: productNewState });
|
|
88
117
|
};
|
|
89
118
|
// Use the keyboard navigator hook
|
|
@@ -103,7 +132,7 @@ export function VersionsFilter({ productInfo, productVersionPivot }) {
|
|
|
103
132
|
var _a;
|
|
104
133
|
setInputValue('');
|
|
105
134
|
setSelectedItems({});
|
|
106
|
-
const productNewState = [...filterInfo[SolrPivotKeys.product_version]];
|
|
135
|
+
const productNewState = [...((filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version]) || [])];
|
|
107
136
|
const objIndex = productNewState.findIndex((item) => item.value === productInfo.value);
|
|
108
137
|
productNewState[objIndex] = {
|
|
109
138
|
field: SolrKeys.product,
|
|
@@ -117,7 +146,7 @@ export function VersionsFilter({ productInfo, productVersionPivot }) {
|
|
|
117
146
|
useEffect(() => {
|
|
118
147
|
if (focusedItemIndex !== null && list[focusedItemIndex]) {
|
|
119
148
|
const focusedItem = list[focusedItemIndex];
|
|
120
|
-
setActiveItem(`select-multi-typeahead-checkbox-${focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.value.replace(' ', '-')}`);
|
|
149
|
+
setActiveItem(`select-multi-typeahead-checkbox-${String(focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.value).replace(' ', '-')}`);
|
|
121
150
|
}
|
|
122
151
|
else {
|
|
123
152
|
setActiveItem(null);
|
|
@@ -131,7 +160,7 @@ export function VersionsFilter({ productInfo, productVersionPivot }) {
|
|
|
131
160
|
// Memoize dropdownOptions to prevent unnecessary rerenders
|
|
132
161
|
const dropdownOptions = useMemo(() => {
|
|
133
162
|
const optionsToRender = !isEmpty(selectOptions) ? selectOptions : list;
|
|
134
|
-
return optionsToRender.map((option, index) => 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)));
|
|
163
|
+
return optionsToRender.map((option, index) => option.value && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: true, isSelected: selectedItems[String(option.value)], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-multi-typeahead-${String(option.value).replace(' ', '-')}` }, option.value)));
|
|
135
164
|
}, [selectOptions, list, selectedItems, focusedItemIndex]);
|
|
136
165
|
// Update selectOptions when input value changes
|
|
137
166
|
useEffect(() => {
|
|
@@ -156,9 +185,9 @@ export function VersionsFilter({ productInfo, productVersionPivot }) {
|
|
|
156
185
|
setSelectedItems(selectedVersions);
|
|
157
186
|
}, [productInfo.case_version]);
|
|
158
187
|
const titleId = 'case-list-versions-filter';
|
|
159
|
-
return (React.createElement(
|
|
188
|
+
return (React.createElement("div", { className: "version-filter-chip" },
|
|
160
189
|
React.createElement("label", { hidden: true, htmlFor: titleId }, t('Open versions dropdown')),
|
|
161
190
|
React.createElement("div", { className: "pf-v6-c-select" },
|
|
162
191
|
React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, "data-tracking-id": "versions-filter", id: titleId, title: t('Version'), isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), popperProps: { direction: 'down', enableFlip: false }, toggle: toggle, isScrollable: true },
|
|
163
|
-
React.createElement(SelectList, null,
|
|
192
|
+
React.createElement(SelectList, null, isLoading ? React.createElement(SelectOption, { isDisabled: true }, t('Loading...')) : dropdownOptions)))));
|
|
164
193
|
}
|
|
@@ -3,16 +3,20 @@ import { ISolrResponse } from '@rh-support/types/shared';
|
|
|
3
3
|
import { UserAuth } from '@rh-support/user-permissions';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { ICaseListResponse } from '../../../models/caseList';
|
|
6
|
-
import {
|
|
6
|
+
import { ISortInfo } from '../CaseListFilterReducer';
|
|
7
7
|
interface IProps {
|
|
8
8
|
caseList: ISolrResponse<ICaseListResponse>;
|
|
9
9
|
caseGroups: ICaseGroup[];
|
|
10
10
|
loggedInUserRights: UserAuth;
|
|
11
11
|
sortInfo?: ISortInfo;
|
|
12
|
-
paginationInfo?: IPaginationInfo;
|
|
13
12
|
isCaseListPageLoading: boolean;
|
|
14
13
|
hasError: boolean;
|
|
15
|
-
|
|
14
|
+
hasNextPage: boolean;
|
|
15
|
+
isLoadingMore: boolean;
|
|
16
|
+
loadMoreError: boolean;
|
|
17
|
+
loadMoreRetryCount: number;
|
|
18
|
+
onRetryLoadMore: () => void;
|
|
19
|
+
sentinelRef?: (node?: Element | null) => void;
|
|
16
20
|
}
|
|
17
21
|
export declare function CaseListTable(props: IProps): React.JSX.Element;
|
|
18
22
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaseListTable.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-table/CaseListTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"CaseListTable.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-table/CaseListTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAuB3E,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAQxD,OAAO,KAAkD,MAAM,OAAO,CAAC;AAKvE,OAAO,EAAE,iBAAiB,EAAyB,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EAAgB,SAAS,EAAyC,MAAM,0BAA0B,CAAC;AA4B1G,UAAU,MAAM;IACZ,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,kBAAkB,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CACjD;AAsBD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,qBAunB1C"}
|