@rh-support/cases 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts.map +1 -1
  2. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.js +21 -17
  3. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts.map +1 -1
  4. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.js +19 -20
  5. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts.map +1 -1
  6. package/lib/esm/components/case-list/case-list-filters/StatusFilter.js +18 -20
  7. package/lib/esm/components/case-list/case-list-filters/TypeFilter.d.ts.map +1 -1
  8. package/lib/esm/components/case-list/case-list-filters/TypeFilter.js +19 -13
  9. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts.map +1 -1
  10. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.js +17 -19
  11. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.js +1 -1
  12. package/lib/esm/components/case-list/case-search/AdvanceSearch.d.ts +1 -1
  13. package/lib/esm/components/case-list/case-search/AdvanceSearch.d.ts.map +1 -1
  14. package/lib/esm/components/case-list/case-search/AdvanceSearch.js +29 -49
  15. package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.js +1 -1
  16. package/lib/esm/components/case-list/case-search/CaseSearch.d.ts.map +1 -1
  17. package/lib/esm/components/case-list/case-search/CaseSearch.js +16 -15
  18. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.d.ts.map +1 -1
  19. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.js +161 -64
  20. package/lib/esm/css/caseList.css +7 -2
  21. package/lib/esm/css/caseSearch.css +0 -4
  22. package/lib/esm/enums/case.d.ts +15 -1
  23. package/lib/esm/enums/case.d.ts.map +1 -1
  24. package/lib/esm/enums/case.js +16 -2
  25. package/lib/esm/enums/filters.d.ts +35 -1
  26. package/lib/esm/enums/filters.d.ts.map +1 -1
  27. package/lib/esm/enums/filters.js +34 -0
  28. package/lib/esm/utils/caseSearchUtils.d.ts +3 -2
  29. package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
  30. package/lib/esm/utils/caseSearchUtils.js +68 -15
  31. 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":"AACA,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,eA+D3C"}
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 { Dropdown, MultiSelectDropDownList } from '@rh-support/components';
2
- import { getDropdownBtnPlaceholder, toOption, toOptions } from '@rh-support/utils';
3
- import React, { useContext } from 'react';
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
- selectedProduct = {
23
- field: SolrKeys.product,
24
- value: selectedProduct.label,
25
- [SolrKeys.version]: [],
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 list = toOptions(props.filterValues, {
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(Dropdown, { placeholder: t('Select a product'), "data-tracking-id": "products-filter", id: "case-list-products-filter", title: t(filterNamesMap[SolrKeys.product]), label: t(filterNamesMap[SolrKeys.product]), onChange: onFilterChangeSingleSelect, selectedItem: toOption((_a = filterInfo[SolrPivotKeys.product_version][0]) === null || _a === void 0 ? void 0 : _a.value), list: toOptions(props.allProducts) }));
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), ' ', props.filterValues.length, t('All selected')), "data-tracking-id": "products-filter", id: "case-list-products-filter", title: t(filterNamesMap[SolrKeys.product]), label: t(filterNamesMap[SolrKeys.product]), onChange: onFilterChangeMultipleSelect, selectedItems: toOptions(filterInfo[SolrPivotKeys.product_version], { labelKey: 'value' }), list: list, searchable: true }));
39
- return React.createElement(React.Fragment, null, props.isSolrSearchDown ? singleSelectSolrIsDown() : multiSelect());
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,EAAa,MAAM,0BAA0B,CAAC;AAUrE,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,eAiE3C"}
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 { Dropdown, MultiSelectDropDownList } from '@rh-support/components';
2
- import { getDropdownBtnPlaceholder, toOption, toOptions } from '@rh-support/utils';
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 onFilterChangeMultipleSelect = (selectedSeverities) => {
14
- selectedSeverities = selectedSeverities.map((selectedSeverity) => selectedSeverity.label);
15
- updateFilter(dispatch, { filterKey: SolrKeys.severity, values: selectedSeverities });
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.label] });
21
+ const onFilterChangeSingleSelect = (event, selectedSeverity) => {
22
+ updateFilter(dispatch, { filterKey: SolrKeys.severity, values: [selectedSeverity] });
23
+ setIsOpen(false);
19
24
  };
