@rh-support/cases 1.0.2 → 1.0.3
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/case-list-filters/ProductsFilter.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/ProductsFilter.js +21 -17
- 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 +19 -20
- 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 +18 -20
- package/lib/esm/components/case-list/case-list-filters/TypeFilter.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/TypeFilter.js +19 -13
- 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 +17 -19
- package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.js +1 -1
- package/lib/esm/components/case-list/case-search/AdvanceSearch.d.ts +1 -1
- package/lib/esm/components/case-list/case-search/AdvanceSearch.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-search/AdvanceSearch.js +29 -49
- package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.js +1 -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 +16 -15
- package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.js +161 -64
- package/lib/esm/css/caseList.css +7 -2
- package/lib/esm/css/caseSearch.css +0 -4
- package/lib/esm/enums/filters.d.ts +35 -1
- package/lib/esm/enums/filters.d.ts.map +1 -1
- package/lib/esm/enums/filters.js +34 -0
- package/lib/esm/utils/caseSearchUtils.d.ts +3 -2
- package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
- package/lib/esm/utils/caseSearchUtils.js +66 -11
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductsFilter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProductsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductsFilter.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAe,MAAM,0BAA0B,CAAC;AAUvE,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,eA0E3C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
|
|
2
|
+
import { MultiSelectDropDownList } from '@rh-support/components';
|
|
3
|
+
import { getDropdownBtnPlaceholder, toOptions } from '@rh-support/utils';
|
|
4
|
+
import React, { useContext, useState } from 'react';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
6
|
import { SolrKeys, SolrPivotKeys } from '../../../enums/filters';
|
|
6
7
|
import { filterNamesMap } from '../../../utils/constants';
|
|
@@ -10,6 +11,8 @@ export function ProductsFilter(props) {
|
|
|
10
11
|
const { t } = useTranslation();
|
|
11
12
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
12
13
|
const { filterInfo } = useContext(CaseListFilterStateContext);
|
|
14
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
15
|
+
const toggleIsOpen = (isExpanded) => setIsOpen(isExpanded);
|
|
13
16
|
const onFilterChangeMultipleSelect = (selectedProducts) => {
|
|
14
17
|
selectedProducts = selectedProducts.map((selectedProduct) => ({
|
|
15
18
|
field: SolrKeys.product,
|
|
@@ -18,23 +21,24 @@ export function ProductsFilter(props) {
|
|
|
18
21
|
}));
|
|
19
22
|
updateFilter(dispatch, { filterKey: SolrPivotKeys.product_version, values: selectedProducts });
|
|
20
23
|
};
|
|
21
|
-
const onFilterChangeSingleSelect = (selectedProduct) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
value: selectedProduct.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
updateFilter(dispatch, { filterKey: SolrPivotKeys.product_version, values: [selectedProduct] });
|
|
24
|
+
const onFilterChangeSingleSelect = (event, selectedProduct) => {
|
|
25
|
+
updateFilter(dispatch, {
|
|
26
|
+
filterKey: SolrPivotKeys.product_version,
|
|
27
|
+
values: [{ field: SolrKeys.product, value: selectedProduct, [SolrKeys.version]: [] }],
|
|
28
|
+
});
|
|
29
|
+
setIsOpen(false);
|
|
28
30
|
};
|
|
29
|
-
const
|
|
30
|
-
labelKey: 'value',
|
|
31
|
-
});
|
|
31
|
+
const titleId = 'case-list-products-filter';
|
|
32
32
|
// solr is down and solr filter values are not available
|
|
33
33
|
// we get filter values from hydra metadata api
|
|
34
34
|
const singleSelectSolrIsDown = () => {
|
|
35
|
-
var _a;
|
|
36
|
-
return (React.createElement(
|
|
35
|
+
var _a, _b;
|
|
36
|
+
return (React.createElement(Select, { variant: SelectVariant.single, "aria-label": "Select Input", onToggle: toggleIsOpen, onSelect: onFilterChangeSingleSelect, selections: (_b = (_a = filterInfo[SolrPivotKeys.product_version]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.value, isOpen: isOpen, "aria-labelledby": titleId, placeholderText: t('Select a product'), "data-tracking-id": "products-filter" }, props.allProducts.map((product) => (React.createElement(SelectOption, { key: product, value: product })))));
|
|
37
37
|
};
|
|
38
|
-
const multiSelect = () => (React.createElement(MultiSelectDropDownList, { placeholder: getDropdownBtnPlaceholder(t('Select a product'), filterInfo[SolrPivotKeys.product_version].map((i) => i.value), '
|
|
39
|
-
|
|
38
|
+
const multiSelect = () => (React.createElement(MultiSelectDropDownList, { placeholder: getDropdownBtnPlaceholder(t('Select a product'), filterInfo[SolrPivotKeys.product_version].map((i) => i.value), '', props.filterValues.length, t('All selected')), "data-tracking-id": "products-filter", id: "case-list-products-filter", title: t(filterNamesMap[SolrKeys.product]), onChange: onFilterChangeMultipleSelect, selectedItems: toOptions(filterInfo[SolrPivotKeys.product_version], { labelKey: 'value' }), list: toOptions(props.filterValues, {
|
|
39
|
+
labelKey: 'value',
|
|
40
|
+
}), searchable: true }));
|
|
41
|
+
return (React.createElement("div", { className: "pf-c-select" },
|
|
42
|
+
React.createElement("label", { id: titleId }, t(filterNamesMap[SolrKeys.product])),
|
|
43
|
+
props.isSolrSearchDown ? singleSelectSolrIsDown() : multiSelect()));
|
|
40
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SeverityFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/SeverityFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"SeverityFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/SeverityFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAU1D,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,eA8E3C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getDropdownBtnPlaceholder
|
|
3
|
-
import React, { useContext } from 'react';
|
|
1
|
+
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
|
|
2
|
+
import { getDropdownBtnPlaceholder } from '@rh-support/utils';
|
|
3
|
+
import React, { useContext, useState } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { SolrKeys } from '../../../enums/filters';
|
|
6
6
|
import { filterNamesMap } from '../../../utils/constants';
|
|
@@ -10,25 +10,24 @@ export function SeverityFilter(props) {
|
|
|
10
10
|
const { t } = useTranslation();
|
|
11
11
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
12
12
|
const { filterInfo } = useContext(CaseListFilterStateContext);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
14
|
+
const toggleIsOpen = (isExpanded) => setIsOpen(isExpanded);
|
|
15
|
+
const onFilterChangeMultipleSelect = (event, selectedSeverities) => {
|
|
16
|
+
const newState = filterInfo[SolrKeys.severity].includes(selectedSeverities)
|
|
17
|
+
? filterInfo[SolrKeys.severity].filter((item) => item !== selectedSeverities)
|
|
18
|
+
: [...filterInfo[SolrKeys.severity], selectedSeverities];
|
|
19
|
+
updateFilter(dispatch, { filterKey: SolrKeys.severity, values: newState });
|
|
16
20
|
};
|
|
17
|
-
const onFilterChangeSingleSelect = (selectedSeverity) => {
|
|
18
|
-
updateFilter(dispatch, { filterKey: SolrKeys.severity, values: [selectedSeverity
|
|
21
|
+
const onFilterChangeSingleSelect = (event, selectedSeverity) => {
|
|
22
|
+
updateFilter(dispatch, { filterKey: SolrKeys.severity, values: [selectedSeverity] });
|
|
23
|
+
setIsOpen(false);
|
|
19
24
|
};
|
|
20
|
-
const
|
|
21
|
-
key: filterValue.value,
|
|
22
|
-
value: filterValue.value,
|
|
23
|
-
})), {
|
|
24
|
-
labelKey: 'value',
|
|
25
|
-
});
|
|
25
|
+
const titleId = 'case-list-severity-filter';
|
|
26
26
|
// solr is down and solr filter values are not available
|
|
27
27
|
// we get filter values from hydra metadata api
|
|
28
|
-
const singleSelectSolrIsDown = () => (React.createElement(
|
|
29
|
-
const multiSelect = () => (React.createElement(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return React.createElement(React.Fragment, null, props.isSolrSearchDown ? singleSelectSolrIsDown() : multiSelect());
|
|
28
|
+
const singleSelectSolrIsDown = () => (React.createElement(Select, { id: titleId, variant: SelectVariant.single, "aria-label": "Select Input", onToggle: toggleIsOpen, onSelect: onFilterChangeSingleSelect, selections: filterInfo[SolrKeys.severity][0], isOpen: isOpen, "aria-labelledby": titleId, placeholderText: t('Select a severity'), "data-tracking-id": "severity-filter", hasPlaceholderStyle: true }, props.allCaseSeverities.map((severity) => (React.createElement(SelectOption, { key: severity, value: severity })))));
|
|
29
|
+
const multiSelect = () => (React.createElement(Select, { id: titleId, variant: SelectVariant.checkbox, "aria-label": t('Select a severity'), onToggle: toggleIsOpen, onSelect: onFilterChangeMultipleSelect, selections: filterInfo[SolrKeys.severity], isOpen: isOpen, placeholderText: getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', props.filterValues.length, t('All selected')), isCheckboxSelectionBadgeHidden: true, "aria-labelledby": titleId, "data-tracking-id": "severity-filter", hasPlaceholderStyle: true }, props.filterValues.map((filterValue) => (React.createElement(SelectOption, { key: filterValue.value, value: filterValue.value })))));
|
|
30
|
+
return (React.createElement("div", { className: "pf-c-select" },
|
|
31
|
+
React.createElement("label", { htmlFor: titleId }, t(filterNamesMap[SolrKeys.severity])),
|
|
32
|
+
props.isSolrSearchDown ? singleSelectSolrIsDown() : multiSelect()));
|
|
34
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/StatusFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"StatusFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/StatusFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQ1D,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,eA4GzC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import React, { useContext } from 'react';
|
|
1
|
+
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
|
|
2
|
+
import React, { useContext, useState } from 'react';
|
|
4
3
|
import { useTranslation } from 'react-i18next';
|
|
5
4
|
import { SolrKeys } from '../../../enums/filters';
|
|
6
5
|
import { filterNamesMap } from '../../../utils/constants';
|
|
@@ -10,12 +9,17 @@ export function StatusFilter(props) {
|
|
|
10
9
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
11
10
|
const { t } = useTranslation();
|
|
12
11
|
const { filterInfo } = useContext(CaseListFilterStateContext);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
13
|
+
const toggleIsOpen = (isExpanded) => setIsOpen(isExpanded);
|
|
14
|
+
const onFilterChange = (event, selectedStatus) => {
|
|
15
|
+
const newState = filterInfo[SolrKeys.status].includes(selectedStatus)
|
|
16
|
+
? filterInfo[SolrKeys.status].filter((item) => item !== selectedStatus)
|
|
17
|
+
: [...filterInfo[SolrKeys.status], selectedStatus];
|
|
18
|
+
updateFilter(dispatch, { filterKey: SolrKeys.status, values: newState });
|
|
16
19
|
};
|
|
17
|
-
const onFilterChangeSingleSelect = (selectedStatus) => {
|
|
18
|
-
updateFilter(dispatch, { filterKey: SolrKeys.status, values: [selectedStatus
|
|
20
|
+
const onFilterChangeSingleSelect = (event, selectedStatus) => {
|
|
21
|
+
updateFilter(dispatch, { filterKey: SolrKeys.status, values: [selectedStatus] });
|
|
22
|
+
setIsOpen(false);
|
|
19
23
|
};
|
|
20
24
|
const getBtnPlaceholder = (btnPlaceholder, selectedValues, type, totalLength, totalLengthString) => {
|
|
21
25
|
if (!selectedValues || (selectedValues && selectedValues.length === 0)) {
|
|
@@ -41,18 +45,12 @@ export function StatusFilter(props) {
|
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
};
|
|
44
|
-
const
|
|
45
|
-
key: filterValue.value,
|
|
46
|
-
value: filterValue.value,
|
|
47
|
-
})), {
|
|
48
|
-
labelKey: 'value',
|
|
49
|
-
});
|
|
48
|
+
const titleId = 'case-list-status-filter';
|
|
50
49
|
// solr is down and solr filter values are not available
|
|
51
50
|
// we get filter values from hydra metadata api
|
|
52
|
-
const singleSelectSolrIsDown = () => (React.createElement(
|
|
53
|
-
const multiSelect = () => (React.createElement(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return React.createElement(React.Fragment, null, props.isSolrSearchDown ? singleSelectSolrIsDown() : multiSelect());
|
|
51
|
+
const singleSelectSolrIsDown = () => (React.createElement(Select, { id: titleId, variant: SelectVariant.single, "aria-label": "Select Input", onToggle: toggleIsOpen, onSelect: onFilterChangeSingleSelect, selections: filterInfo[SolrKeys.status][0], isOpen: isOpen, "aria-labelledby": titleId, placeholderText: t('Select a status'), "data-tracking-id": "status-filter", hasPlaceholderStyle: true }, props.allCaseStatuses.map((status) => (React.createElement(SelectOption, { key: status, value: status })))));
|
|
52
|
+
const multiSelect = () => (React.createElement(Select, { id: titleId, variant: SelectVariant.checkbox, "aria-label": t('Select a status'), onToggle: toggleIsOpen, onSelect: onFilterChange, selections: filterInfo[SolrKeys.status], isOpen: isOpen, placeholderText: getBtnPlaceholder(t('Select a status'), filterInfo[SolrKeys.status], ' ', props.filterValues.length, t('All selected')), isCheckboxSelectionBadgeHidden: true, "aria-labelledby": titleId, "data-tracking-id": "status-filter", hasPlaceholderStyle: true }, props.filterValues.map((filterValue) => (React.createElement(SelectOption, { key: filterValue.value, value: filterValue.value })))));
|
|
53
|
+
return (React.createElement("div", { className: "pf-c-select" },
|
|
54
|
+
React.createElement("label", { htmlFor: titleId }, t(filterNamesMap[SolrKeys.status])),
|
|
55
|
+
props.isSolrSearchDown ? singleSelectSolrIsDown() : multiSelect()));
|
|
58
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/TypeFilter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TypeFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/TypeFilter.tsx"],"names":[],"mappings":"AAUA,UAAU,MAAM;IACZ,YAAY,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAkDvC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { Trans, useTranslation } from 'react-i18next';
|
|
1
|
+
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
|
|
2
|
+
import { getDropdownBtnPlaceholder } from '@rh-support/utils';
|
|
3
|
+
import React, { useContext, useState } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
6
5
|
import { SolrKeys } from '../../../enums/filters';
|
|
7
6
|
import { filterNamesMap } from '../../../utils/constants';
|
|
8
7
|
import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
|
|
@@ -11,12 +10,19 @@ export function TypeFilter(props) {
|
|
|
11
10
|
const { t } = useTranslation();
|
|
12
11
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
13
12
|
const { filterInfo } = useContext(CaseListFilterStateContext);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
14
|
+
const toggleIsOpen = (isExpanded) => setIsOpen(isExpanded);
|
|
15
|
+
const onFilterChangeMultipleSelect = (event, selectedTypes) => {
|
|
16
|
+
const newState = filterInfo[SolrKeys.type].includes(selectedTypes)
|
|
17
|
+
? filterInfo[SolrKeys.type].filter((item) => item !== selectedTypes)
|
|
18
|
+
: [...filterInfo[SolrKeys.type], selectedTypes];
|
|
19
|
+
updateFilter(dispatch, {
|
|
20
|
+
filterKey: SolrKeys.type,
|
|
21
|
+
values: newState,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const titleId = 'case-list-type-filter';
|
|
25
|
+
return (React.createElement("div", { className: "pf-c-select" },
|
|
26
|
+
React.createElement("label", { htmlFor: titleId }, t(filterNamesMap[SolrKeys.type])),
|
|
27
|
+
React.createElement(Select, { id: titleId, variant: SelectVariant.checkbox, "aria-label": t('Select a case type'), onToggle: toggleIsOpen, onSelect: onFilterChangeMultipleSelect, selections: filterInfo[SolrKeys.type], isOpen: isOpen, placeholderText: getDropdownBtnPlaceholder(t('Select a case type'), filterInfo[SolrKeys.type], ' ', props.allCaseTypes.length, t('All selected')), isCheckboxSelectionBadgeHidden: true, "aria-labelledby": titleId, "data-tracking-id": "type-filter", hasPlaceholderStyle: true }, props.allCaseTypes.map((filterValue) => (React.createElement(SelectOption, { key: filterValue, value: filterValue }))))));
|
|
22
28
|
}
|
|
@@ -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":"AAMA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAMxE,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,eA2D1E"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { toOptions } from '@rh-support/utils';
|
|
1
|
+
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
|
|
3
2
|
import isEmpty from 'lodash/isEmpty';
|
|
4
|
-
import React, { useContext } from 'react';
|
|
3
|
+
import React, { useContext, useState } from 'react';
|
|
5
4
|
import { useTranslation } from 'react-i18next';
|
|
6
5
|
import { SolrKeys, SolrPivotKeys } from '../../../enums/filters';
|
|
7
6
|
import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
|
|
@@ -13,27 +12,26 @@ export function VersionsFilter({ productInfo, productVersionPivot }) {
|
|
|
13
12
|
const { t } = useTranslation();
|
|
14
13
|
const { filterInfo } = useContext(CaseListFilterStateContext);
|
|
15
14
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
16
|
-
const
|
|
17
|
-
|
|
15
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
16
|
+
const toggleIsOpen = (isExpanded) => setIsOpen(isExpanded);
|
|
17
|
+
const onFilterChange = (event, selectedVer) => {
|
|
18
|
+
const newVerionState = productInfo.case_version.map((version) => version.value).includes(selectedVer)
|
|
19
|
+
? productInfo.case_version.filter((item) => item.value !== selectedVer)
|
|
20
|
+
: [...productInfo.case_version, { field: SolrKeys.version, value: selectedVer }];
|
|
18
21
|
// find current product from previous state
|
|
19
|
-
const
|
|
20
|
-
const objIndex =
|
|
22
|
+
const productNewState = [...filterInfo[SolrPivotKeys.product_version]];
|
|
23
|
+
const objIndex = productNewState.findIndex((item) => item.value === productInfo.value);
|
|
21
24
|
// replace product with updated versions
|
|
22
|
-
|
|
25
|
+
productNewState[objIndex] = {
|
|
23
26
|
field: SolrKeys.product,
|
|
24
27
|
value: productInfo.value,
|
|
25
|
-
[SolrKeys.version]:
|
|
28
|
+
[SolrKeys.version]: newVerionState,
|
|
26
29
|
};
|
|
27
|
-
updateFilter(dispatch, { filterKey: SolrPivotKeys.product_version, values:
|
|
28
|
-
};
|
|
29
|
-
const getSelectedVersionsArray = (productValue) => {
|
|
30
|
-
const selectedVersions = filterInfo[SolrPivotKeys.product_version].find((item) => item.value === productValue);
|
|
31
|
-
return (selectedVersions && selectedVersions[SolrKeys.version]) || [];
|
|
30
|
+
updateFilter(dispatch, { filterKey: SolrPivotKeys.product_version, values: productNewState });
|
|
32
31
|
};
|
|
33
32
|
const versions = getVersionValuesForProduct(productVersionPivot, productInfo.value);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}) || [], className: "pf-c-select filter-chip-version-selector" }))));
|
|
33
|
+
const titleId = 'case-list-versions-filter';
|
|
34
|
+
return (React.createElement(React.Fragment, null, !isEmpty(versions) && (React.createElement(React.Fragment, null,
|
|
35
|
+
React.createElement("label", { hidden: true, htmlFor: titleId }, t('Open versions dropdown')),
|
|
36
|
+
React.createElement(Select, { variant: SelectVariant.checkbox, "aria-label": t('Version'), onToggle: toggleIsOpen, onSelect: onFilterChange, selections: productInfo.case_version.map((ver) => ver.value), isOpen: isOpen, placeholderText: 'Version', isCheckboxSelectionBadgeHidden: true, "aria-labelledby": titleId, "data-tracking-id": "versions-filter", hasPlaceholderStyle: true }, (versions || []).map((filterValue) => (React.createElement(SelectOption, { key: filterValue.value, value: filterValue.value, component: "div" }))))))));
|
|
39
37
|
}
|
|
@@ -106,7 +106,7 @@ export function ExportCaseListCSV(props) {
|
|
|
106
106
|
}
|
|
107
107
|
return tooltipText;
|
|
108
108
|
};
|
|
109
|
-
return (React.createElement("span", { title: props.isExportCsvDisabled && getTooltipContent() },
|
|
109
|
+
return (React.createElement("span", { title: (props.isExportCsvDisabled && getTooltipContent()) || '' },
|
|
110
110
|
React.createElement(Button, { variant: "tertiary", isDisabled: isBtnDisabled || props.isExportCsvDisabled, onClick: loggedInUsersAccount.data.secureSupport ? onExportCSVClickSecureSupport : onExportCSVClick, title: btnTitle, "data-tracking-id": "case-list-toolbar-export-csv" }, isFetchingCSVData ? (React.createElement(React.Fragment, null,
|
|
111
111
|
React.createElement(Trans, null, "Exporting CSV"),
|
|
112
112
|
React.createElement("i", { className: "fa fa-circle-o-notch fa-spin fa-fw", "aria-label": "loading" }))) : (React.createElement(Trans, null, "Export CSV")))));
|
|
@@ -3,7 +3,7 @@ interface IProps {
|
|
|
3
3
|
onSearchValChange?: (newVal: string) => void;
|
|
4
4
|
onSearchTypeChange?: (newType: CaseSearchQueryType) => void;
|
|
5
5
|
onSearchClear?: () => void;
|
|
6
|
-
onSearchSubmit: (parsedQuery: string) => void;
|
|
6
|
+
onSearchSubmit: (type: CaseSearchQueryType, parsedQuery: string) => void;
|
|
7
7
|
onAdvancedSearchValidation: (validation: boolean) => void;
|
|
8
8
|
}
|
|
9
9
|
export declare function AdvanceSearch(props: IProps): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdvanceSearch.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-search/AdvanceSearch.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AdvanceSearch.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-search/AdvanceSearch.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAKhE,UAAU,MAAM;IACZ,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,cAAc,EAAE,CAAC,IAAI,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACzE,0BAA0B,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,eAgT1C"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { Button } from '@patternfly/react-core';
|
|
2
2
|
import InfoIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
|
|
3
3
|
import TimesCircleIcon from '@patternfly/react-icons/dist/js/icons/times-circle-icon';
|
|
4
|
-
import { GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
5
4
|
import isEmpty from 'lodash/isEmpty';
|
|
6
5
|
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
7
6
|
import { Trans, useTranslation } from 'react-i18next';
|
|
8
7
|
import { CaseSearchQueryType } from '../../../enums/caseSearch';
|
|
9
|
-
import { createFilterStateFromAdvancedQuery } from '../../../utils/caseSearchUtils';
|
|
10
8
|
import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
|
|
11
|
-
import { updateFilterQuery
|
|
9
|
+
import { updateFilterQuery } from '../CaseListFilterReducer';
|
|
12
10
|
import useAdvanceSearchParser from './useAdvanceSearchParser';
|
|
13
11
|
export function AdvanceSearch(props) {
|
|
14
12
|
const { t } = useTranslation();
|
|
@@ -16,17 +14,17 @@ export function AdvanceSearch(props) {
|
|
|
16
14
|
const { filterQueryInfo } = filterState;
|
|
17
15
|
const isFirstMountRef = useRef(true);
|
|
18
16
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
19
|
-
const [
|
|
17
|
+
const [inputString, setInputString] = useState('');
|
|
20
18
|
const [autoCompleteList, setAutoCompleteList] = useState([]);
|
|
21
19
|
const dropdownWrapperRef = useRef(null);
|
|
22
20
|
const parseQuery = () => {
|
|
23
21
|
try {
|
|
24
|
-
parse(
|
|
22
|
+
parse(inputString);
|
|
25
23
|
setIsParsingSuccessful(true);
|
|
26
24
|
props.onAdvancedSearchValidation(true);
|
|
27
25
|
try {
|
|
28
26
|
// to trigger the autocomplete on a valid selection
|
|
29
|
-
parse(
|
|
27
|
+
parse(inputString + ' ');
|
|
30
28
|
}
|
|
31
29
|
catch (e) {
|
|
32
30
|
parserErrorRef.current = e;
|
|
@@ -37,33 +35,21 @@ export function AdvanceSearch(props) {
|
|
|
37
35
|
setIsParsingSuccessful(false);
|
|
38
36
|
props.onAdvancedSearchValidation(false);
|
|
39
37
|
parserErrorRef.current = e;
|
|
40
|
-
autoCompleteSetup(e.expected,
|
|
38
|
+
autoCompleteSetup(e.expected, inputString.substring(e.location.start.offset, inputString.length));
|
|
41
39
|
}
|
|
42
40
|
};
|
|
43
41
|
const { parse, parseSafe, parserRef } = useAdvanceSearchParser({ onInit: parseQuery });
|
|
44
42
|
const [isAutoCompleteListVisible, setIsAutoCompleteListVisible] = useState(false);
|
|
45
43
|
const [isParsingSuccessful, setIsParsingSuccessful] = useState(false);
|
|
46
44
|
const parserErrorRef = useRef(null);
|
|
47
|
-
const { globalMetadataState } = useContext(GlobalMetadataStateContext);
|
|
48
|
-
const [showComplexQueryError, setShowComplexQueryError] = useState(false);
|
|
49
45
|
const searchInputRef = useRef(null);
|
|
50
46
|
const [selectedItemIndex, setSelectedItemIndex] = useState(null);
|
|
51
|
-
const isSameFieldIncludedTwice = () => {
|
|
52
|
-
const allFields = (queryString || '').match(/[\w]+:/g) || [];
|
|
53
|
-
return allFields.length !== new Set(allFields).size;
|
|
54
|
-
};
|
|
55
47
|
useEffect(() => {
|
|
56
|
-
if (
|
|
48
|
+
if (filterQueryInfo.type === CaseSearchQueryType.BASIC)
|
|
57
49
|
return;
|
|
58
|
-
|
|
59
|
-
filterQueryInfo.queryString &&
|
|
60
|
-
updateFilterQuery(dispatch, {
|
|
61
|
-
type: CaseSearchQueryType.ADVANCED,
|
|
62
|
-
queryString: filterQueryInfo.queryString,
|
|
63
|
-
parsedQuery: parseSafe(filterQueryInfo.queryString),
|
|
64
|
-
});
|
|
50
|
+
setInputString(filterQueryInfo === null || filterQueryInfo === void 0 ? void 0 : filterQueryInfo.parsedQuery);
|
|
65
51
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
-
}, [filterQueryInfo.
|
|
52
|
+
}, [filterQueryInfo === null || filterQueryInfo === void 0 ? void 0 : filterQueryInfo.parsedQuery]);
|
|
67
53
|
useEffect(() => {
|
|
68
54
|
if (isFirstMountRef.current) {
|
|
69
55
|
isFirstMountRef.current = false;
|
|
@@ -72,10 +58,9 @@ export function AdvanceSearch(props) {
|
|
|
72
58
|
if (!parserRef.current)
|
|
73
59
|
return;
|
|
74
60
|
parseQuery();
|
|
75
|
-
|
|
76
|
-
props.onSearchValChange && props.onSearchValChange(queryString);
|
|
61
|
+
props.onSearchValChange && props.onSearchValChange(inputString);
|
|
77
62
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
|
-
}, [
|
|
63
|
+
}, [inputString]);
|
|
79
64
|
const handleClickOutside = (e) => {
|
|
80
65
|
if (dropdownWrapperRef.current.contains(e.target)) {
|
|
81
66
|
// inside click
|
|
@@ -97,7 +82,7 @@ export function AdvanceSearch(props) {
|
|
|
97
82
|
}, [isAutoCompleteListVisible]);
|
|
98
83
|
const onQueryStringChange = (ev) => {
|
|
99
84
|
const query = ev.target.value;
|
|
100
|
-
|
|
85
|
+
setInputString(query);
|
|
101
86
|
};
|
|
102
87
|
const autoCompleteSetup = (expectedArray = null, phrase = '') => {
|
|
103
88
|
const autocomplete = [];
|
|
@@ -157,7 +142,7 @@ export function AdvanceSearch(props) {
|
|
|
157
142
|
}
|
|
158
143
|
};
|
|
159
144
|
const onItemClick = (itemValue) => {
|
|
160
|
-
|
|
145
|
+
setInputString(inputString.substring(0, parserErrorRef.current.location.start.offset) + itemValue);
|
|
161
146
|
searchInputRef.current.focus();
|
|
162
147
|
};
|
|
163
148
|
const onInputFocus = () => {
|
|
@@ -204,51 +189,46 @@ export function AdvanceSearch(props) {
|
|
|
204
189
|
return false;
|
|
205
190
|
};
|
|
206
191
|
const onClear = () => {
|
|
207
|
-
|
|
192
|
+
setInputString('');
|
|
208
193
|
setAutoCompleteList([]);
|
|
209
194
|
setIsAutoCompleteListVisible(false);
|
|
210
195
|
props.onSearchClear && props.onSearchClear();
|
|
211
196
|
};
|
|
212
197
|
const onSearchSubmit = () => {
|
|
213
|
-
const parsedQuery = parseSafe(
|
|
198
|
+
const parsedQuery = parseSafe(inputString);
|
|
214
199
|
setIsAutoCompleteListVisible(false);
|
|
215
|
-
props.onSearchSubmit && props.onSearchSubmit(parsedQuery);
|
|
216
|
-
};
|
|
217
|
-
const canSwitchToBasicSearch = () => {
|
|
218
|
-
return !(queryString || '').match(/ or /i) && !isSameFieldIncludedTwice();
|
|
200
|
+
props.onSearchSubmit && props.onSearchSubmit(CaseSearchQueryType.ADVANCED, parsedQuery);
|
|
219
201
|
};
|
|
220
202
|
const onBasicClick = () => {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
if (queryString) {
|
|
226
|
-
const updatedFilterState = createFilterStateFromAdvancedQuery(parseSafe(queryString).replace(/ and /g, ' AND ').replace(/ or /g, ' OR '), globalMetadataState, filterState);
|
|
227
|
-
if (updatedFilterState.filterQueryInfo.queryString === '') {
|
|
203
|
+
var _a, _b;
|
|
204
|
+
if (inputString) {
|
|
205
|
+
if (((_a = filterState.filterQueryInfo) === null || _a === void 0 ? void 0 : _a.queryString) === '') {
|
|
228
206
|
props.onSearchValChange && props.onSearchValChange('');
|
|
229
207
|
}
|
|
230
|
-
|
|
208
|
+
updateFilterQuery(dispatch, {
|
|
209
|
+
type: CaseSearchQueryType.BASIC,
|
|
210
|
+
queryString: ((_b = filterState.filterQueryInfo) === null || _b === void 0 ? void 0 : _b.queryString) || '',
|
|
211
|
+
parsedQuery: '',
|
|
212
|
+
});
|
|
231
213
|
}
|
|
232
214
|
else {
|
|
233
|
-
updateFilterQuery(dispatch, Object.assign(Object.assign({}, filterQueryInfo), { type: CaseSearchQueryType.BASIC }));
|
|
215
|
+
updateFilterQuery(dispatch, Object.assign(Object.assign({}, filterState.filterQueryInfo), { type: CaseSearchQueryType.BASIC }));
|
|
234
216
|
}
|
|
235
217
|
props.onSearchTypeChange && props.onSearchTypeChange(CaseSearchQueryType.BASIC);
|
|
236
218
|
};
|
|
237
|
-
const isQueryInValid =
|
|
219
|
+
const isQueryInValid = inputString && !isParsingSuccessful;
|
|
238
220
|
return (React.createElement(React.Fragment, null,
|
|
239
221
|
React.createElement("div", { className: "pf-c-select pf-m-expanded", ref: dropdownWrapperRef },
|
|
240
222
|
React.createElement("div", { className: "pf-c-select__toggle pf-m-typeahead" },
|
|
241
223
|
React.createElement("div", { className: "pf-c-select__toggle-wrapper" },
|
|
242
|
-
React.createElement("input", { value:
|
|
243
|
-
|
|
224
|
+
React.createElement("input", { value: inputString, onChange: onQueryStringChange, onFocus: onInputFocus, ref: searchInputRef, onKeyDown: onKeyDown, placeholder: t('i18nEnterSolrQuery', 'Enter SOLR query, for example: severity:"1 (Urgent)" and -status:"Waiting on Customer"'), className: `pf-c-form-control pf-c-select__toggle-typeahead ${inputString && isParsingSuccessful ? 'pf-m-success' : ''}`, type: "text", "aria-invalid": isQueryInValid ? true : false, autoComplete: "off", id: "advance-search-typeahead", "aria-label": t('Enter search query'), "aria-describedby": "advance-query-error-helper" })),
|
|
225
|
+
inputString && (React.createElement(Button, { onClick: onClear, className: "pf-c-button pf-m-plain pf-c-select__toggle-clear", variant: "plain", "data-tracking-id": "clear-search", "aria-label": t('Clear this search') },
|
|
244
226
|
React.createElement(TimesCircleIcon, null)))),
|
|
245
|
-
showComplexQueryError && (React.createElement("p", { className: "pf-c-form__helper-text pf-m-error", style: { color: '#c9190b' }, id: "advance-query-error-helper", "aria-live": "polite" },
|
|
246
|
-
React.createElement(Trans, null, "The advance query you entered is too complex to switch back to a basic search. Try revising or clearing this query."))),
|
|
247
227
|
isAutoCompleteListVisible && (React.createElement("ul", { className: "pf-c-select__menu", "aria-labelledby": "advance-search-typeahead-label", role: "listbox" }, autoCompleteList.map((item, index) => (React.createElement("li", { key: index, role: "presentation", className: `pf-c-select__menu-wrapper ${selectedItemIndex === index ? 'pf-m-focus' : ''}` },
|
|
248
228
|
React.createElement("button", { type: "button", onClick: (e) => onItemClick(item.value), className: "pf-c-select__menu-item", "aria-selected": selectedItemIndex === index ? true : false, role: "option" }, item.display))))))),
|
|
249
|
-
React.createElement(Button, { type: "button", variant: "primary", "data-tracking-id": "case-list-adv-search-button", className: "pf-u-ml-sm", onClick: onSearchSubmit, isDisabled: (isEmpty(
|
|
229
|
+
React.createElement(Button, { type: "button", variant: "primary", "data-tracking-id": "case-list-adv-search-button", className: "pf-u-ml-sm", onClick: onSearchSubmit, isDisabled: (isEmpty(inputString) && isEmpty(filterQueryInfo === null || filterQueryInfo === void 0 ? void 0 : filterQueryInfo.parsedQuery)) || !isParsingSuccessful },
|
|
250
230
|
React.createElement(Trans, null, "Search")),
|
|
251
|
-
React.createElement(Button, { variant: "link",
|
|
231
|
+
React.createElement(Button, { variant: "link", onClick: onBasicClick, "data-tracking-id": "case-list-basic-toggle-button" },
|
|
252
232
|
React.createElement(Trans, null, "Basic")),
|
|
253
233
|
React.createElement(Button, { variant: "link", className: "pf-u-px-0", component: "a", rel: "noopener noreferrer", target: "_blank", href: "https://source.redhat.com/communitiesatredhat/applications/integration-community-of-practice/all/testallin/all_in_blog/advanced_search_in_the_customer_support_tool", "data-tracking-id": "advance-search-guide" },
|
|
254
234
|
React.createElement(InfoIcon, null))));
|
|
@@ -149,7 +149,7 @@ export function BookmarkedSearchesSelector(props) {
|
|
|
149
149
|
.sort()
|
|
150
150
|
.map((bookmarkedSearch) => {
|
|
151
151
|
var _a;
|
|
152
|
-
return (React.createElement("li", { className: "pf-c-dropdown__menu-item pf-u-p-xs" },
|
|
152
|
+
return (React.createElement("li", { className: "pf-c-dropdown__menu-item pf-u-p-xs", key: bookmarkedSearch },
|
|
153
153
|
React.createElement(Split, { key: `split-parent-${bookmarkedSearch}` },
|
|
154
154
|
React.createElement(SplitItem, { isFilled: true, key: `split-left-${bookmarkedSearch}` },
|
|
155
155
|
React.createElement(Button, { variant: ButtonVariant.plain, isBlock: true, className: "pf-u-text-align-left", onClick: onBookmarkSelectorChange(bookmarkedSearch, bookmarkedSearches[bookmarkedSearch], true) },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaseSearch.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-search/CaseSearch.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CaseSearch.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-search/CaseSearch.tsx"],"names":[],"mappings":"AAkBA,UAAU,MAAM;IACZ,sBAAsB,EAAE,MAAM,CAAC;CAClC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAuKvC"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Button, SearchInput } from '@patternfly/react-core';
|
|
2
|
+
import { GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
2
3
|
import { AbilityContext, CaseListFields, resourceActions, resources } from '@rh-support/user-permissions';
|
|
3
4
|
import isEmpty from 'lodash/isEmpty';
|
|
4
5
|
import React, { useContext, useEffect, useState } from 'react';
|
|
5
6
|
import { Trans, useTranslation } from 'react-i18next';
|
|
6
7
|
import { CaseSearchQueryType } from '../../../enums/caseSearch';
|
|
7
|
-
import {
|
|
8
|
-
import { createAdvancedSearchQueryFromFilterState } from '../../../utils/caseSearchUtils';
|
|
8
|
+
import { createFilterStateFromAdvancedQuery, createUserFriendlyQueryFromFilterStateAdvancedSearch, } from '../../../utils/caseSearchUtils';
|
|
9
9
|
import { useCaseListStateContext } from '../CaseListContext';
|
|
10
10
|
import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
|
|
11
|
-
import {
|
|
11
|
+
import { updateFilterQuery, updateFilterState } from '../CaseListFilterReducer';
|
|
12
12
|
import { AdvanceSearch } from './AdvanceSearch';
|
|
13
13
|
import { BookmarkedSearchesSelector } from './BookmarkedSearchesSelector';
|
|
14
14
|
export function CaseSearch(props) {
|
|
15
|
+
const { globalMetadataState } = useContext(GlobalMetadataStateContext);
|
|
15
16
|
const { t } = useTranslation();
|
|
16
17
|
const ability = useContext(AbilityContext);
|
|
17
18
|
const canUseAdvancedSearch = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.ADVANCED_SEARCH);
|
|
@@ -22,12 +23,10 @@ export function CaseSearch(props) {
|
|
|
22
23
|
const [isAdvancedSearchValid, setIsAdvancedSearchValid] = useState(true);
|
|
23
24
|
const dispatch = useContext(CaseListFilterDispatchContext);
|
|
24
25
|
const { isFetching } = useCaseListStateContext();
|
|
26
|
+
// on queryString and parsedQuery change need to update search
|
|
25
27
|
useEffect(() => {
|
|
26
|
-
if (searchVal === filterQueryInfo.queryString)
|
|
27
|
-
return;
|
|
28
28
|
setSearchVal(filterQueryInfo.queryString);
|
|
29
|
-
|
|
30
|
-
}, [filterQueryInfo.queryString]);
|
|
29
|
+
}, [filterQueryInfo]);
|
|
31
30
|
useEffect(() => {
|
|
32
31
|
if (searchType === filterQueryInfo.type)
|
|
33
32
|
return;
|
|
@@ -50,18 +49,20 @@ export function CaseSearch(props) {
|
|
|
50
49
|
const onCaseSearch = (parsedQuery = '', queryString = searchVal) => {
|
|
51
50
|
updateFilterQuery(dispatch, { type: searchType, queryString, parsedQuery });
|
|
52
51
|
};
|
|
52
|
+
const onCaseSearchAdvanced = (type, parsedQuery = '', queryStringInputBox = searchVal) => {
|
|
53
|
+
const newFilterState = createFilterStateFromAdvancedQuery(parsedQuery.replace(/ and /g, ' AND ').replace(/ or /g, ' OR '), globalMetadataState, filterState, queryStringInputBox, type);
|
|
54
|
+
// here should create filter
|
|
55
|
+
updateFilterState(dispatch, newFilterState);
|
|
56
|
+
};
|
|
53
57
|
const onSearchTypeChange = (newType) => {
|
|
58
|
+
var _a, _b;
|
|
54
59
|
if (newType === CaseSearchQueryType.ADVANCED) {
|
|
55
|
-
const
|
|
56
|
-
SolrKeys.accountNumber,
|
|
57
|
-
SolrKeys.escalation,
|
|
58
|
-
]);
|
|
60
|
+
const parsedQuery = createUserFriendlyQueryFromFilterStateAdvancedSearch(filterState.filterInfo, (_a = filterState.filterQueryInfo) === null || _a === void 0 ? void 0 : _a.queryString, true);
|
|
59
61
|
updateFilterQuery(dispatch, {
|
|
60
62
|
type: CaseSearchQueryType.ADVANCED,
|
|
61
|
-
queryString:
|
|
62
|
-
parsedQuery
|
|
63
|
+
queryString: (_b = filterState.filterQueryInfo) === null || _b === void 0 ? void 0 : _b.queryString,
|
|
64
|
+
parsedQuery,
|
|
63
65
|
});
|
|
64
|
-
updateFilterState(dispatch, { filterInfo: initialFilterInfo });
|
|
65
66
|
}
|
|
66
67
|
setSearchType(newType);
|
|
67
68
|
};
|
|
@@ -91,7 +92,7 @@ export function CaseSearch(props) {
|
|
|
91
92
|
};
|
|
92
93
|
const renderAdvanceSearch = () => {
|
|
93
94
|
return canUseAdvancedSearch ? (React.createElement(React.Fragment, null,
|
|
94
|
-
React.createElement(AdvanceSearch, { onSearchValChange: onSearchValChange, onSearchClear: clearSearchVal, onSearchSubmit:
|
|
95
|
+
React.createElement(AdvanceSearch, { onSearchValChange: onSearchValChange, onSearchClear: clearSearchVal, onSearchSubmit: onCaseSearchAdvanced, onSearchTypeChange: onSearchTypeChange, onAdvancedSearchValidation: (isValid) => setIsAdvancedSearchValid(isValid) }))) : (React.createElement(React.Fragment, null));
|
|
95
96
|
};
|
|
96
97
|
return (React.createElement(React.Fragment, null,
|
|
97
98
|
React.createElement("form", { onSubmit: handleSubmit, onKeyDown: handleSearchInputKeyDown },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAdvanceSearchParser.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-search/useAdvanceSearchParser.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAdvanceSearchParser.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-search/useAdvanceSearchParser.tsx"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAAE,MAAM,EAAE;;CAAA;yBASzB,MAAM;6BAIF,MAAM;;EAwLzC"}
|
|
@@ -3,20 +3,12 @@ import PEG from 'pegjs';
|
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
4
|
import { SolrKeys } from '../../../enums/filters';
|
|
5
5
|
import { useCaseListStateContext } from '../CaseListContext';
|
|
6
|
-
// escaped from solrGrammar.txt
|
|
7
|
-
const grammarStringInternal = '{\r\n function joinByOr(val) {\r\n return "(" + [].concat.apply([], val).filter(function(item) {return item !== \' \'}).join(" or ")+")";\r\n }\r\n}\r\n\r\nquery = sequence\r\n\r\nsequence = first:sequencePart cont:sequenceCont { return first + cont; }\r\nsequenceCont = orSequence / andSequence / ""\r\n\r\nandSequence = parts:(" and " sequencePart)+ { return [].concat.apply([], parts).join(""); }\r\norSequence = parts:(" or " sequencePart)+ { return [].concat.apply([], parts).join(""); }\r\nsequencePart = criteria / "(" sq:sequence ")" { return \'(\' + sq + \')\' }\r\n\r\n\r\ncriteria = basicCriteria / notCriteria\r\nnotCriteria = "-"criteria:basicCriteria {return \'-\' + criteria; }\r\nbasicCriteria = field:basicFieldName ":"" "* value:value { return field + ":" + value; }\r\n/ field:severityFieldName ":"" "* value:severityValue { return field + ":" + value; }\r\n/ field:statusFieldName ":"" "* value:statusValue { return field + ":" + value; }\r\n/ field:groupFieldName ":"" "* value:groupValue { return field + ":" + value; }\r\n/ field:caseTypeFieldName ":"" "* value:caseTypeValue { return field + ":" + value; }\r\n/ field:productFieldName ":"" "* value:productValue { return field + ":" + value; }\r\n/ field:ftsFieldName ":"" "* value:booleanValue { return field + ":" + value; }\r\n/ field:accountNumberFieldName ":"" "* value:accountNumberValue { return field + ":" + value; }\r\n/ field:accountNameFieldName ":"" "* value:accountNameValue { return field + ":" + value; }\r\n/ field:escalatedFieldName ":"" "* value:booleanValue { return field + ":" + value; }\r\n/ field:cepFieldName ":"" "* value:booleanValue { return field + ":" + value; }\r\n/ field:contactSSOFieldName ":"" "* value:stringOrMulti { return field + ":" + value; }\r\n/ field:ownerSSOFieldName ":"" "* value:stringOrMulti { return field + ":" + value; }\r\n/ field:createdBySSOFieldName ":"" "* value:stringOrMulti { return field + ":" + value; }\r\n/ field:textFieldName ":"" "* value:value { return value; }\r\n\r\nvalue = range / string\r\nrange = "[" from:([^" "]+) " TO " to:([^\\]]+) "]" {return "[" + from.join("") + " TO " + to.join("") + "]"; }\r\nstring = quoted_term / unquoted_term / _\r\n\r\nunquoted_term\r\n = term:term_char+\r\n { \r\n return term.join(\'\');\r\n }\r\n\r\nterm_char\r\n = [^: \\t\\r\\n\\f\\{\\}()"+-/^~\\[\\]]\r\n\r\n \r\nquoted_term\r\n = \'"\' term:[^"]+ \'"\'\r\n {\r\n return \'"\' + term.join(\'\') + \'"\';\r\n }\r\nbooleanValue = "true" / "false"\r\nnumber = digits:[0-9]+ { return digits.join(\'\'); }\r\nmultipleValue = "(" val:(value)+ ")" { return joinByOr(val); }\r\nstringOrMulti = string / multipleValue\r\n\r\nbasicFieldName = "contactName" {return "case_contactName";}\r\n/ "createdByName" {return "case_createdByName";}\r\n/ "createdDate" {return "case_createdDate";}\r\n/ "closedDate" {return "case_closedDate";}\r\n/ "description" {return "case_description";}\r\n/ "summary" {return "case_summary";}\r\n/ "productVersion" {return "case_version";}\r\n/ "lastModifiedDate" {return "case_lastModifiedDate";}\r\n/ "lastModifiedByName" {return "case_lastModifiedByName";}\r\n/ "ownerName" {return "case_owner";}\r\n/ "caseNumber" {return "case_number";}\r\n/ "openshiftClusterId" {return "case_openshift_cluster_id";}\r\n/ "alternateCaseId" {return "case_alternate_id";}\r\n\r\ncepFieldName = "CEP" {return "case_is_cep";}\r\nftsFieldName = "FTS" {return "case_24_7";}\r\nescalatedFieldName = "escalated" {return "case_customer_escalation";}\r\ncontactSSOFieldName = "contactSSO" {return "case_contact_sso_username";}\r\nownerSSOFieldName = "ownerSSO" {return "case_owner_sso_username";}\r\ncreatedBySSOFieldName = "createdBySSO" {return "case_createdby_sso_username";}\r\ntextFieldName = "text" {return "";}\r\n\r\nseverityFieldName = "severity" {return "case_severity";}\r\nseverityValue = string / severityMultipleValue / _ \r\nseverityMultipleValue = "(" val:(severityValue)+ ")" { return joinByOr(val); }\r\n\r\nstatusFieldName = "status" {return "case_status";}\r\nstatusValue = string / statusMultipleValue / _ \r\nstatusMultipleValue = "(" val:(statusValue)+ ")" { return joinByOr(val); }\r\n\r\ngroupFieldName = "group" {return "case_folderNumber";}\r\ngroupValue = string / groupMultipleValue / _ \r\ngroupMultipleValue = "(" val:(groupValue)+ ")" { return joinByOr(val); }\r\n\r\ncaseTypeFieldName = "caseType" {return "case_type";}\r\ncaseTypeValue = string / caseTypeMultipleValue / _ \r\ncaseTypeMultipleValue = "(" val:(caseTypeValue)+ ")" { return joinByOr(val); }\r\n\r\nproductFieldName = "productName" { return "case_product"; }\r\nproductValue = string / productMultipleValue / _ \r\nproductMultipleValue = "(" val:(productValue)+ ")" { return joinByOr(val); }\r\n\r\naccountNumberFieldName = "accountNumber" {return "case_accountNumber";}\r\naccountNumberValue = number / string / accountNumberMultipleValue / _ \r\naccountNumberMultipleValue = "(" val:(accountNumberValue)+ ")" { return joinByOr(val); }\r\n\r\naccountNameFieldName = "accountName" { return "case_account_name";}\r\naccountNameValue = string / accountNameMultipleValue / _ \r\naccountNameMultipleValue = "(" val:(accountNameValue)+ ")" { return joinByOr(val); }\r\n\r\n_ "whitespace"\r\n = [ \\t\\r\\n\\f]+';
|
|
8
6
|
export default function useAdvanceSearchParser({ onInit }) {
|
|
9
7
|
const { filterValuesFromFacetResponse } = useCaseListStateContext();
|
|
10
8
|
const { globalMetadataState: { caseGroups, loggedInUsersAccount, bookmarkedGroupAccounts, allCaseTypes }, } = useGlobalStateContext();
|
|
11
|
-
const grammerStringRef = useRef(grammarStringInternal);
|
|
12
9
|
const parserRef = useRef(null);
|
|
13
10
|
const parse = (stringQuery) => {
|
|
14
|
-
|
|
15
|
-
// so we just intialise the parser with basic grammar without values
|
|
16
|
-
if (!parserRef.current) {
|
|
17
|
-
initParser();
|
|
18
|
-
}
|
|
19
|
-
return parserRef.current.parse(stringQuery);
|
|
11
|
+
return parserRef.current.parse(stringQuery.replace(/ +/g, ' '));
|
|
20
12
|
};
|
|
21
13
|
const parseSafe = (stringQuery) => {
|
|
22
14
|
try {
|
|
@@ -25,69 +17,174 @@ export default function useAdvanceSearchParser({ onInit }) {
|
|
|
25
17
|
catch (e) { }
|
|
26
18
|
return '';
|
|
27
19
|
};
|
|
28
|
-
const initParser = () => {
|
|
20
|
+
const initParser = (grammer) => {
|
|
29
21
|
try {
|
|
30
|
-
parserRef.current = PEG.generate(
|
|
22
|
+
parserRef.current = PEG.generate(grammer);
|
|
31
23
|
}
|
|
32
|
-
catch (
|
|
24
|
+
catch (e) {
|
|
33
25
|
parserRef.current = null;
|
|
34
26
|
}
|
|
35
27
|
};
|
|
36
|
-
//
|
|
28
|
+
// init grammar parser once we have the values from facets
|
|
37
29
|
useEffect(() => {
|
|
38
|
-
if (!filterValuesFromFacetResponse
|
|
30
|
+
if (!filterValuesFromFacetResponse ||
|
|
31
|
+
caseGroups.isFetching ||
|
|
32
|
+
allCaseTypes.isFetching ||
|
|
33
|
+
bookmarkedGroupAccounts.isFetching ||
|
|
34
|
+
loggedInUsersAccount.isFetching)
|
|
39
35
|
return;
|
|
40
|
-
const statusValues = filterValuesFromFacetResponse[SolrKeys.status]
|
|
41
|
-
.map((status) => `"\\"${status.value}\\"" { return '"${status.value}"'; }`)
|
|
42
|
-
.join(' / ');
|
|
43
|
-
const severityValues = filterValuesFromFacetResponse[SolrKeys.severity]
|
|
44
|
-
.map((severity) => `"\\"${severity.value}\\"" { return '"${severity.value}"'; }`)
|
|
45
|
-
.join(' / ');
|
|
46
|
-
const productValues = filterValuesFromFacetResponse[SolrKeys.product]
|
|
47
|
-
.map((product) => `"\\"${product.value}\\"" { return '"${product.value}"'; }`)
|
|
48
|
-
.join(' / ');
|
|
49
|
-
writeValuesToGrammarString('status', statusValues);
|
|
50
|
-
writeValuesToGrammarString('severity', severityValues);
|
|
51
|
-
writeValuesToGrammarString('product', productValues);
|
|
52
|
-
initParser();
|
|
53
|
-
// // parse on page load so that we have the autocomplete setup on first load
|
|
54
|
-
onInit && onInit();
|
|
55
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
-
}, [filterValuesFromFacetResponse, caseGroups.data]);
|
|
57
|
-
// write case groups to solr grammar string
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
const groupValues = (caseGroups.data || [])
|
|
60
|
-
.map((group) => `"\\"${group.name}\\"" { return '${group.groupNum}'; }`)
|
|
61
|
-
.join(' / ');
|
|
62
|
-
writeValuesToGrammarString('group', groupValues);
|
|
63
|
-
initParser();
|
|
64
|
-
}, [caseGroups.data]);
|
|
65
|
-
// write case types to solr grammar string
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
const caseTypeValues = (allCaseTypes.data || [])
|
|
68
|
-
.map((caseType) => `"\\"${caseType}\\"" { return '"${caseType}"'; }`)
|
|
69
|
-
.join(' / ');
|
|
70
|
-
writeValuesToGrammarString('caseType', caseTypeValues);
|
|
71
|
-
initParser();
|
|
72
|
-
}, [allCaseTypes.data]);
|
|
73
|
-
// write account numbers and account name to solr grammar string
|
|
74
|
-
useEffect(() => {
|
|
75
36
|
const accounts = (bookmarkedGroupAccounts.data || []);
|
|
76
37
|
const allAccounts = [...accounts, loggedInUsersAccount.data];
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
38
|
+
const grammarStringInternal = `
|
|
39
|
+
{
|
|
40
|
+
function joinByOr(val) {
|
|
41
|
+
return "(" + [].concat.apply([], val).filter(function(item) {return item !== ' '}).join(" OR ")+")";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
query = sequence
|
|
46
|
+
|
|
47
|
+
sequence = first:sequencePart cont:sequenceCont { return first + cont; }
|
|
48
|
+
|
|
49
|
+
sequenceCont = orSequence / andSequence / ""
|
|
50
|
+
|
|
51
|
+
andSequence = parts:(" and " sequencePart)+ { return [].concat.apply([], parts).join(""); }
|
|
52
|
+
orSequence = parts:(" or " sequencePart)+ { return [].concat.apply([], parts).join(""); }
|
|
53
|
+
sequencePart = criteria / "(" sq:sequence ")" { return '(' + sq + ')' }
|
|
54
|
+
|
|
55
|
+
criteria = basicCriteria / notCriteria
|
|
56
|
+
notCriteria = "-"criteria:basicCriteria {return '-' + criteria; }
|
|
57
|
+
basicCriteria = field:basicFieldName ":"" "* value:value { return field + ":" + value; }
|
|
58
|
+
/ field:severityFieldName ":"" "* value:severityValue { return field + ":" + value; }
|
|
59
|
+
/ field:statusFieldName ":"" "* value:statusValue { return field + ":" + value; }
|
|
60
|
+
/ field:groupFieldName ":"" "* value:groupValue { return field + ":" + value; }
|
|
61
|
+
/ field:caseTypeFieldName ":"" "* value:caseTypeValue { return field + ":" + value; }
|
|
62
|
+
/ field:productFieldName ":"" "* value:productValue { return field + ":" + value; }
|
|
63
|
+
/ field:versionFieldName ":"" "* value:versionValue { return field + ":" + value; }
|
|
64
|
+
/ field:ftsFieldName ":"" "* value:booleanValue { return field + ":" + value; }
|
|
65
|
+
/ field:accountNumberFieldName ":"" "* value:accountNumberValue { return field + ":" + value; }
|
|
66
|
+
/ field:accountNameFieldName ":"" "* value:accountNameValue { return field + ":" + value; }
|
|
67
|
+
/ field:escalatedFieldName ":"" "* value:booleanValue { return field + ":" + value; }
|
|
68
|
+
/ field:cepFieldName ":"" "* value:booleanValue { return field + ":" + value; }
|
|
69
|
+
/ field:contactSSOFieldName ":"" "* value:stringOrMulti { return field + ":" + value; }
|
|
70
|
+
/ field:ownerSSOFieldName ":"" "* value:stringOrMulti { return field + ":" + value; }
|
|
71
|
+
/ field:createdBySSOFieldName ":"" "* value:stringOrMulti { return field + ":" + value; }
|
|
72
|
+
/ field:textFieldName ":"" "* value:value { return value; }
|
|
73
|
+
|
|
74
|
+
value = range / string
|
|
75
|
+
range = "[" from:([^" "]+) " TO " to:([^\\]]+) "]" {return "[" + from.join("") + " TO " + to.join("") + "]"; }
|
|
76
|
+
string = quoted_term / unquoted_term / _
|
|
77
|
+
|
|
78
|
+
unquoted_term
|
|
79
|
+
= term:term_char+
|
|
80
|
+
{
|
|
81
|
+
return term.join('');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
term_char
|
|
85
|
+
= [^: \\t\\r\\n\\f\\{\\}()"+-/^~\\[\\]]
|
|
86
|
+
|
|
87
|
+
quoted_term
|
|
88
|
+
= '"' term:[^"]+ '"'
|
|
89
|
+
{
|
|
90
|
+
return '"' + term.join('') + '"';
|
|
91
|
+
}
|
|
92
|
+
booleanValue = "true" / "false"
|
|
93
|
+
number = digits:[0-9]+ { return digits.join(''); }
|
|
94
|
+
multipleValue = "(" val:(value)+ ")" { return joinByOr(val); }
|
|
95
|
+
stringOrMulti = string / multipleValue
|
|
96
|
+
|
|
97
|
+
basicFieldName = "contactName" {return "${SolrKeys.contactName}";}
|
|
98
|
+
/ "createdByName" {return "${SolrKeys.createdBy}";}
|
|
99
|
+
/ "createdDate" {return "${SolrKeys.createdDate}";}
|
|
100
|
+
/ "closedDate" {return "${SolrKeys.caseClosedDate}";}
|
|
101
|
+
/ "description" {return "${SolrKeys.description}";}
|
|
102
|
+
/ "summary" {return "${SolrKeys.caseSummary}";}
|
|
103
|
+
/ "lastModifiedDate" {return "${SolrKeys.modifiedDate}";}
|
|
104
|
+
/ "lastModifiedByName" {return "${SolrKeys.modifiedBy}";}
|
|
105
|
+
/ "ownerName" {return "${SolrKeys.ownerName}";}
|
|
106
|
+
/ "caseNumber" {return "${SolrKeys.caseNumber}";}
|
|
107
|
+
/ "openshiftClusterId" {return "${SolrKeys.openshiftClusterId}";}
|
|
108
|
+
/ "alternateCaseId" {return "${SolrKeys.alternateId}";}
|
|
109
|
+
|
|
110
|
+
cepFieldName = "CEP" {return "${SolrKeys.cep}";}
|
|
111
|
+
ftsFieldName = "FTS" {return "${SolrKeys.fts}";}
|
|
112
|
+
escalatedFieldName = "escalated" {return "${SolrKeys.escalation}";}
|
|
113
|
+
contactSSOFieldName = "contactSSO" {return "${SolrKeys.caseContactSSO}";}
|
|
114
|
+
ownerSSOFieldName = "ownerSSO" {return "${SolrKeys.caseOwner}";}
|
|
115
|
+
createdBySSOFieldName = "createdBySSO" {return "${SolrKeys.createdBySsoUsername}";}
|
|
116
|
+
textFieldName = "text" {return "";}
|
|
117
|
+
|
|
118
|
+
severityFieldName = "severity" {return "${SolrKeys.severity}";}
|
|
119
|
+
severityValue = string
|
|
120
|
+
/${(filterValuesFromFacetResponse[SolrKeys.severity] || [])
|
|
121
|
+
.map((severity) => `'"${severity.value}"' { return '"${severity.value}"'; } `)
|
|
122
|
+
.join(' / ')}
|
|
123
|
+
/ severityMultipleValue / _
|
|
124
|
+
severityMultipleValue = "(" val:(severityValue)+ ")" { return joinByOr(val); }
|
|
125
|
+
|
|
126
|
+
statusFieldName = "status" {return "${SolrKeys.status}";}
|
|
127
|
+
statusValue = string
|
|
128
|
+
/${(filterValuesFromFacetResponse[SolrKeys.status] || [])
|
|
129
|
+
.map((status) => `'"${status.value}"' { return '"${status.value}"'; } `)
|
|
130
|
+
.join(' / ')}
|
|
131
|
+
/ statusMultipleValue / _
|
|
132
|
+
statusMultipleValue = "(" val:(statusValue)+ ")" { return joinByOr(val); }
|
|
133
|
+
|
|
134
|
+
groupFieldName = "group" {return "${SolrKeys.group}";}
|
|
135
|
+
groupValue = string
|
|
136
|
+
/ ${(caseGroups.data || []).map((group) => `'"${group.name}"' { return '${group.groupNum}'; }`).join(' / ')}
|
|
137
|
+
/ groupMultipleValue / _
|
|
138
|
+
groupMultipleValue = "(" val:(groupValue)+ ")" { return joinByOr(val); }
|
|
139
|
+
|
|
140
|
+
caseTypeFieldName = "caseType" {return "${SolrKeys.type}";}
|
|
141
|
+
caseTypeValue = string
|
|
142
|
+
/ ${(allCaseTypes.data || []).map((caseType) => `'"${caseType}"' { return '"${caseType}"'; }`).join(' / ')}
|
|
143
|
+
/ caseTypeMultipleValue / _
|
|
144
|
+
caseTypeMultipleValue = "(" val:(caseTypeValue)+ ")" { return joinByOr(val); }
|
|
145
|
+
|
|
146
|
+
productFieldName = "productName" { return "${SolrKeys.product}"; }
|
|
147
|
+
productValue = string
|
|
148
|
+
/ ${(filterValuesFromFacetResponse[SolrKeys.product] || [])
|
|
149
|
+
.map((product) => `'"${product.value}"' { return '"${product.value}"'; } `)
|
|
150
|
+
.join(' / ')}
|
|
151
|
+
/ productMultipleValue / _
|
|
152
|
+
productMultipleValue = "(" val:(productValue)+ ")" { return joinByOr(val); }
|
|
153
|
+
|
|
154
|
+
versionFieldName = "productVersion" { return "${SolrKeys.version}"; }
|
|
155
|
+
versionValue = string
|
|
156
|
+
/ versionMultipleValue / _
|
|
157
|
+
versionMultipleValue = "(" val:(versionValue)+ ")" { return joinByOr(val); }
|
|
158
|
+
|
|
159
|
+
accountNumberFieldName = "accountNumber" {return "${SolrKeys.accountNumber}";}
|
|
160
|
+
accountNumberValue = number
|
|
161
|
+
/ string
|
|
162
|
+
/ ${allAccounts.map((account) => `"${account.accountNumber}" { return "${account.accountNumber}"; }`).join(' / ')}
|
|
163
|
+
/ accountNumberMultipleValue / _
|
|
164
|
+
accountNumberMultipleValue = "(" val:(accountNumberValue)+ ")" { return joinByOr(val); }
|
|
165
|
+
|
|
166
|
+
accountNameFieldName = "accountName" { return "case_account_name";}
|
|
167
|
+
accountNameValue = string
|
|
168
|
+
/ ${allAccounts.map((account) => `'"${account.name}"' { return "${account.name}"; }`).join(' / ')}
|
|
169
|
+
/ accountNameMultipleValue / _
|
|
170
|
+
accountNameMultipleValue = "(" val:(accountNameValue)+ ")" { return joinByOr(val); }
|
|
171
|
+
|
|
172
|
+
_ "whitespace"
|
|
173
|
+
= [ \\t\\r\\n\\f]+
|
|
174
|
+
|
|
175
|
+
EOF
|
|
176
|
+
= !.
|
|
177
|
+
`;
|
|
178
|
+
initParser(grammarStringInternal);
|
|
179
|
+
// parse on page load so that we have the autocomplete setup on first load
|
|
180
|
+
onInit && onInit();
|
|
181
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
182
|
+
}, [
|
|
183
|
+
filterValuesFromFacetResponse,
|
|
184
|
+
caseGroups.isFetching,
|
|
185
|
+
allCaseTypes.isFetching,
|
|
186
|
+
bookmarkedGroupAccounts.isFetching,
|
|
187
|
+
loggedInUsersAccount.isFetching,
|
|
188
|
+
]);
|
|
92
189
|
return { parse, parseSafe, parserRef };
|
|
93
190
|
}
|
package/lib/esm/css/caseList.css
CHANGED
|
@@ -155,11 +155,12 @@
|
|
|
155
155
|
font-size: 14px;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
.cases-main .case-search-top .filter-chip-wrapper .
|
|
158
|
+
.cases-main .case-search-top .filter-chip-wrapper button.pf-c-select__toggle {
|
|
159
159
|
font-size: 13px;
|
|
160
|
+
--pf-c-select__toggle-text--Color: var(--pf-c-select__toggle--m-placeholder__toggle-text--Color) !important;
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
.cases-main .case-search-top .filter-chip-wrapper .
|
|
163
|
+
.cases-main .case-search-top .filter-chip-wrapper button.pf-c-select__toggle svg {
|
|
163
164
|
margin-left: 4px;
|
|
164
165
|
}
|
|
165
166
|
|
|
@@ -469,3 +470,7 @@
|
|
|
469
470
|
min-width: 10%;
|
|
470
471
|
max-width: 10%;
|
|
471
472
|
}
|
|
473
|
+
|
|
474
|
+
.filter-group .pf-c-select__toggle {
|
|
475
|
+
--pf-c-select__toggle-text--Color: var(--pf-c-select__toggle--m-placeholder__toggle-text--Color) !important;
|
|
476
|
+
}
|
|
@@ -35,8 +35,42 @@ export declare enum SolrKeys {
|
|
|
35
35
|
cep = "case_is_cep",
|
|
36
36
|
accountName = "case_accountName",
|
|
37
37
|
alternateId = "case_alternate_id",
|
|
38
|
-
caseClosedDate = "case_closedDate"
|
|
38
|
+
caseClosedDate = "case_closedDate",
|
|
39
|
+
openshiftClusterId = "case_openshift_cluster_id"
|
|
39
40
|
}
|
|
41
|
+
export declare const advancedSearchMap: {
|
|
42
|
+
case_number: string;
|
|
43
|
+
case_summary: string;
|
|
44
|
+
case_product: string;
|
|
45
|
+
case_status: string;
|
|
46
|
+
case_accountNumber: string;
|
|
47
|
+
case_folderNumber: string;
|
|
48
|
+
case_folderName: string;
|
|
49
|
+
case_severity: string;
|
|
50
|
+
case_owner_sso_username: string;
|
|
51
|
+
case_owner: string;
|
|
52
|
+
case_contactName: string;
|
|
53
|
+
case_contact_sso_username: string;
|
|
54
|
+
case_customer_escalation: string;
|
|
55
|
+
case_version: string;
|
|
56
|
+
case_createdByName: string;
|
|
57
|
+
case_createdby_sso_username: string;
|
|
58
|
+
case_createdDate: string;
|
|
59
|
+
case_lastModifiedByName: string;
|
|
60
|
+
case_lastModifiedDate: string;
|
|
61
|
+
case_last_public_update_date: string;
|
|
62
|
+
case_last_public_update_by: string;
|
|
63
|
+
case_description: string;
|
|
64
|
+
uri: string;
|
|
65
|
+
case_24_7: string;
|
|
66
|
+
case_type: string;
|
|
67
|
+
case_is_cep: string;
|
|
68
|
+
case_accountName: string;
|
|
69
|
+
case_alternate_id: string;
|
|
70
|
+
case_closedDate: string;
|
|
71
|
+
case_openshift_cluster_id: string;
|
|
72
|
+
case_account_name: string;
|
|
73
|
+
};
|
|
40
74
|
export declare enum SolrPivotKeys {
|
|
41
75
|
product_version = "case_product,case_version"
|
|
42
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../src/enums/filters.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAChB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;CACpB;AAED,oBAAY,QAAQ;IAChB,UAAU,gBAAgB;IAC1B,WAAW,iBAAiB;IAC5B,OAAO,iBAAiB;IACxB,MAAM,gBAAgB;IACtB,aAAa,uBAAuB;IACpC,KAAK,sBAAsB;IAC3B,SAAS,oBAAoB;IAC7B,QAAQ,kBAAkB;IAC1B,SAAS,4BAA4B;IACrC,SAAS,eAAe;IACxB,WAAW,qBAAqB;IAChC,cAAc,8BAA8B;IAC5C,UAAU,6BAA6B;IACvC,OAAO,iBAAiB;IACxB,SAAS,uBAAuB;IAChC,oBAAoB,gCAAgC;IACpD,WAAW,qBAAqB;IAChC,UAAU,4BAA4B;IACtC,YAAY,0BAA0B;IACtC,oBAAoB,iCAAiC;IACrD,sBAAsB,+BAA+B;IACrD,WAAW,qBAAqB;IAChC,GAAG,QAAQ;IACX,GAAG,cAAc;IACjB,IAAI,cAAc;IAClB,GAAG,gBAAgB;IACnB,WAAW,qBAAqB;IAChC,WAAW,sBAAsB;IACjC,cAAc,oBAAoB;
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../src/enums/filters.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAChB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;CACpB;AAED,oBAAY,QAAQ;IAChB,UAAU,gBAAgB;IAC1B,WAAW,iBAAiB;IAC5B,OAAO,iBAAiB;IACxB,MAAM,gBAAgB;IACtB,aAAa,uBAAuB;IACpC,KAAK,sBAAsB;IAC3B,SAAS,oBAAoB;IAC7B,QAAQ,kBAAkB;IAC1B,SAAS,4BAA4B;IACrC,SAAS,eAAe;IACxB,WAAW,qBAAqB;IAChC,cAAc,8BAA8B;IAC5C,UAAU,6BAA6B;IACvC,OAAO,iBAAiB;IACxB,SAAS,uBAAuB;IAChC,oBAAoB,gCAAgC;IACpD,WAAW,qBAAqB;IAChC,UAAU,4BAA4B;IACtC,YAAY,0BAA0B;IACtC,oBAAoB,iCAAiC;IACrD,sBAAsB,+BAA+B;IACrD,WAAW,qBAAqB;IAChC,GAAG,QAAQ;IACX,GAAG,cAAc;IACjB,IAAI,cAAc;IAClB,GAAG,gBAAgB;IACnB,WAAW,qBAAqB;IAChC,WAAW,sBAAsB;IACjC,cAAc,oBAAoB;IAClC,kBAAkB,8BAA8B;CACnD;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgC7B,CAAC;AAGF,oBAAY,aAAa;IACrB,eAAe,8BAA8B;CAChD;AAED,eAAO,MAAM,iBAAiB,QAA4C,CAAC;AAC3E,oBAAY,QAAQ;IAChB,UAAU,eAAe;IACzB,WAAW,YAAY;IACvB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,aAAa,qBAAqB;IAClC,QAAQ,aAAa;IACrB,SAAS,YAAY;IACrB,WAAW,gBAAgB;IAC3B,SAAS,mBAAmB;IAC5B,UAAU,uBAAuB;IACjC,OAAO,YAAY;IACnB,SAAS,gBAAgB;IACzB,oBAAoB,gCAAgC;IACpD,WAAW,gBAAgB;IAC3B,UAAU,qBAAqB;IAC/B,YAAY,qBAAqB;IACjC,oBAAoB,qBAAqB;IACzC,sBAAsB,qBAAqB;IAC3C,WAAW,gBAAgB;IAC3B,GAAG,QAAQ;IACX,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,QAAQ,aAAa;IACrB,cAAc,iBAAiB;CAClC;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;CAsB9B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;CAElC,CAAC"}
|
package/lib/esm/enums/filters.js
CHANGED
|
@@ -38,7 +38,41 @@ export var SolrKeys;
|
|
|
38
38
|
SolrKeys["accountName"] = "case_accountName";
|
|
39
39
|
SolrKeys["alternateId"] = "case_alternate_id";
|
|
40
40
|
SolrKeys["caseClosedDate"] = "case_closedDate";
|
|
41
|
+
SolrKeys["openshiftClusterId"] = "case_openshift_cluster_id";
|
|
41
42
|
})(SolrKeys || (SolrKeys = {}));
|
|
43
|
+
export const advancedSearchMap = {
|
|
44
|
+
case_number: 'caseNumber',
|
|
45
|
+
case_summary: 'summary',
|
|
46
|
+
case_product: 'productName',
|
|
47
|
+
case_status: 'status',
|
|
48
|
+
case_accountNumber: 'accountNumber',
|
|
49
|
+
case_folderNumber: 'group',
|
|
50
|
+
case_folderName: 'groupName',
|
|
51
|
+
case_severity: 'severity',
|
|
52
|
+
case_owner_sso_username: 'caseOwner',
|
|
53
|
+
case_owner: 'ownerName',
|
|
54
|
+
case_contactName: 'contactName',
|
|
55
|
+
case_contact_sso_username: 'contactSSO',
|
|
56
|
+
case_customer_escalation: 'escalated',
|
|
57
|
+
case_version: 'productVersion',
|
|
58
|
+
case_createdByName: 'createdByName',
|
|
59
|
+
case_createdby_sso_username: 'createdBySSO',
|
|
60
|
+
case_createdDate: 'createdDate',
|
|
61
|
+
case_lastModifiedByName: 'lastModifiedByName',
|
|
62
|
+
case_lastModifiedDate: 'lastModifiedDate',
|
|
63
|
+
case_last_public_update_date: 'lastPublicUpdateDate',
|
|
64
|
+
case_last_public_update_by: 'lastPublicUpdateDateBy',
|
|
65
|
+
case_description: 'description',
|
|
66
|
+
uri: 'uri',
|
|
67
|
+
case_24_7: 'FTS',
|
|
68
|
+
case_type: 'caseType',
|
|
69
|
+
case_is_cep: 'CEP',
|
|
70
|
+
case_accountName: 'accountName',
|
|
71
|
+
case_alternate_id: 'alternateCaseId',
|
|
72
|
+
case_closedDate: 'closedDate',
|
|
73
|
+
case_openshift_cluster_id: 'openshiftClusterId',
|
|
74
|
+
case_account_name: 'accountName',
|
|
75
|
+
};
|
|
42
76
|
// just to keep ts happy since the below const does not work
|
|
43
77
|
export var SolrPivotKeys;
|
|
44
78
|
(function (SolrPivotKeys) {
|
|
@@ -11,12 +11,13 @@ export declare const FILTER_URL_PAGE_SIZE_SEARCH_PARAM = "size";
|
|
|
11
11
|
export declare const FILTER_URL_QUERY_TYPE = "searchType";
|
|
12
12
|
declare function createSolrQueryFromFilterState(filterState: ICaseListFilterState, loggedInUser: UserAuth): any;
|
|
13
13
|
declare function createUserFriendlyQueryFromFilterState(filterInfo: Partial<IFilterInfo>, filterQuery: string, useKeyForKVPair?: boolean): string;
|
|
14
|
+
declare function createUserFriendlyQueryFromFilterStateAdvancedSearch(filterInfo: Partial<IFilterInfo>, filterQuery: string, useKeyForKVPair?: boolean): string;
|
|
14
15
|
declare function createAdvancedSearchQueryFromFilterState(filterInfo: Partial<IFilterInfo>, keyword: string, useKeyForKVPair?: any[]): string;
|
|
15
16
|
declare function createQueryForCSVDownload(filterState: ICaseListFilterState, loggedInUserRights: UserAuth, loggedInUsersAccount: any, startValue?: number, limitValue?: number): any;
|
|
16
17
|
declare function createSFDCQueryFromFilterState(filterState: ICaseListFilterState, loggedInUser: UserAuth, loggedInUserAccount: Partial<IAccount>): Partial<ISFDCCaseFilter>;
|
|
17
18
|
declare function mapSFDCCaseListToSolrCaseList(response?: ISFDCCaseListResponse[]): ISolrCaseListResponse[];
|
|
18
19
|
declare function createURLQueryFromFilterState(filterState: ICaseListFilterState): string;
|
|
19
20
|
declare function createFilterStateFromUrlQuery(urlQuery: string, globalMetadataState: IGlobalMetadataState, pageSize?: number, currentPage?: number, searchType?: CaseSearchQueryType): ICaseListFilterState;
|
|
20
|
-
declare function createFilterStateFromAdvancedQuery(queryString: string, globalMetadataState: IGlobalMetadataState, currentFilterState: ICaseListFilterState): ICaseListFilterState;
|
|
21
|
-
export { createSolrQueryFromFilterState, createUserFriendlyQueryFromFilterState, createQueryForCSVDownload, createSFDCQueryFromFilterState, mapSFDCCaseListToSolrCaseList, createURLQueryFromFilterState, createFilterStateFromUrlQuery, createAdvancedSearchQueryFromFilterState, createFilterStateFromAdvancedQuery, };
|
|
21
|
+
declare function createFilterStateFromAdvancedQuery(queryString: string, globalMetadataState: IGlobalMetadataState, currentFilterState: ICaseListFilterState, parsedQuery?: string, type?: CaseSearchQueryType): ICaseListFilterState;
|
|
22
|
+
export { createSolrQueryFromFilterState, createUserFriendlyQueryFromFilterState, createUserFriendlyQueryFromFilterStateAdvancedSearch, createQueryForCSVDownload, createSFDCQueryFromFilterState, mapSFDCCaseListToSolrCaseList, createURLQueryFromFilterState, createFilterStateFromUrlQuery, createAdvancedSearchQueryFromFilterState, createFilterStateFromAdvancedQuery, };
|
|
22
23
|
//# sourceMappingURL=caseSearchUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caseSearchUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseSearchUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAUxD,OAAO,EACH,oBAAoB,EACpB,WAAW,EAId,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAEH,mBAAmB,EAEtB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"caseSearchUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseSearchUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAUxD,OAAO,EACH,oBAAoB,EACpB,WAAW,EAId,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAEH,mBAAmB,EAEtB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,eAAO,MAAM,6BAA6B,UAAU,CAAC;AACrD,eAAO,MAAM,oCAAoC,MAAM,CAAC;AACxD,eAAO,MAAM,iCAAiC,SAAS,CAAC;AACxD,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,iBAAS,8BAA8B,CAAC,WAAW,EAAE,oBAAoB,EAAE,YAAY,EAAE,QAAQ,OA4DhG;AAED,iBAAS,sCAAsC,CAC3C,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,EAChC,WAAW,EAAE,MAAM,EACnB,eAAe,GAAE,OAAe,UAwBnC;AAED,iBAAS,oDAAoD,CACzD,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,EAChC,WAAW,EAAE,MAAM,EACnB,eAAe,GAAE,OAAe,UAgDnC;AAeD,iBAAS,wCAAwC,CAC7C,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,EAChC,OAAO,EAAE,MAAM,EACf,eAAe,QAAK,UAoCvB;AASD,iBAAS,yBAAyB,CAC9B,WAAW,EAAE,oBAAoB,EACjC,kBAAkB,EAAE,QAAQ,EAC5B,oBAAoB,KAAA,EACpB,UAAU,SAAI,EACd,UAAU,SAAO,OAcpB;AAkBD,iBAAS,8BAA8B,CACnC,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,QAAQ,EACtB,mBAAmB,EAAE,OAAO,CAAC,QAAQ,CAAC,GACvC,OAAO,CAAC,eAAe,CAAC,CAkE1B;AAED,iBAAS,6BAA6B,CAAC,QAAQ,GAAE,qBAAqB,EAAO,GAAG,qBAAqB,EAAE,CAEtG;AAcD,iBAAS,6BAA6B,CAAC,WAAW,EAAE,oBAAoB,UAUvE;AAED,iBAAS,6BAA6B,CAClC,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,oBAAoB,EACzC,QAAQ,CAAC,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,GAAE,mBAA+C,wBAsD9D;AAGD,iBAAS,kCAAkC,CACvC,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,oBAAoB,EACzC,kBAAkB,EAAE,oBAAoB,EACxC,WAAW,GAAE,MAAW,EACxB,IAAI,GAAE,mBAA+C,wBAqCxD;AAgGD,OAAO,EACH,8BAA8B,EAC9B,sCAAsC,EACtC,oDAAoD,EACpD,yBAAyB,EACzB,8BAA8B,EAC9B,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,wCAAwC,EACxC,kCAAkC,GACrC,CAAC"}
|
|
@@ -19,7 +19,7 @@ import { getLabel } from '../components/case-list/case-list-filters/AccountsBook
|
|
|
19
19
|
import { initialCaseFilterState } from '../components/case-list/CaseListFilterContext';
|
|
20
20
|
import { CaseListColumnIds, caseListSortColumnIdsToSolrMap, CaseStatus } from '../enums/case';
|
|
21
21
|
import { advanceSearchFieldNameToSolrFieldMapping, CaseSearchQueryType, fieldNameToSolrFieldMapping, } from '../enums/caseSearch';
|
|
22
|
-
import { AdditionalFilterLabels, ProductVersionKey, sfdcFieldToSolrMap, SolrKeys, SolrPivotKeys, SolrTags, } from '../enums/filters';
|
|
22
|
+
import { AdditionalFilterLabels, advancedSearchMap, ProductVersionKey, sfdcFieldToSolrMap, SolrKeys, SolrPivotKeys, SolrTags, } from '../enums/filters';
|
|
23
23
|
export const FILTER_URL_QUERY_SEARCH_PARAM = 'query';
|
|
24
24
|
export const FILTER_URL_CURRENT_PAGE_SEARCH_PARAM = 'p';
|
|
25
25
|
export const FILTER_URL_PAGE_SIZE_SEARCH_PARAM = 'size';
|
|
@@ -27,8 +27,7 @@ export const FILTER_URL_QUERY_TYPE = 'searchType';
|
|
|
27
27
|
function createSolrQueryFromFilterState(filterState, loggedInUser) {
|
|
28
28
|
const { paginationInfo: { pageSize, currentPage }, sortInfo: { column, direction }, filterInfo, filterQueryInfo, } = filterState;
|
|
29
29
|
const rows = pageSize;
|
|
30
|
-
const
|
|
31
|
-
const queryString = ((isAdvancedSearch ? filterQueryInfo.parsedQuery : filterQueryInfo.queryString) || '*:*').trim();
|
|
30
|
+
const queryString = (filterQueryInfo.queryString || '*:*').trim();
|
|
32
31
|
const isCaseNumberQuery = isValidCaseNumber(queryString);
|
|
33
32
|
const q = isCaseNumberQuery ? `${SolrKeys.caseNumber}:${queryString}` : queryString;
|
|
34
33
|
const sort = `${caseListSortColumnIdsToSolrMap[column]} ${direction}`;
|
|
@@ -97,6 +96,52 @@ function createUserFriendlyQueryFromFilterState(filterInfo, filterQuery, useKeyF
|
|
|
97
96
|
filtersQuery !== '*:*' && finalQueryArr.push(filtersQuery);
|
|
98
97
|
return finalQueryArr.join(' AND ');
|
|
99
98
|
}
|
|
99
|
+
function createUserFriendlyQueryFromFilterStateAdvancedSearch(filterInfo, filterQuery, useKeyForKVPair = false) {
|
|
100
|
+
// if query contains quotes then we need to escape it so that solr parser can parse it successfully
|
|
101
|
+
//const searchTextQuery = filterQuery ? `keyword: "${filterQuery.replace(/"/g, '\\"')}"` : '';
|
|
102
|
+
let solrQuery = new SolrQueryBuilder();
|
|
103
|
+
Object.keys(filterInfo).forEach((_filterKey) => {
|
|
104
|
+
const fieldLabel = fieldNameToSolrFieldMapping[_filterKey]
|
|
105
|
+
? fieldNameToSolrFieldMapping[_filterKey]
|
|
106
|
+
: _filterKey;
|
|
107
|
+
const fieldValue = isKeyValuePair(filterInfo[_filterKey])
|
|
108
|
+
? filterInfo[_filterKey].map((item) => (useKeyForKVPair ? item.key : item.value))
|
|
109
|
+
: filterInfo[_filterKey];
|
|
110
|
+
if (_filterKey !== ProductVersionKey) {
|
|
111
|
+
Array.isArray(fieldValue) && fieldValue.length > 0 && solrQuery.where(fieldLabel).in(flatMap(fieldValue));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const filtersQuery = solrQuery.build();
|
|
115
|
+
const productVersionQuery = createProductVersionQueryStringFromFilterState(filterInfo);
|
|
116
|
+
// add text: to string search and create and with the rest
|
|
117
|
+
const q = parseSolrQuery(filterQuery);
|
|
118
|
+
const newFilterInfo = {};
|
|
119
|
+
let advanceToBasicQuery = [];
|
|
120
|
+
Object.keys(q || {}).forEach((_key) => {
|
|
121
|
+
if (_key === SolrKeys.product) {
|
|
122
|
+
newFilterInfo[SolrPivotKeys.product_version] = generateProductVersionPivotValue(q[_key]);
|
|
123
|
+
}
|
|
124
|
+
// if it's an unnamed field we should add it to free text querystring
|
|
125
|
+
else if (_key === '<implicit>' || _key === 'undefined') {
|
|
126
|
+
advanceToBasicQuery.push(q[_key]);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// it means field is not supported as a filter
|
|
130
|
+
if (!fieldNameToSolrFieldMapping[_key]) {
|
|
131
|
+
// if it's supported in basic search mode then add it as a query string in the search input
|
|
132
|
+
if (advanceSearchFieldNameToSolrFieldMapping[_key] || SolrKeys[_key]) {
|
|
133
|
+
advanceToBasicQuery.push(`${advancedSearchMap[_key]}:${getStringOrBooleanValue(q[_key][0])}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const textSearch = advanceToBasicQuery.length !== 0 ? [`text:"${advanceToBasicQuery.join(' ')}"`] : [];
|
|
139
|
+
const parsedQueryString = []
|
|
140
|
+
.concat(textSearch)
|
|
141
|
+
.concat(productVersionQuery ? productVersionQuery : [])
|
|
142
|
+
.concat(filtersQuery !== '*:*' ? filtersQuery : []);
|
|
143
|
+
return parsedQueryString.join(' and ').replace(/ AND /g, ' and ').replace(/ OR /g, ' or ');
|
|
144
|
+
}
|
|
100
145
|
function createProductVersionQueryStringFromFilterState(filterInfo) {
|
|
101
146
|
const queryStringForProductFilter = buildSolrQuery({ [ProductVersionKey]: filterInfo[ProductVersionKey] });
|
|
102
147
|
let productVersionQuery = '';
|
|
@@ -107,7 +152,7 @@ function createProductVersionQueryStringFromFilterState(filterInfo) {
|
|
|
107
152
|
.replace(regexForProductReplace, fieldNameToSolrFieldMapping[SolrKeys.product])
|
|
108
153
|
.replace(regexForVersionReplace, fieldNameToSolrFieldMapping[SolrKeys.version]);
|
|
109
154
|
}
|
|
110
|
-
return productVersionQuery;
|
|
155
|
+
return productVersionQuery.replace(/\(\s+/g, '(').replace(/\s\)+/g, ')');
|
|
111
156
|
}
|
|
112
157
|
function createAdvancedSearchQueryFromFilterState(filterInfo, keyword, useKeyForKVPair = []) {
|
|
113
158
|
const finalQueryArr = [];
|
|
@@ -141,8 +186,13 @@ function createAdvancedSearchQueryFromFilterState(filterInfo, keyword, useKeyFor
|
|
|
141
186
|
filtersQuery !== '*:*' && finalQueryArr.push(filtersQuery);
|
|
142
187
|
return finalQueryArr.join(' and ');
|
|
143
188
|
}
|
|
189
|
+
function isBoolean(val) {
|
|
190
|
+
return val === false || val === true;
|
|
191
|
+
}
|
|
144
192
|
function getStringOrBooleanValue(val) {
|
|
145
|
-
|
|
193
|
+
if (isBoolean(val))
|
|
194
|
+
return val;
|
|
195
|
+
return val === 'true' ? true : val === 'false' ? false : `"${val}"`;
|
|
146
196
|
}
|
|
147
197
|
function createQueryForCSVDownload(filterState, loggedInUserRights, loggedInUsersAccount, startValue = 0, limitValue = 1000) {
|
|
148
198
|
if (loggedInUsersAccount.secureSupport) {
|
|
@@ -285,15 +335,19 @@ function createFilterStateFromUrlQuery(urlQuery, globalMetadataState, pageSize,
|
|
|
285
335
|
}
|
|
286
336
|
}
|
|
287
337
|
});
|
|
338
|
+
const parsedQuery = filterQueryInfo.type === CaseSearchQueryType.ADVANCED
|
|
339
|
+
? createUserFriendlyQueryFromFilterStateAdvancedSearch(filterInfo, filterQueryInfo.queryString, true)
|
|
340
|
+
: '';
|
|
288
341
|
const filterQuery = {
|
|
289
342
|
sortInfo,
|
|
290
343
|
paginationInfo,
|
|
291
|
-
filterQueryInfo,
|
|
344
|
+
filterQueryInfo: Object.assign(Object.assign({}, filterQueryInfo), { parsedQuery }),
|
|
292
345
|
filterInfo: Object.assign(Object.assign({}, defaultFilterInfo), filterInfo),
|
|
293
346
|
};
|
|
294
347
|
return filterQuery;
|
|
295
348
|
}
|
|
296
|
-
|
|
349
|
+
// when from advaced query we want to swith to basic query is called
|
|
350
|
+
function createFilterStateFromAdvancedQuery(queryString, globalMetadataState, currentFilterState, parsedQuery = '', type = CaseSearchQueryType.BASIC) {
|
|
297
351
|
const filterObj = parseSolrQuery(queryString);
|
|
298
352
|
const newFilterInfo = {};
|
|
299
353
|
let advanceToBasicQuery = [];
|
|
@@ -312,14 +366,15 @@ function createFilterStateFromAdvancedQuery(queryString, globalMetadataState, cu
|
|
|
312
366
|
}
|
|
313
367
|
else {
|
|
314
368
|
// if it's supported in basic search mode then add it as a query string in the search input
|
|
315
|
-
if (advanceSearchFieldNameToSolrFieldMapping[_key]) {
|
|
369
|
+
if (advanceSearchFieldNameToSolrFieldMapping[_key] || SolrKeys[_key]) {
|
|
316
370
|
const val = filterObj[_key];
|
|
317
|
-
advanceToBasicQuery.push(`${_key}
|
|
371
|
+
advanceToBasicQuery.push(`${_key}:${getStringOrBooleanValue(val)}`);
|
|
318
372
|
}
|
|
319
373
|
}
|
|
320
374
|
}
|
|
321
375
|
});
|
|
322
|
-
const filterState = Object.assign(Object.assign({}, currentFilterState), { filterQueryInfo: Object.assign(Object.assign({}, currentFilterState.filterQueryInfo), { queryString: advanceToBasicQuery.join(' AND '),
|
|
376
|
+
const filterState = Object.assign(Object.assign({}, currentFilterState), { filterQueryInfo: Object.assign(Object.assign({}, currentFilterState.filterQueryInfo), { queryString: advanceToBasicQuery.join(' AND '), parsedQuery,
|
|
377
|
+
type }), filterInfo: Object.assign(Object.assign({}, initialCaseFilterState.filterInfo), newFilterInfo) });
|
|
323
378
|
return filterState;
|
|
324
379
|
}
|
|
325
380
|
function generateFilterValue(solrFieldName, value, globalMetadataState) {
|
|
@@ -395,4 +450,4 @@ function generateProductVersionPivotValue(values) {
|
|
|
395
450
|
};
|
|
396
451
|
});
|
|
397
452
|
}
|
|
398
|
-
export { createSolrQueryFromFilterState, createUserFriendlyQueryFromFilterState, createQueryForCSVDownload, createSFDCQueryFromFilterState, mapSFDCCaseListToSolrCaseList, createURLQueryFromFilterState, createFilterStateFromUrlQuery, createAdvancedSearchQueryFromFilterState, createFilterStateFromAdvancedQuery, };
|
|
453
|
+
export { createSolrQueryFromFilterState, createUserFriendlyQueryFromFilterState, createUserFriendlyQueryFromFilterStateAdvancedSearch, createQueryForCSVDownload, createSFDCQueryFromFilterState, mapSFDCCaseListToSolrCaseList, createURLQueryFromFilterState, createFilterStateFromUrlQuery, createAdvancedSearchQueryFromFilterState, createFilterStateFromAdvancedQuery, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/cases",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"not ie <= 11",
|
|
100
100
|
"not op_mini all"
|
|
101
101
|
],
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "6ad83aaad97f659afae273d0bf00f1b7400584f1"
|
|
103
103
|
}
|