@rh-support/cases 2.6.182 → 2.6.186
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 +7 -0
- package/lib/esm/components/case-list/CaseList.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseList.js +108 -143
- package/lib/esm/components/case-list/CaseListContext.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseListContext.js +2 -5
- package/lib/esm/components/case-list/CaseListFilterReducer.d.ts +4 -6
- package/lib/esm/components/case-list/CaseListFilterReducer.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseListFilterReducer.js +12 -3
- package/lib/esm/components/case-list/CaseListReducer.d.ts +10 -22
- package/lib/esm/components/case-list/CaseListReducer.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseListReducer.js +7 -25
- 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 +11 -18
- 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 +5 -4
- package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts +7 -1
- 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 +15 -7
- package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts +5 -2
- 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 +3 -1
- 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 +4 -5
- 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 +54 -15
- package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts +3 -0
- 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 +44 -18
- package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts +3 -0
- 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 +44 -14
- package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts +3 -1
- 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 +32 -61
- package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts +3 -7
- 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 +58 -69
- package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts +5 -0
- 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 +68 -38
- 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 +15 -5
- 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 +3 -2
- package/lib/esm/components/case-list/case-search/AdvanceSearch.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-search/AdvanceSearch.js +1 -1
- package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.js +0 -1
- 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 +1 -2
- package/lib/esm/css/caseList.css +22 -99
- package/lib/esm/enums/case.d.ts +1 -2
- package/lib/esm/enums/case.d.ts.map +1 -1
- package/lib/esm/enums/case.js +1 -14
- package/lib/esm/hooks/useExportCaseListCSV.d.ts.map +1 -1
- package/lib/esm/hooks/useExportCaseListCSV.js +9 -1
- package/lib/esm/test-utils/mockData.js +1 -1
- package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
- package/lib/esm/utils/caseSearchUtils.js +6 -28
- package/lib/esm/utils/constants.d.ts +1 -2
- package/lib/esm/utils/constants.d.ts.map +1 -1
- package/lib/esm/utils/constants.js +3 -14
- package/lib/esm/utils/mockSolrResponse.js +1 -1
- package/package.json +6 -7
- package/lib/esm/utils/caseListGraphQLUtils.d.ts +0 -28
- package/lib/esm/utils/caseListGraphQLUtils.d.ts.map +0 -1
- package/lib/esm/utils/caseListGraphQLUtils.js +0 -244
- package/lib/esm/utils/caseListMapper.d.ts +0 -6
- package/lib/esm/utils/caseListMapper.d.ts.map +0 -1
- package/lib/esm/utils/caseListMapper.js +0 -36
- package/lib/esm/utils/caseListVariablesBuilder.d.ts +0 -14
- package/lib/esm/utils/caseListVariablesBuilder.d.ts.map +0 -1
- package/lib/esm/utils/caseListVariablesBuilder.js +0 -193
- package/lib/esm/utils/statusUtils.d.ts +0 -3
- package/lib/esm/utils/statusUtils.d.ts.map +0 -1
- package/lib/esm/utils/statusUtils.js +0 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button, MenuToggle, Select, SelectList, SelectOption, } from '@patternfly/react-core';
|
|
2
|
-
import { useSelectKeyboardNavigator } from '@rh-support/components';
|
|
2
|
+
import { SingleSelectDropdown, 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,38 +9,56 @@ 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;
|
|
12
13
|
const { t } = useTranslation();
|
|
13
14
|
const { filterInfo } = useContext(CaseListFilterStateContext);
|
|
14
15
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
15
16
|
const [isOpen, setIsOpen] = useState(false);
|
|
16
17
|
const [selectedItems, setSelectedItems] = useState({});
|
|
17
|
-
const list =
|
|
18
|
-
value: severity,
|
|
19
|
-
key:
|
|
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,
|
|
20
24
|
}));
|
|
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
|
+
};
|
|
21
30
|
const onToggleClick = (e) => {
|
|
22
31
|
setIsOpen(!isOpen);
|
|
23
32
|
};
|
|
24
33
|
const onSelect = (option) => {
|
|
25
|
-
|
|
26
|
-
if (selectedItems[option.value]) {
|
|
27
|
-
setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
|
|
34
|
+
if (props.isSolrSearchDown) {
|
|
28
35
|
updateFilter(dispatch, {
|
|
29
36
|
filterKey: SolrKeys.severity,
|
|
30
|
-
values:
|
|
37
|
+
values: [option.value],
|
|
31
38
|
});
|
|
39
|
+
setIsOpen(false);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const prevSelectedSeverities = Object.keys(selectedItems).filter((item) => selectedItems[item] && item);
|
|
43
|
+
if (selectedItems[option.value]) {
|
|
44
|
+
setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
|
|
45
|
+
const index = prevSelectedSeverities.indexOf(option.value);
|
|
46
|
+
prevSelectedSeverities.splice(index, 1);
|
|
32
47
|
}
|
|
33
48
|
else {
|
|
34
49
|
setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
|
|
35
|
-
|
|
36
|
-
filterKey: SolrKeys.severity,
|
|
37
|
-
values: [...prevSelectedSeverities, option.value],
|
|
38
|
-
});
|
|
50
|
+
prevSelectedSeverities.push(option.value);
|
|
39
51
|
}
|
|
52
|
+
updateFilter(dispatch, {
|
|
53
|
+
filterKey: SolrKeys.severity,
|
|
54
|
+
values: prevSelectedSeverities,
|
|
55
|
+
});
|
|
40
56
|
};
|
|
57
|
+
// Use the keyboard navigator hook
|
|
41
58
|
const { focusedItemIndex, onInputKeyDown } = useSelectKeyboardNavigator({
|
|
42
59
|
list,
|
|
43
60
|
isOpen,
|
|
61
|
+
resetIndexOnClose: true,
|
|
44
62
|
setIsOpen,
|
|
45
63
|
onSelect,
|
|
46
64
|
});
|
|
@@ -51,17 +69,25 @@ export function SeverityFilter(props) {
|
|
|
51
69
|
values: [],
|
|
52
70
|
});
|
|
53
71
|
};
|
|
54
|
-
const placeholder =
|
|
72
|
+
const placeholder = props.isSolrSearchDown
|
|
73
|
+
? t('Select a severity')
|
|
74
|
+
: getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', list.length, t('All selected'));
|
|
55
75
|
const toggle = (toggleRef) => (React.createElement(MenuToggle, { variant: "default", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true, onKeyDown: onInputKeyDown },
|
|
56
76
|
placeholder,
|
|
57
77
|
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" }))));
|
|
58
|
-
const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox:
|
|
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
|
+
};
|
|
59
85
|
useEffect(() => {
|
|
60
86
|
var _a;
|
|
61
87
|
if (isEmpty(filterInfo[SolrKeys.severity])) {
|
|
62
88
|
setSelectedItems({});
|
|
63
89
|
}
|
|
64
|
-
else {
|
|
90
|
+
else if (!props.isSolrSearchDown) {
|
|
65
91
|
const selectedSeverities = (_a = filterInfo[SolrKeys.severity]) === null || _a === void 0 ? void 0 : _a.reduce((selection, severity) => {
|
|
66
92
|
selection[severity] = true;
|
|
67
93
|
return selection;
|
|
@@ -69,9 +95,9 @@ export function SeverityFilter(props) {
|
|
|
69
95
|
setSelectedItems(selectedSeverities);
|
|
70
96
|
}
|
|
71
97
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
-
}, [filterInfo[SolrKeys.severity]]);
|
|
98
|
+
}, [filterInfo[SolrKeys.severity], props.isSolrSearchDown]);
|
|
73
99
|
return (React.createElement("div", { className: "severity-filter" },
|
|
74
100
|
React.createElement("label", { htmlFor: "case-list-severity-filter", className: "pf-v6-u-mb-sm severity-filter-label" }, t(filterNamesMap[SolrKeys.severity])),
|
|
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))));
|
|
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)))));
|
|
77
103
|
}
|
|
@@ -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":"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,23 +1,43 @@
|
|
|
1
1
|
import { Button, MenuToggle, Select, SelectList, SelectOption, } from '@patternfly/react-core';
|
|
2
|
-
import { useSelectKeyboardNavigator } from '@rh-support/components';
|
|
2
|
+
import { SingleSelectDropdown, 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
|
|
7
|
+
import { filterNamesMap } 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;
|
|
11
12
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
12
13
|
const { t } = useTranslation();
|
|
13
14
|
const { filterInfo } = useContext(CaseListFilterStateContext);
|
|
14
15
|
const [isOpen, setIsOpen] = useState(false);
|
|
15
16
|
const [selectedItems, setSelectedItems] = useState({});
|
|
16
|
-
const list =
|
|
17
|
+
const list = props.isSolrSearchDown
|
|
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
|
+
};
|
|
17
29
|
const onToggleClick = (e) => {
|
|
18
30
|
setIsOpen(!isOpen);
|
|
19
31
|
};
|
|
20
32
|
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
|
+
}
|
|
21
41
|
const prevSelectedStatuses = Object.keys(selectedItems).filter((item) => selectedItems[item] && item);
|
|
22
42
|
if (selectedItems[option.value]) {
|
|
23
43
|
setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
|
|
@@ -55,32 +75,42 @@ export function StatusFilter(props) {
|
|
|
55
75
|
else if (selectedValues && selectedValues.length === 1) {
|
|
56
76
|
return selectedValues[0];
|
|
57
77
|
}
|
|
58
|
-
else if (selectedValues &&
|
|
78
|
+
else if (selectedValues && selectedValues.length === 3) {
|
|
59
79
|
return t('All cases');
|
|
60
80
|
}
|
|
61
81
|
else {
|
|
62
|
-
|
|
63
|
-
selectedValues.
|
|
64
|
-
|
|
65
|
-
if (hasAllOpenSelected) {
|
|
82
|
+
if (selectedValues &&
|
|
83
|
+
selectedValues.length === 2 &&
|
|
84
|
+
selectedValues.every((item) => item.includes('Waiting'))) {
|
|
66
85
|
return t('All open cases');
|
|
67
86
|
}
|
|
87
|
+
else if (selectedValues && totalLength && selectedValues.length === totalLength) {
|
|
88
|
+
return totalLengthString || btnPlaceholder;
|
|
89
|
+
}
|
|
68
90
|
else {
|
|
69
91
|
return `${selectedValues.length} ${type} selected`;
|
|
70
92
|
}
|
|
71
93
|
}
|
|
72
94
|
};
|
|
73
|
-
const placeholder =
|
|
95
|
+
const placeholder = props.isSolrSearchDown
|
|
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'));
|
|
74
98
|
const toggle = (toggleRef) => (React.createElement(MenuToggle, { variant: "default", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true, onKeyDown: onInputKeyDown },
|
|
75
99
|
placeholder,
|
|
76
100
|
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" }))));
|
|
77
|
-
const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox:
|
|
101
|
+
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-status-${option.value.replace(' ', '-')}` }, option.value)));
|
|
102
|
+
const onSingleSelectChange = (option) => {
|
|
103
|
+
updateFilter(dispatch, {
|
|
104
|
+
filterKey: SolrKeys.status,
|
|
105
|
+
values: [option.value],
|
|
106
|
+
});
|
|
107
|
+
};
|
|
78
108
|
useEffect(() => {
|
|
79
109
|
var _a;
|
|
80
110
|
if (isEmpty(filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status])) {
|
|
81
111
|
setSelectedItems({});
|
|
82
112
|
}
|
|
83
|
-
else {
|
|
113
|
+
else if (!props.isSolrSearchDown) {
|
|
84
114
|
const selectedStatuses = (_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) === null || _a === void 0 ? void 0 : _a.reduce((selection, status) => {
|
|
85
115
|
selection[status] = true;
|
|
86
116
|
return selection;
|
|
@@ -88,10 +118,10 @@ export function StatusFilter(props) {
|
|
|
88
118
|
setSelectedItems(selectedStatuses || {});
|
|
89
119
|
}
|
|
90
120
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
-
}, [filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]]);
|
|
121
|
+
}, [filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status], props.isSolrSearchDown]);
|
|
92
122
|
const titleId = 'case-list-status-filter';
|
|
93
123
|
return (React.createElement("div", { className: "status-filter" },
|
|
94
124
|
React.createElement("label", { htmlFor: titleId, className: "pf-v6-u-mb-sm status-filter-label" }, t(filterNamesMap[SolrKeys.status])),
|
|
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))));
|
|
125
|
+
props.isSolrSearchDown ? (React.createElement(SingleSelectDropdown, { id: titleId, selected: selectedOption, options: singleSelectOptions, placeholder: t('Select a status'), onSelect: onSingleSelectChange, dataTrackingId: "status-filter", isScrollable: true })) : (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 } },
|
|
126
|
+
React.createElement(SelectList, null, dropdownOptions)))));
|
|
97
127
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { IProductVersionPivotMap } from '../CaseList';
|
|
2
3
|
import { IProductFilter } from '../CaseListFilterReducer';
|
|
3
4
|
interface IProps {
|
|
4
5
|
productInfo: IProductFilter;
|
|
6
|
+
productVersionPivot: IProductVersionPivotMap[];
|
|
5
7
|
}
|
|
6
|
-
export declare function VersionsFilter({ productInfo }: IProps): React.JSX.Element;
|
|
8
|
+
export declare function VersionsFilter({ productInfo, productVersionPivot }: IProps): React.JSX.Element;
|
|
7
9
|
export {};
|
|
8
10
|
//# 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":"AAeA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAIhF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAoCxE,UAAU,MAAM;IACZ,WAAW,EAAE,cAAc,CAAC;IAC5B,mBAAmB,EAAE,uBAAuB,EAAE,CAAC;CAClD;AAED,wBAAgB,cAAc,CAAC,EAAE,WAAW,EAAE,mBAAmB,EAAE,EAAE,MAAM,qBAkO1E"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { useApolloClient } from '@apollo/client/react';
|
|
2
1
|
import { Button, MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, } from '@patternfly/react-core';
|
|
3
2
|
import TimesIcon from '@patternfly/react-icons/dist/js/icons/times-icon';
|
|
4
3
|
import { useSelectKeyboardNavigator } from '@rh-support/components';
|
|
5
|
-
import { GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
6
|
-
import { GET_PRODUCTS, handleGraphQLVersionsResponse } from '@rh-support/utils';
|
|
7
4
|
import isEmpty from 'lodash/isEmpty';
|
|
8
5
|
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
6
|
import { useTranslation } from 'react-i18next';
|
|
10
7
|
import { SolrKeys, SolrPivotKeys } from '../../../enums/filters';
|
|
11
8
|
import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
|
|
12
9
|
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,62 +33,32 @@ 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, productVersionPivot }) {
|
|
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);
|
|
47
45
|
const [inputValue, setInputValue] = useState('');
|
|
48
46
|
const [activeItem, setActiveItem] = useState(null);
|
|
49
47
|
const [isOpen, setIsOpen] = useState(false);
|
|
50
48
|
const [selectedItems, setSelectedItems] = useState({});
|
|
51
|
-
const [fetchedVersions, setFetchedVersions] = useState([]);
|
|
52
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
53
49
|
const textInputRef = useRef();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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]);
|
|
50
|
+
// Memoize versions to prevent unnecessary recalculations
|
|
51
|
+
const versions = useMemo(() => {
|
|
52
|
+
const versionValues = getVersionValuesForProduct(productVersionPivot, productInfo.value);
|
|
53
|
+
return versionValues === null || versionValues === void 0 ? void 0 : versionValues.sort((a, b) => compareVersions(a.value, b.value));
|
|
54
|
+
}, [productVersionPivot, productInfo.value]);
|
|
55
|
+
// Memoize list to prevent unnecessary recreations
|
|
56
|
+
const list = useMemo(() => (versions === null || versions === void 0 ? void 0 : versions.map((version) => ({
|
|
57
|
+
value: version.value,
|
|
58
|
+
key: version.value,
|
|
59
|
+
}))) || [], [versions]);
|
|
90
60
|
const [selectOptions, setSelectOptions] = useState(list);
|
|
91
|
-
const onToggleClick = () => {
|
|
61
|
+
const onToggleClick = (e) => {
|
|
92
62
|
setIsOpen(!isOpen);
|
|
93
63
|
};
|
|
94
64
|
const onSelect = (option) => {
|
|
@@ -102,17 +72,18 @@ export function VersionsFilter({ productInfo }) {
|
|
|
102
72
|
setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
|
|
103
73
|
prevSelectedVersions.push(option.value);
|
|
104
74
|
}
|
|
105
|
-
const newVersionState = prevSelectedVersions.map((version) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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]) || [])];
|
|
75
|
+
const newVersionState = prevSelectedVersions.map((version) => ({
|
|
76
|
+
field: SolrKeys.version,
|
|
77
|
+
value: version,
|
|
78
|
+
}));
|
|
79
|
+
const productNewState = [...filterInfo[SolrPivotKeys.product_version]];
|
|
114
80
|
const objIndex = productNewState.findIndex((item) => item.value === productInfo.value);
|
|
115
|
-
|
|
81
|
+
// replace product with updated versions
|
|
82
|
+
productNewState[objIndex] = {
|
|
83
|
+
field: SolrKeys.product,
|
|
84
|
+
value: productInfo.value,
|
|
85
|
+
[SolrKeys.version]: newVersionState,
|
|
86
|
+
};
|
|
116
87
|
updateFilter(dispatch, { filterKey: SolrPivotKeys.product_version, values: productNewState });
|
|
117
88
|
};
|
|
118
89
|
// Use the keyboard navigator hook
|
|
@@ -132,7 +103,7 @@ export function VersionsFilter({ productInfo }) {
|
|
|
132
103
|
var _a;
|
|
133
104
|
setInputValue('');
|
|
134
105
|
setSelectedItems({});
|
|
135
|
-
const productNewState = [...
|
|
106
|
+
const productNewState = [...filterInfo[SolrPivotKeys.product_version]];
|
|
136
107
|
const objIndex = productNewState.findIndex((item) => item.value === productInfo.value);
|
|
137
108
|
productNewState[objIndex] = {
|
|
138
109
|
field: SolrKeys.product,
|
|
@@ -146,7 +117,7 @@ export function VersionsFilter({ productInfo }) {
|
|
|
146
117
|
useEffect(() => {
|
|
147
118
|
if (focusedItemIndex !== null && list[focusedItemIndex]) {
|
|
148
119
|
const focusedItem = list[focusedItemIndex];
|
|
149
|
-
setActiveItem(`select-multi-typeahead-checkbox-${
|
|
120
|
+
setActiveItem(`select-multi-typeahead-checkbox-${focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.value.replace(' ', '-')}`);
|
|
150
121
|
}
|
|
151
122
|
else {
|
|
152
123
|
setActiveItem(null);
|
|
@@ -160,7 +131,7 @@ export function VersionsFilter({ productInfo }) {
|
|
|
160
131
|
// Memoize dropdownOptions to prevent unnecessary rerenders
|
|
161
132
|
const dropdownOptions = useMemo(() => {
|
|
162
133
|
const optionsToRender = !isEmpty(selectOptions) ? selectOptions : list;
|
|
163
|
-
return optionsToRender.map((option, index) => option.value && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: true, isSelected: selectedItems[
|
|
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)));
|
|
164
135
|
}, [selectOptions, list, selectedItems, focusedItemIndex]);
|
|
165
136
|
// Update selectOptions when input value changes
|
|
166
137
|
useEffect(() => {
|
|
@@ -185,9 +156,9 @@ export function VersionsFilter({ productInfo }) {
|
|
|
185
156
|
setSelectedItems(selectedVersions);
|
|
186
157
|
}, [productInfo.case_version]);
|
|
187
158
|
const titleId = 'case-list-versions-filter';
|
|
188
|
-
return (React.createElement("div", { className: "version-filter-chip" },
|
|
159
|
+
return (React.createElement(React.Fragment, null, (!isEmpty(versions) || true) && (React.createElement("div", { className: "version-filter-chip" },
|
|
189
160
|
React.createElement("label", { hidden: true, htmlFor: titleId }, t('Open versions dropdown')),
|
|
190
161
|
React.createElement("div", { className: "pf-v6-c-select" },
|
|
191
162
|
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 },
|
|
192
|
-
React.createElement(SelectList, null,
|
|
163
|
+
React.createElement(SelectList, null, dropdownOptions)))))));
|
|
193
164
|
}
|
|
@@ -3,20 +3,16 @@ 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 { ISortInfo } from '../CaseListFilterReducer';
|
|
6
|
+
import { IPaginationInfo, 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;
|
|
12
13
|
isCaseListPageLoading: boolean;
|
|
13
14
|
hasError: boolean;
|
|
14
|
-
|
|
15
|
-
isLoadingMore: boolean;
|
|
16
|
-
loadMoreError: boolean;
|
|
17
|
-
loadMoreRetryCount: number;
|
|
18
|
-
onRetryLoadMore: () => void;
|
|
19
|
-
sentinelRef?: (node?: Element | null) => void;
|
|
15
|
+
isSolrDown?: boolean;
|
|
20
16
|
}
|
|
21
17
|
export declare function CaseListTable(props: IProps): React.JSX.Element;
|
|
22
18
|
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;AAqB3E,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,EAEH,eAAe,EACf,SAAS,EAIZ,MAAM,0BAA0B,CAAC;AA4BlC,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,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAsBD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,qBA6kB1C"}
|