20
- const list = toOptions(props.filterValues.map((filterValue) => ({
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(Dropdown, { placeholder: t('Select a severity'), "data-tracking-id": "severity-filter", id: "case-list-severity-filter", title: t(filterNamesMap[SolrKeys.severity]), label: t(filterNamesMap[SolrKeys.severity]), onChange: onFilterChangeSingleSelect, selectedItem: toOption(filterInfo[SolrKeys.severity][0]), list: toOptions(props.allCaseSeverities) }));
29
- const multiSelect = () => (React.createElement(MultiSelectDropDownList, { placeholder: getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', props.filterValues.length, t('All selected')), "data-tracking-id": "severity-filter", id: "case-list-severity-filter", title: t(filterNamesMap[SolrKeys.severity]), label: t(filterNamesMap[SolrKeys.severity]), onChange: onFilterChangeMultipleSelect, selectedItems: toOptions(filterInfo[SolrKeys.severity].map((filterValue) => ({
30
- key: filterValue,
31
- value: filterValue,
32
- })), { labelKey: 'value' }), list: list }));
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,EAAa,MAAM,0BAA0B,CAAC;AAUrE,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,eA+FzC"}
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 { Dropdown, MultiSelectDropDownList } from '@rh-support/components';
2
- import { toOption, toOptions } from '@rh-support/utils';
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 onFilterChange = (selectedStatus) => {
14
- selectedStatus = selectedStatus.map((i) => i.label);
15
- updateFilter(dispatch, { filterKey: SolrKeys.status, values: selectedStatus });
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.label] });
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 list = toOptions(props.filterValues.map((filterValue) => ({
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(Dropdown, { placeholder: t('Select a status'), "data-tracking-id": "status-filter", id: "case-list-status-filter", title: t(filterNamesMap[SolrKeys.status]), label: t(filterNamesMap[SolrKeys.status]), onChange: onFilterChangeSingleSelect, selectedItem: toOption(filterInfo[SolrKeys.status][0]), list: toOptions(props.allCaseStatuses) }));
53
- const multiSelect = () => (React.createElement(MultiSelectDropDownList, { placeholder: getBtnPlaceholder(t('Select a status'), filterInfo[SolrKeys.status], ' ', props.filterValues.length, t('All selected')), "data-tracking-id": "status-filter", id: "case-list-status-filter", title: t(filterNamesMap[SolrKeys.status]), label: t(filterNamesMap[SolrKeys.status]), onChange: onFilterChange, selectedItems: toOptions(filterInfo[SolrKeys.status].map((filterValue) => ({
54
- key: filterValue,
55
- value: filterValue,
56
- })), { labelKey: 'value' }), list: list }));
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":"AAWA,UAAU,MAAM;IACZ,YAAY,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eA6CvC"}
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 { MultiSelectDropDownList } from '@rh-support/components';
2
- import { FeatureAnnouncementKeys, NewFeatureLabel } from '@rh-support/react-context';
3
- import { getDropdownBtnPlaceholder, toOptions } from '@rh-support/utils';
4
- import React, { useContext } from 'react';
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 onFilterChangeMultipleSelect = (selectedTypes) => updateFilter(dispatch, {
15
- filterKey: SolrKeys.type,
16
- values: selectedTypes.map((selectedType) => selectedType.label),
17
- });
18
- return (React.createElement(MultiSelectDropDownList, { placeholder: getDropdownBtnPlaceholder(t('Select a case type'), filterInfo[SolrKeys.type], ' ', props.allCaseTypes.length, t('All selected')), "data-tracking-id": "type-filter", id: "case-list-type-filter", title: t(filterNamesMap[SolrKeys.type]), label: React.createElement("h3", { className: "pull-bottom-narrow" },
19
- t(filterNamesMap[SolrKeys.type]),
20
- React.createElement(NewFeatureLabel, { "aria-label": "send notification new feature announcement", hasAutoWidth: true, featureName: FeatureAnnouncementKeys.CASE_TYPE_FILTER, headerContent: React.createElement(Trans, null, "New filter available"), position: 'right', bodyContent: React.createElement("div", null,
21
- React.createElement(Trans, null, "You can now filter by case type.")) })), onChange: onFilterChangeMultipleSelect, selectedItems: toOptions(filterInfo[SolrKeys.type]), list: toOptions(props.allCaseTypes) }));
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":"AAQA,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,eAmD1E"}
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 { MultiSelectDropDownList } from '@rh-support/components';
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 onFilterChange = (selectedVersions, productInfo) => {
17
- selectedVersions = selectedVersions.map((i) => i.value);
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 productState = [...filterInfo[SolrPivotKeys.product_version]];
20
- const objIndex = productState.findIndex((item) => item.value === productInfo.value);
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
- productState[objIndex] = {
25
+ productNewState[objIndex] = {
23
26
  field: SolrKeys.product,
24
27
  value: productInfo.value,
25
- [SolrKeys.version]: selectedVersions.map((version) => ({ field: 'case_version', value: version.value })),
28
+ [SolrKeys.version]: newVerionState,
26
29
  };
27
- updateFilter(dispatch, { filterKey: SolrPivotKeys.product_version, values: productState });
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
- return (React.createElement(React.Fragment, null, !isEmpty(versions) && (React.createElement(MultiSelectDropDownList, { placeholder: t('Version'), "data-tracking-id": "versions-filter", id: "case-list-versions-filter", title: 'versions dropdown', onChange: (selectedItems) => onFilterChange(selectedItems, productInfo), selectedItems: toOptions(getSelectedVersionsArray(productInfo.value), {
35
- labelKey: 'value',
36
- }), list: toOptions(versions, {
37
- labelKey: 'value',
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":"AAQA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAMhE,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,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,0BAA0B,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,eAwV1C"}
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, updateFilterState } from '../CaseListFilterReducer';
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 [queryString, setQueryString] = useState('');
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(queryString);
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(queryString + ' ');
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, queryString.substring(e.location.start.offset, queryString.length));
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 (queryString === filterQueryInfo.queryString || filterQueryInfo.type === CaseSearchQueryType.BASIC)
48
+ if (filterQueryInfo.type === CaseSearchQueryType.BASIC)
57
49
  return;
58
- setQueryString(filterQueryInfo.queryString);
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.queryString]);
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
- setShowComplexQueryError(false);
76
- props.onSearchValChange && props.onSearchValChange(queryString);
61
+ props.onSearchValChange && props.onSearchValChange(inputString);
77
62
  // eslint-disable-next-line react-hooks/exhaustive-deps
78
- }, [queryString]);
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
- setQueryString(query);
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
- setQueryString(queryString.substring(0, parserErrorRef.current.location.start.offset) + itemValue);
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
- setQueryString('');
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(queryString);
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
- if (!canSwitchToBasicSearch()) {
222
- setShowComplexQueryError(true);
223
- return;
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
- updateFilterState(dispatch, updatedFilterState);
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 = (queryString && !isParsingSuccessful) || showComplexQueryError;
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: queryString, 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 ${queryString && isParsingSuccessful && !showComplexQueryError ? '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" })),
243
- queryString && (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') },
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(queryString) && isEmpty(filterQueryInfo.queryString)) || !isParsingSuccessful },
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", isDisabled: showComplexQueryError, onClick: onBasicClick, "data-tracking-id": "case-list-basic-toggle-button" },
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":"AAeA,UAAU,MAAM;IACZ,sBAAsB,EAAE,MAAM,CAAC;CAClC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAqJvC"}
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 { SolrKeys } from '../../../enums/filters';
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 { initialFilterInfo, updateFilterQuery, updateFilterState } from '../CaseListFilterReducer';
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
- // eslint-disable-next-line react-hooks/exhaustive-deps
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 queryStr = createAdvancedSearchQueryFromFilterState(filterState.filterInfo, searchVal, [
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: queryStr,
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: onCaseSearch, onSearchTypeChange: onSearchTypeChange, onAdvancedSearchValidation: (isValid) => setIsAdvancedSearchValid(isValid) }))) : (React.createElement(React.Fragment, null));
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 },