@rh-support/cases 2.6.164 → 2.6.167

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 (78) hide show
  1. package/lib/esm/components/case-list/CaseList.d.ts +0 -7
  2. package/lib/esm/components/case-list/CaseList.d.ts.map +1 -1
  3. package/lib/esm/components/case-list/CaseList.js +106 -107
  4. package/lib/esm/components/case-list/CaseListContext.d.ts.map +1 -1
  5. package/lib/esm/components/case-list/CaseListContext.js +0 -2
  6. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts +5 -1
  7. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts.map +1 -1
  8. package/lib/esm/components/case-list/CaseListFilterReducer.js +2 -1
  9. package/lib/esm/components/case-list/CaseListReducer.d.ts +2 -8
  10. package/lib/esm/components/case-list/CaseListReducer.d.ts.map +1 -1
  11. package/lib/esm/components/case-list/CaseListReducer.js +1 -13
  12. package/lib/esm/components/case-list/case-list-filters/AccountsFilter.d.ts.map +1 -1
  13. package/lib/esm/components/case-list/case-list-filters/AccountsFilter.js +18 -11
  14. package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.d.ts.map +1 -1
  15. package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.js +4 -2
  16. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts +1 -7
  17. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts.map +1 -1
  18. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.js +7 -15
  19. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts +2 -5
  20. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts.map +1 -1
  21. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.js +14 -14
  22. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts +1 -3
  23. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts.map +1 -1
  24. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.js +2 -2
  25. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts +5 -4
  26. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts.map +1 -1
  27. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.js +15 -54
  28. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts +0 -3
  29. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts.map +1 -1
  30. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.js +18 -44
  31. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts +0 -3
  32. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts.map +1 -1
  33. package/lib/esm/components/case-list/case-list-filters/StatusFilter.js +14 -44
  34. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts +1 -3
  35. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts.map +1 -1
  36. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.js +61 -32
  37. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts +0 -1
  38. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts.map +1 -1
  39. package/lib/esm/components/case-list/case-list-table/CaseListTable.js +5 -6
  40. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts +0 -5
  41. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts.map +1 -1
  42. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.js +38 -68
  43. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.d.ts.map +1 -1
  44. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.js +5 -15
  45. package/lib/esm/components/case-list/case-list-table/SeverityLabel.js +1 -1
  46. package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.d.ts.map +1 -1
  47. package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.js +2 -3
  48. package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.d.ts.map +1 -1
  49. package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.js +1 -0
  50. package/lib/esm/components/case-list/case-search/CaseSearch.d.ts.map +1 -1
  51. package/lib/esm/components/case-list/case-search/CaseSearch.js +6 -6
  52. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.d.ts.map +1 -1
  53. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.js +2 -1
  54. package/lib/esm/enums/case.d.ts +2 -1
  55. package/lib/esm/enums/case.d.ts.map +1 -1
  56. package/lib/esm/enums/case.js +14 -1
  57. package/lib/esm/hooks/useExportCaseListCSV.d.ts.map +1 -1
  58. package/lib/esm/hooks/useExportCaseListCSV.js +1 -9
  59. package/lib/esm/test-utils/mockData.js +1 -1
  60. package/lib/esm/utils/caseListGraphQLUtils.d.ts +16 -0
  61. package/lib/esm/utils/caseListGraphQLUtils.d.ts.map +1 -0
  62. package/lib/esm/utils/caseListGraphQLUtils.js +193 -0
  63. package/lib/esm/utils/caseListMapper.d.ts +6 -0
  64. package/lib/esm/utils/caseListMapper.d.ts.map +1 -0
  65. package/lib/esm/utils/caseListMapper.js +36 -0
  66. package/lib/esm/utils/caseListVariablesBuilder.d.ts +13 -0
  67. package/lib/esm/utils/caseListVariablesBuilder.d.ts.map +1 -0
  68. package/lib/esm/utils/caseListVariablesBuilder.js +160 -0
  69. package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
  70. package/lib/esm/utils/caseSearchUtils.js +26 -1
  71. package/lib/esm/utils/constants.d.ts +2 -1
  72. package/lib/esm/utils/constants.d.ts.map +1 -1
  73. package/lib/esm/utils/constants.js +14 -3
  74. package/lib/esm/utils/mockSolrResponse.js +1 -1
  75. package/lib/esm/utils/statusUtils.d.ts +3 -0
  76. package/lib/esm/utils/statusUtils.d.ts.map +1 -0
  77. package/lib/esm/utils/statusUtils.js +22 -0
  78. package/package.json +6 -6
@@ -1,9 +1,3 @@
1
1
  import React from 'react';
2
- import { IProductVersionPivotMap } from '../CaseList';
3
- interface IProps {
4
- productVersionPivotValues: IProductVersionPivotMap[];
5
- isSolrSearchDown: boolean;
6
- }
7
- export declare function CaseListFilterChips(props: IProps): React.JSX.Element;
8
- export {};
2
+ export declare function CaseListFilterChips(): React.JSX.Element;
9
3
  //# sourceMappingURL=CaseListFilterChips.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CaseListFilterChips.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/CaseListFilterChips.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAMtD,UAAU,MAAM;IACZ,yBAAyB,EAAE,uBAAuB,EAAE,CAAC;IACrD,gBAAgB,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,qBAmIhD"}
1
+ {"version":3,"file":"CaseListFilterChips.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/CaseListFilterChips.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAU1C,wBAAgB,mBAAmB,sBAwHlC"}
@@ -7,11 +7,10 @@ import { Trans } from 'react-i18next';
7
7
  import { ProductVersionKey, SolrKeys, SolrPivotKeys } from '../../../enums/filters';
8
8
  import { filterNamesMap } from '../../../utils/constants';
9
9
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
10
- import { visibleFilterChipsWhenSolrDownSfdcUp } from '../CaseListFilterHelpers';
11
10
  import { clearFilters, removeFilterItem } from '../CaseListFilterReducer';
12
11
  import { CreatorSsoNameFilterChip } from './CreatorSsoNameFilterChip';
13
12
  import { ProductFilterChip } from './ProductFilterChip';
14
- export function CaseListFilterChips(props) {
13
+ export function CaseListFilterChips() {
15
14
  const { filterInfo } = useContext(CaseListFilterStateContext);
16
15
  const dispatch = useContext(CaseListFilterDispatchContext);
17
16
  const currentFilterLength = flatMap(filterInfo).length;
@@ -37,15 +36,10 @@ export function CaseListFilterChips(props) {
37
36
  };
38
37
  const getChipGroupForFilter = (filterKey, filterValues, groupName = '') => {
39
38
  const caseTypeFilter = filterKey === 'case_type' ? toNewCaseTypeMapper(filterValues) : filterValues;
40
- if (props.isSolrSearchDown && !visibleFilterChipsWhenSolrDownSfdcUp.includes(filterKey)) {
41
- return React.createElement(React.Fragment, null);
42
- }
43
- else {
44
- return (React.createElement("div", { className: "filter-chip", key: `${filterKey}-bookmarks-${groupName}` },
45
- React.createElement("span", { className: "filter-chip__heading" },
46
- React.createElement(Trans, null, groupName || filterNamesMap[filterKey] || filterKey)),
47
- React.createElement(LabelGroup, { numLabels: 7, className: "pf-v6-c-chip-group__simple" }, renderFilterValueChips(filterKey, caseTypeFilter, groupName))));
48
- }
39
+ return (React.createElement("div", { className: "filter-chip", key: `${filterKey}-bookmarks-${groupName}` },
40
+ React.createElement("span", { className: "filter-chip__heading" },
41
+ React.createElement(Trans, null, groupName || filterNamesMap[filterKey] || filterKey)),
42
+ React.createElement(LabelGroup, { numLabels: 7, className: "pf-v6-c-chip-group__simple" }, renderFilterValueChips(filterKey, caseTypeFilter, groupName))));
49
43
  };
50
44
  const renderAccountFilterChip = () => {
51
45
  const visibleChips = [];
@@ -86,10 +80,8 @@ export function CaseListFilterChips(props) {
86
80
  return (React.createElement(React.Fragment, null, isAnyFilterApplied && (React.createElement("div", { className: "filter-chip-wrapper" },
87
81
  React.createElement("h2", null, "Filtering by"),
88
82
  React.createElement("div", { className: "filter-chips" },
89
- Array.isArray(filterInfo[ProductVersionKey]) && filterInfo[ProductVersionKey].length > 0 && (React.createElement(ProductFilterChip, { productList: props.isSolrSearchDown && filterInfo[ProductVersionKey].length > 1
90
- ? [filterInfo[ProductVersionKey][0]]
91
- : filterInfo[ProductVersionKey], productVersionPivot: props.productVersionPivotValues })),
92
- !props.isSolrSearchDown && showUsernameFilter && React.createElement(CreatorSsoNameFilterChip, null),
83
+ Array.isArray(filterInfo[ProductVersionKey]) && filterInfo[ProductVersionKey].length > 0 && (React.createElement(ProductFilterChip, { productList: filterInfo[ProductVersionKey] })),
84
+ showUsernameFilter && React.createElement(CreatorSsoNameFilterChip, null),
93
85
  renderChips(),
94
86
  currentFilterLength > 1 && (React.createElement(Button, { variant: "link", isInline: true, onClick: clearAllFilters, "data-tracking-id": "case-list-clear-filters", className: "clear-filters" },
95
87
  React.createElement(Trans, null, "Clear all filters"))))))));
@@ -1,15 +1,12 @@
1
1
  import { IApiResponseDetails } from '@rh-support/types/shared';
2
- import { ISolrResponseToFacetFields, ITroubleshootProductResponse } from '@rh-support/utils';
2
+ import { ITroubleshootProductResponse } from '@rh-support/utils';
3
3
  import React from 'react';
4
- import { IFacetFields } from '../../../models/caseList';
5
4
  interface IProps {
6
- filterValues: ISolrResponseToFacetFields<IFacetFields>;
7
- isSolrSearchDown: boolean;
8
5
  allCaseTypes: IApiResponseDetails<string[]>;
9
6
  allCaseStatuses: IApiResponseDetails<string[]>;
10
7
  allCaseSeverities: IApiResponseDetails<string[]>;
11
8
  allProducts: IApiResponseDetails<ITroubleshootProductResponse>;
12
9
  }
13
- export declare const CaseListFilters: ({ filterValues, allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts, isSolrSearchDown, }: IProps) => React.JSX.Element;
10
+ export declare const CaseListFilters: ({ allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts }: IProps) => React.JSX.Element;
14
11
  export {};
15
12
  //# sourceMappingURL=CaseListFilters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CaseListFilters.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/CaseListFilters.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAE7F,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAWxD,UAAU,MAAM;IACZ,YAAY,EAAE,0BAA0B,CAAC,YAAY,CAAC,CAAC;IACvD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,eAAe,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,WAAW,EAAE,mBAAmB,CAAC,4BAA4B,CAAC,CAAC;CAClE;AAID,eAAO,MAAM,eAAe,GAAI,oGAO7B,MAAM,sBA2ER,CAAC"}
1
+ {"version":3,"file":"CaseListFilters.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/CaseListFilters.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAY1C,UAAU,MAAM;IACZ,YAAY,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,eAAe,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,WAAW,EAAE,mBAAmB,CAAC,4BAA4B,CAAC,CAAC;CAClE;AAED,eAAO,MAAM,eAAe,GAAI,mEAAmE,MAAM,sBAmExG,CAAC"}
@@ -1,7 +1,5 @@
1
1
  import { AbilityContext, CaseListFields, resourceActions, resources } from '@rh-support/user-permissions';
2
- import get from 'lodash/get';
3
2
  import React, { useContext } from 'react';
4
- import { SolrKeys } from '../../../enums/filters';
5
3
  import { AccountsBookmarkedGroupFilter } from './AccountsBookmarkedGroupFilter';
6
4
  import { AccountsFilter } from './AccountsFilter';
7
5
  import { AdditionalFilters } from './AdditionalFilters';
@@ -11,9 +9,7 @@ import { ProductsFilter } from './ProductsFilter';
11
9
  import { SeverityFilter } from './SeverityFilter';
12
10
  import { StatusFilter } from './StatusFilter';
13
11
  import { TypeFilter } from './TypeFilter';
14
- // Adding a new filter here? Make sure you add in caseSearchUtils also so that
15
- // it get included in the solr search query fq parameter
16
- export const CaseListFilters = ({ filterValues, allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts, isSolrSearchDown, }) => {
12
+ export const CaseListFilters = ({ allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts }) => {
17
13
  var _a, _b;
18
14
  const ability = useContext(AbilityContext);
19
15
  const canReadAccountFilter = ability.can(resourceActions.READ, resources.ACCOUNTS_FILTER);
@@ -25,17 +21,21 @@ export const CaseListFilters = ({ filterValues, allCaseTypes, allCaseSeverities,
25
21
  const canAccessSeverityFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.SEVERITY_FILTER);
26
22
  const canAccessAdditionalFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.ADDITIONAL_FILTER);
27
23
  const canAccessGroupsFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.GROUPS_FILTER);
24
+ void canAccessGroupsFilter;
25
+ void GroupsFilter;
28
26
  const canAccessCreatorFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.CREATOR_FILTER);
29
27
  const canAccessTypeFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.TYPE_FILTER);
30
28
  return (React.createElement(React.Fragment, null,
31
29
  React.createElement("div", { className: "filter-group" },
32
- !isSolrSearchDown && canReadAccountFilter && (React.createElement(AccountsFilter, { canReadBookmarkAccounts: canReadAccountFilter })),
33
- !isSolrSearchDown && (canReadBookmarkAccounts || canAccessManagedAccounts) && (React.createElement(AccountsBookmarkedGroupFilter, { canManageBookmarkAccounts: canManageBookmarkAccounts, canReadBookmarkAccounts: canReadBookmarkAccounts, canAccessManagedAccounts: canAccessManagedAccounts })),
34
- canAccessGroupsFilter && React.createElement(GroupsFilter, null),
35
- canAccessProductsFilter && (React.createElement(ProductsFilter, { filterValues: get(filterValues, SolrKeys.product, []), isSolrSearchDown: isSolrSearchDown, allProducts: ((_b = (_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult) === null || _b === void 0 ? void 0 : _b.map((p) => p.product)) || [] })),
36
- canAccessSeverityFilter && (React.createElement(SeverityFilter, { filterValues: get(filterValues, SolrKeys.severity, []), isSolrSearchDown: isSolrSearchDown, allCaseSeverities: allCaseSeverities.data })),
37
- canAccessStatusFilter && (React.createElement(StatusFilter, { filterValues: get(filterValues, SolrKeys.status, []), allCaseStatuses: allCaseStatuses.data, isSolrSearchDown: isSolrSearchDown })),
38
- !isSolrSearchDown && canAccessTypeFilter && React.createElement(TypeFilter, { allCaseTypes: allCaseTypes.data }),
39
- !isSolrSearchDown && canAccessCreatorFilter && React.createElement(CreatorSsoNameFilter, null),
40
- !isSolrSearchDown && canAccessAdditionalFilter && React.createElement(AdditionalFilters, null))));
30
+ canReadAccountFilter && React.createElement(AccountsFilter, { canReadBookmarkAccounts: canReadAccountFilter }),
31
+ (canReadBookmarkAccounts || canAccessManagedAccounts) && (React.createElement(AccountsBookmarkedGroupFilter, { canManageBookmarkAccounts: canManageBookmarkAccounts, canReadBookmarkAccounts: canReadBookmarkAccounts, canAccessManagedAccounts: canAccessManagedAccounts })),
32
+ canAccessProductsFilter && (React.createElement(ProductsFilter, { allProducts: ((_b = (_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult) === null || _b === void 0 ? void 0 : _b.map((p) => ({
33
+ name: p.product,
34
+ productId: p.productId,
35
+ }))) || [] })),
36
+ canAccessSeverityFilter && React.createElement(SeverityFilter, { allCaseSeverities: allCaseSeverities.data }),
37
+ canAccessStatusFilter && React.createElement(StatusFilter, { allCaseStatuses: allCaseStatuses.data }),
38
+ canAccessTypeFilter && React.createElement(TypeFilter, { allCaseTypes: allCaseTypes.data }),
39
+ canAccessCreatorFilter && React.createElement(CreatorSsoNameFilter, null),
40
+ canAccessAdditionalFilter && React.createElement(AdditionalFilters, null))));
41
41
  };
@@ -1,10 +1,8 @@
1
1
  import React from 'react';
2
- import { IProductVersionPivotMap } from '../CaseList';
3
2
  import { IProductFilter } from '../CaseListFilterReducer';
4
3
  interface IProps {
5
4
  productList: IProductFilter[];
6
- productVersionPivot: IProductVersionPivotMap[];
7
5
  }
8
- export declare function ProductFilterChip({ productList, productVersionPivot }: IProps): React.JSX.Element;
6
+ export declare function ProductFilterChip({ productList }: IProps): React.JSX.Element;
9
7
  export {};
10
8
  //# sourceMappingURL=ProductFilterChip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProductFilterChip.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductFilterChip.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAGxE,UAAU,MAAM;IACZ,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,mBAAmB,EAAE,uBAAuB,EAAE,CAAC;CAClD;AAED,wBAAgB,iBAAiB,CAAC,EAAE,WAAW,EAAE,mBAAwB,EAAE,EAAE,MAAM,qBAsElF"}
1
+ {"version":3,"file":"ProductFilterChip.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductFilterChip.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAE,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAGxE,UAAU,MAAM;IACZ,WAAW,EAAE,cAAc,EAAE,CAAC;CACjC;AAED,wBAAgB,iBAAiB,CAAC,EAAE,WAAW,EAAE,EAAE,MAAM,qBAsExD"}
@@ -7,7 +7,7 @@ import { filterNamesMap } from '../../../utils/constants';
7
7
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
8
8
  import { updateFilter } from '../CaseListFilterReducer';
9
9
  import { VersionsFilter } from './VersionsFilter';
10
- export function ProductFilterChip({ productList, productVersionPivot = [] }) {
10
+ export function ProductFilterChip({ productList }) {
11
11
  const { filterInfo } = useContext(CaseListFilterStateContext);
12
12
  const dispatch = useContext(CaseListFilterDispatchContext);
13
13
  const canAccessVersionsFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.VERSIONS_FILTER);
@@ -26,7 +26,7 @@ export function ProductFilterChip({ productList, productVersionPivot = [] }) {
26
26
  return (React.createElement("div", { className: "filter-chip" },
27
27
  React.createElement("span", { className: "filter-chip__heading" }, filterNamesMap[SolrKeys.product]),
28
28
  canAccessVersionsFilter ? (React.createElement(React.Fragment, null, productList.map((currentProduct, index) => (React.createElement(LabelGroup, { numLabels: 10, key: `${currentProduct.value}-${index}`, categoryName: currentProduct.value },
29
- React.createElement(VersionsFilter, { productInfo: currentProduct, productVersionPivot: productVersionPivot }),
29
+ React.createElement(VersionsFilter, { productInfo: currentProduct }),
30
30
  currentProduct[SolrKeys.version].map((chip) => (React.createElement(Label, { variant: "outline", key: chip.value, onClose: () => deleteVersion(currentProduct, chip) }, chip.value))),
31
31
  React.createElement(Button, { icon: React.createElement(TimesCircleIcon, { "aria-hidden": "true" }), className: "pf-v6-c-button__icon", variant: ButtonVariant.plain, "aria-label": "Remove product", onClick: () => deleteProduct(currentProduct) })))))) : (React.createElement(LabelGroup, { numLabels: 10, categoryName: "Product", key: "products" }, productList.map((currentProduct, index) => (React.createElement(Label, { variant: "outline", key: `${currentProduct.value}-${index}`, onClose: () => deleteProduct(currentProduct) }, currentProduct.value)))))));
32
32
  }
@@ -1,9 +1,10 @@
1
- import { IFacetResponse } from '@rh-support/types/shared';
2
1
  import React from 'react';
2
+ interface IProductOption {
3
+ name: string;
4
+ productId: string;
5
+ }
3
6
  interface IProps {
4
- filterValues: IFacetResponse[];
5
- isSolrSearchDown: boolean;
6
- allProducts: string[];
7
+ allProducts: IProductOption[];
7
8
  }
8
9
  export declare function ProductsFilter(props: IProps): React.JSX.Element;
9
10
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ProductsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductsFilter.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D,OAAO,KAAkD,MAAM,OAAO,CAAC;AAQvE,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,qBA+O3C"}
1
+ {"version":3,"file":"ProductsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductsFilter.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAQvE,UAAU,cAAc;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,MAAM;IACZ,WAAW,EAAE,cAAc,EAAE,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,qBAoL3C"}
@@ -1,5 +1,5 @@
1
1
  import { MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, } from '@patternfly/react-core';
2
- import { SingleSelectDropdown, useSelectKeyboardNavigator } from '@rh-support/components';
2
+ import { useSelectKeyboardNavigator } from '@rh-support/components';
3
3
  import { getDropdownBtnPlaceholder } from '@rh-support/utils';
4
4
  import isEmpty from 'lodash/isEmpty';
5
5
  import isUndefined from 'lodash/isUndefined';
@@ -10,11 +10,11 @@ import { filterNamesMap } from '../../../utils/constants';
10
10
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
11
11
  import { updateFilter } from '../CaseListFilterReducer';
12
12
  export function ProductsFilter(props) {
13
- var _a, _b, _c, _d, _f;
13
+ var _a;
14
14
  const { t } = useTranslation();
15
15
  const dispatch = useContext(CaseListFilterDispatchContext);
16
16
  const { filterInfo } = useContext(CaseListFilterStateContext);
17
- const { allProducts, filterValues, isSolrSearchDown } = props;
17
+ const { allProducts } = props;
18
18
  const [isOpen, setIsOpen] = useState(false);
19
19
  const [selectedItems, setSelectedItems] = useState({});
20
20
  const [activeItem, setActiveItem] = useState(null);
@@ -23,51 +23,24 @@ export function ProductsFilter(props) {
23
23
  const selectedProducts = !isUndefined(filterInfo) && !isUndefined(filterInfo[SolrPivotKeys.product_version])
24
24
  ? filterInfo[SolrPivotKeys.product_version]
25
25
  : [];
26
- const productOptions = filterValues.map((product) => ({
26
+ const productOptions = allProducts.map((product) => ({
27
27
  field: SolrKeys.product,
28
- value: product.value,
28
+ value: product.name,
29
+ productId: product.productId,
29
30
  [SolrKeys.version]: [],
30
31
  }));
31
- const singleSelectOptions = allProducts.length > 0
32
- ? allProducts.map((product) => ({
33
- value: product,
34
- label: product,
35
- }))
36
- : [{ value: '', label: t('No products available') }];
37
- const selectedProduct = ((_b = (_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.value) || '';
38
- const selectedOption = {
39
- value: selectedProduct,
40
- label: selectedProduct,
41
- };
42
- // Single select mode for when Solr is down
43
- const onFilterChangeSingleSelect = (selection) => {
44
- updateFilter(dispatch, {
45
- filterKey: SolrPivotKeys.product_version,
46
- values: [{ field: SolrKeys.product, value: selection.value, [SolrKeys.version]: [] }],
47
- });
48
- setIsOpen(false);
49
- };
50
- const onSingleSelectChange = (option) => {
51
- // Don't update filter if no products are available
52
- if (allProducts.length === 0 || option.value === '') {
53
- return;
54
- }
55
- updateFilter(dispatch, {
56
- filterKey: SolrPivotKeys.product_version,
57
- values: [{ field: SolrKeys.product, value: option.value, [SolrKeys.version]: [] }],
58
- });
59
- };
60
- // Multi-select mode
61
32
  const onSelect = (option) => {
33
+ var _a;
62
34
  let newSelectedProducts = [];
63
35
  if (selectedProducts === null || selectedProducts === void 0 ? void 0 : selectedProducts.some((product) => option.value === product.value)) {
64
36
  newSelectedProducts = selectedProducts.filter((product) => option.value !== product.value);
65
37
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
66
38
  }
67
39
  else {
40
+ const productId = option.productId || ((_a = allProducts.find((p) => p.name === option.value)) === null || _a === void 0 ? void 0 : _a.productId) || '';
68
41
  newSelectedProducts = [
69
42
  ...selectedProducts,
70
- { field: SolrKeys.product, value: option.value, [SolrKeys.version]: [] },
43
+ { field: SolrKeys.product, value: option.value, productId, [SolrKeys.version]: [] },
71
44
  ];
72
45
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
73
46
  }
@@ -93,21 +66,12 @@ export function ProductsFilter(props) {
93
66
  resetIndexOnClose: true,
94
67
  isDisabled: false,
95
68
  setIsOpen,
96
- onSelect: (item) => {
97
- if (isSolrSearchDown) {
98
- onFilterChangeSingleSelect(item);
99
- }
100
- else {
101
- onSelect(item);
102
- }
103
- },
69
+ onSelect,
104
70
  });
105
71
  const onTextInputChange = (_event, value) => {
106
72
  setInputValue(value);
107
73
  };
108
- const placeholder = isSolrSearchDown
109
- ? ((_d = (_c = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version]) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.value) || t('Select a product')
110
- : getDropdownBtnPlaceholder(t('Select a product'), ((_f = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version]) === null || _f === void 0 ? void 0 : _f.map((i) => i.value)) || [], '', props.filterValues.length, t('All selected'));
74
+ const placeholder = getDropdownBtnPlaceholder(t('Select a product'), ((_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version]) === null || _a === void 0 ? void 0 : _a.map((i) => i.value)) || [], '', (allProducts === null || allProducts === void 0 ? void 0 : allProducts.length) || 0, t('All selected'));
111
75
  const toggleForMultiSelect = (toggleRef) => (React.createElement(MenuToggle, { variant: "typeahead", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true },
112
76
  React.createElement(TextInputGroup, { isPlain: true },
113
77
  React.createElement(TextInputGroupMain, Object.assign({ value: inputValue, onClick: onToggleClick, onChange: onTextInputChange, onKeyDown: onInputKeyDown, id: "multi-typeahead-product-filter-input", autoComplete: "off", innerRef: textInputRef, placeholder: placeholder }, (activeItem && { 'aria-activedescendant': activeItem }), { role: "combobox", isExpanded: isOpen, "aria-controls": "select-multi-typeahead-product-listbox" })))));
@@ -129,9 +93,6 @@ export function ProductsFilter(props) {
129
93
  }, [inputValue]);
130
94
  useEffect(() => {
131
95
  var _a;
132
- if (isSolrSearchDown) {
133
- return;
134
- }
135
96
  if (isEmpty(filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version])) {
136
97
  setSelectedItems({});
137
98
  }
@@ -142,13 +103,13 @@ export function ProductsFilter(props) {
142
103
  }, {});
143
104
  setSelectedItems(selectedProductItems || {});
144
105
  }
145
- }, [filterInfo, isSolrSearchDown]);
106
+ }, [filterInfo]);
146
107
  const renderOptions = () => {
147
108
  const filteredOptions = getFilteredOptions();
148
- return filteredOptions.map((option, index) => (React.createElement(SelectOption, { key: `product-option-${index}`, value: option, hasCheckbox: !isSolrSearchDown, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-product-${String(option.value).replace(/\s/g, '-')}` }, option.value)));
109
+ return filteredOptions.map((option, index) => (React.createElement(SelectOption, { key: `product-option-${index}`, value: option, hasCheckbox: true, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-product-${String(option.value).replace(/\s/g, '-')}` }, option.value)));
149
110
  };
150
111
  return (React.createElement("div", { className: "product-filter" },
151
112
  React.createElement("label", { htmlFor: "case-list-products-filter", className: "pf-v6-u-mb-sm products-filter-label" }, t(filterNamesMap[SolrKeys.product])),
152
- isSolrSearchDown ? (React.createElement(SingleSelectDropdown, { id: "case-list-products-filter", selected: selectedOption, options: singleSelectOptions, placeholder: allProducts.length > 0 ? t('Select a product') : t('No products available'), onSelect: (options) => onSingleSelectChange(options[0]), dataTrackingId: "products-filter", isScrollable: true, isDisabled: allProducts.length === 0 })) : (React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: "case-list-products-filter", "data-tracking-id": "products-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggleForMultiSelect, isScrollable: true, popperProps: { direction: 'down', enableFlip: false, maxWidth: '30rem' } },
153
- React.createElement(SelectList, null, renderOptions())))));
113
+ React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: "case-list-products-filter", "data-tracking-id": "products-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggleForMultiSelect, isScrollable: true, popperProps: { direction: 'down', enableFlip: false, maxWidth: '30rem' } },
114
+ React.createElement(SelectList, null, renderOptions()))));
154
115
  }
@@ -1,9 +1,6 @@
1
- import { IFacetResponse } from '@rh-support/types/shared';
2
1
  import React from 'react';
3
2
  interface IProps {
4
- filterValues: IFacetResponse[];
5
3
  allCaseSeverities: string[];
6
- isSolrSearchDown: boolean;
7
4
  }
8
5
  export declare function SeverityFilter(props: IProps): React.JSX.Element;
9
6
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"SeverityFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/SeverityFilter.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,KAA0C,MAAM,OAAO,CAAC;AAQ/D,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,qBAoL3C"}
1
+ {"version":3,"file":"SeverityFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/SeverityFilter.tsx"],"names":[],"mappings":"AAYA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAQ/D,UAAU,MAAM;IACZ,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,qBA0I3C"}
@@ -1,5 +1,5 @@
1
1
  import { Button, MenuToggle, Select, SelectList, SelectOption, } from '@patternfly/react-core';
2
- import { SingleSelectDropdown, useSelectKeyboardNavigator } from '@rh-support/components';
2
+ import { useSelectKeyboardNavigator } from '@rh-support/components';
3
3
  import { getDropdownBtnPlaceholder } from '@rh-support/utils';
4
4
  import isEmpty from 'lodash/isEmpty';
5
5
  import React, { useContext, useEffect, useState } from 'react';
@@ -9,56 +9,38 @@ import { filterNamesMap } from '../../../utils/constants';
9
9
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
10
10
  import { updateFilter } from '../CaseListFilterReducer';
11
11
  export function SeverityFilter(props) {
12
- var _a;
13
12
  const { t } = useTranslation();
14
13
  const { filterInfo } = useContext(CaseListFilterStateContext);
15
14
  const dispatch = useContext(CaseListFilterDispatchContext);
16
15
  const [isOpen, setIsOpen] = useState(false);
17
16
  const [selectedItems, setSelectedItems] = useState({});
18
- const list = props.isSolrSearchDown
19
- ? props.allCaseSeverities.map((severity) => ({ value: severity, key: severity }))
20
- : props.filterValues.map((filterValue) => ({ value: filterValue.value, key: filterValue.value }));
21
- const singleSelectOptions = list.map((item) => ({
22
- value: item.value,
23
- label: item.value,
17
+ const list = (props.allCaseSeverities || []).map((severity) => ({
18
+ value: severity,
19
+ key: severity,
24
20
  }));
25
- const selectedSeverity = ((_a = filterInfo[SolrKeys.severity]) === null || _a === void 0 ? void 0 : _a[0]) || '';
26
- const selectedOption = {
27
- value: selectedSeverity,
28
- label: selectedSeverity,
29
- };
30
21
  const onToggleClick = (e) => {
31
22
  setIsOpen(!isOpen);
32
23
  };
33
24
  const onSelect = (option) => {
34
- if (props.isSolrSearchDown) {
35
- updateFilter(dispatch, {
36
- filterKey: SolrKeys.severity,
37
- values: [option.value],
38
- });
39
- setIsOpen(false);
40
- return;
41
- }
42
25
  const prevSelectedSeverities = Object.keys(selectedItems).filter((item) => selectedItems[item] && item);
43
26
  if (selectedItems[option.value]) {
44
27
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
45
- const index = prevSelectedSeverities.indexOf(option.value);
46
- prevSelectedSeverities.splice(index, 1);
28
+ updateFilter(dispatch, {
29
+ filterKey: SolrKeys.severity,
30
+ values: prevSelectedSeverities.filter((item) => item !== option.value),
31
+ });
47
32
  }
48
33
  else {
49
34
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
50
- prevSelectedSeverities.push(option.value);
35
+ updateFilter(dispatch, {
36
+ filterKey: SolrKeys.severity,
37
+ values: [...prevSelectedSeverities, option.value],
38
+ });
51
39
  }
52
- updateFilter(dispatch, {
53
- filterKey: SolrKeys.severity,
54
- values: prevSelectedSeverities,
55
- });
56
40
  };
57
- // Use the keyboard navigator hook
58
41
  const { focusedItemIndex, onInputKeyDown } = useSelectKeyboardNavigator({
59
42
  list,
60
43
  isOpen,
61
- resetIndexOnClose: true,
62
44
  setIsOpen,
63
45
  onSelect,
64
46
  });
@@ -69,25 +51,17 @@ export function SeverityFilter(props) {
69
51
  values: [],
70
52
  });
71
53
  };
72
- const placeholder = props.isSolrSearchDown
73
- ? t('Select a severity')
74
- : getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', list.length, t('All selected'));
54
+ const placeholder = getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', list.length, t('All selected'));
75
55
  const toggle = (toggleRef) => (React.createElement(MenuToggle, { variant: "default", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true, onKeyDown: onInputKeyDown },
76
56
  placeholder,
77
57
  Object.keys(selectedItems).filter((key) => selectedItems[key] === true).length > 0 && (React.createElement(Button, { icon: "", variant: "plain", onClick: onClick, "aria-label": "Clear selection", className: "pf-v6-c-select__toggle-clear" }))));
78
- const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: !props.isSolrSearchDown, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-severity-${option.value.replace(' ', '-')}` }, option.value)));
79
- const onSingleSelectChange = (option) => {
80
- updateFilter(dispatch, {
81
- filterKey: SolrKeys.severity,
82
- values: [option.value],
83
- });
84
- };
58
+ const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: true, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-severity-${option.value.replace(' ', '-')}` }, option.value)));
85
59
  useEffect(() => {
86
60
  var _a;
87
61
  if (isEmpty(filterInfo[SolrKeys.severity])) {
88
62
  setSelectedItems({});
89
63
  }
90
- else if (!props.isSolrSearchDown) {
64
+ else {
91
65
  const selectedSeverities = (_a = filterInfo[SolrKeys.severity]) === null || _a === void 0 ? void 0 : _a.reduce((selection, severity) => {
92
66
  selection[severity] = true;
93
67
  return selection;
@@ -95,9 +69,9 @@ export function SeverityFilter(props) {
95
69
  setSelectedItems(selectedSeverities);
96
70
  }
97
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
98
- }, [filterInfo[SolrKeys.severity], props.isSolrSearchDown]);
72
+ }, [filterInfo[SolrKeys.severity]]);
99
73
  return (React.createElement("div", { className: "severity-filter" },
100
74
  React.createElement("label", { htmlFor: "case-list-severity-filter", className: "pf-v6-u-mb-sm severity-filter-label" }, t(filterNamesMap[SolrKeys.severity])),
101
- props.isSolrSearchDown ? (React.createElement(SingleSelectDropdown, { id: "case-list-severity-filter", selected: selectedOption, options: singleSelectOptions, placeholder: t('Select a severity'), onSelect: onSingleSelectChange, dataTrackingId: "severity-filter", isScrollable: true })) : (React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: "case-list-severity-filter", "data-tracking-id": "severity-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
102
- React.createElement(SelectList, null, dropdownOptions)))));
75
+ React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: "case-list-severity-filter", "data-tracking-id": "severity-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
76
+ React.createElement(SelectList, null, dropdownOptions))));
103
77
  }
@@ -1,8 +1,5 @@
1
- import { IFacetResponse } from '@rh-support/types/shared';
2
1
  import React from 'react';
3
2
  interface IProps {
4
- filterValues: IFacetResponse[];
5
- isSolrSearchDown: boolean;
6
3
  allCaseStatuses: string[];
7
4
  }
8
5
  export interface IStatusFilterOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"StatusFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/StatusFilter.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,qBAkNzC"}
1
+ {"version":3,"file":"StatusFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/StatusFilter.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAQ/D,UAAU,MAAM;IACZ,eAAe,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,qBAqKzC"}
@@ -1,43 +1,23 @@
1
1
  import { Button, MenuToggle, Select, SelectList, SelectOption, } from '@patternfly/react-core';
2
- import { SingleSelectDropdown, useSelectKeyboardNavigator } from '@rh-support/components';
2
+ import { useSelectKeyboardNavigator } from '@rh-support/components';
3
3
  import isEmpty from 'lodash/isEmpty';
4
4
  import React, { useContext, useEffect, useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { SolrKeys } from '../../../enums/filters';
7
- import { filterNamesMap } from '../../../utils/constants';
7
+ import { filterNamesMap, PORTAL_DISPLAY_STATUSES } from '../../../utils/constants';
8
8
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
9
9
  import { updateFilter } from '../CaseListFilterReducer';
10
10
  export function StatusFilter(props) {
11
- var _a;
12
11
  const dispatch = useContext(CaseListFilterDispatchContext);
13
12
  const { t } = useTranslation();
14
13
  const { filterInfo } = useContext(CaseListFilterStateContext);
15
14
  const [isOpen, setIsOpen] = useState(false);
16
15
  const [selectedItems, setSelectedItems] = useState({});
17
- const list = props.isSolrSearchDown
18
- ? props.allCaseStatuses.map((status) => ({ value: status, key: status }))
19
- : props.filterValues.map((filterValue) => ({ value: filterValue.value, key: filterValue.value }));
20
- const singleSelectOptions = list.map((item) => ({
21
- value: item.value,
22
- label: item.value,
23
- }));
24
- const selectedStatus = ((_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) === null || _a === void 0 ? void 0 : _a[0]) || '';
25
- const selectedOption = {
26
- value: selectedStatus,
27
- label: selectedStatus,
28
- };
16
+ const list = PORTAL_DISPLAY_STATUSES.map((status) => ({ value: status, key: status }));
29
17
  const onToggleClick = (e) => {
30
18
  setIsOpen(!isOpen);
31
19
  };
32
20
  const onSelect = (option) => {
33
- if (props.isSolrSearchDown) {
34
- updateFilter(dispatch, {
35
- filterKey: SolrKeys.status,
36
- values: [option.value],
37
- });
38
- setIsOpen(false);
39
- return;
40
- }
41
21
  const prevSelectedStatuses = Object.keys(selectedItems).filter((item) => selectedItems[item] && item);
42
22
  if (selectedItems[option.value]) {
43
23
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
@@ -75,42 +55,32 @@ export function StatusFilter(props) {
75
55
  else if (selectedValues && selectedValues.length === 1) {
76
56
  return selectedValues[0];
77
57
  }
78
- else if (selectedValues && selectedValues.length === 3) {
58
+ else if (selectedValues && totalLength && selectedValues.length === totalLength) {
79
59
  return t('All cases');
80
60
  }
81
61
  else {
82
- if (selectedValues &&
83
- selectedValues.length === 2 &&
84
- selectedValues.every((item) => item.includes('Waiting'))) {
62
+ const hasAllOpenSelected = selectedValues.includes('In Progress') &&
63
+ selectedValues.includes('Waiting on Customer') &&
64
+ !selectedValues.includes('Closed');
65
+ if (hasAllOpenSelected) {
85
66
  return t('All open cases');
86
67
  }
87
- else if (selectedValues && totalLength && selectedValues.length === totalLength) {
88
- return totalLengthString || btnPlaceholder;
89
- }
90
68
  else {
91
69
  return `${selectedValues.length} ${type} selected`;
92
70
  }
93
71
  }
94
72
  };
95
- const placeholder = props.isSolrSearchDown
96
- ? t('Select a status')
97
- : getBtnPlaceholder(t('Select a status'), (filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) || [], ' ', list.length, t('All selected'));
73
+ const placeholder = getBtnPlaceholder(t('Select a status'), (filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) || [], ' ', list.length, t('All selected'));
98
74
  const toggle = (toggleRef) => (React.createElement(MenuToggle, { variant: "default", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true, onKeyDown: onInputKeyDown },
99
75
  placeholder,
100
76
  Object.keys(selectedItems).filter((key) => selectedItems[key] === true).length > 0 && (React.createElement(Button, { icon: "", variant: "plain", onClick: onClick, "aria-label": "Clear selection", className: "pf-v6-c-select__toggle-clear" }))));
101
- const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: !props.isSolrSearchDown, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-status-${option.value.replace(' ', '-')}` }, option.value)));
102
- const onSingleSelectChange = (option) => {
103
- updateFilter(dispatch, {
104
- filterKey: SolrKeys.status,
105
- values: [option.value],
106
- });
107
- };
77
+ const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: true, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-status-${option.value.replace(' ', '-')}` }, option.value)));
108
78
  useEffect(() => {
109
79
  var _a;
110
80
  if (isEmpty(filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status])) {
111
81
  setSelectedItems({});
112
82
  }
113
- else if (!props.isSolrSearchDown) {
83
+ else {
114
84
  const selectedStatuses = (_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) === null || _a === void 0 ? void 0 : _a.reduce((selection, status) => {
115
85
  selection[status] = true;
116
86
  return selection;
@@ -118,10 +88,10 @@ export function StatusFilter(props) {
118
88
  setSelectedItems(selectedStatuses || {});
119
89
  }
120
90
  // eslint-disable-next-line react-hooks/exhaustive-deps
121
- }, [filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status], props.isSolrSearchDown]);
91
+ }, [filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]]);
122
92
  const titleId = 'case-list-status-filter';
123
93
  return (React.createElement("div", { className: "status-filter" },
124
94
  React.createElement("label", { htmlFor: titleId, className: "pf-v6-u-mb-sm status-filter-label" }, t(filterNamesMap[SolrKeys.status])),
125
- props.isSolrSearchDown ? (React.createElement(SingleSelectDropdown, { id: titleId, selected: selectedOption, options: singleSelectOptions, placeholder: t('Select a status'), onSelect: onSingleSelectChange, dataTrackingId: "status-filter", isScrollable: true })) : (React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: titleId, "data-tracking-id": "status-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
126
- React.createElement(SelectList, null, dropdownOptions)))));
95
+ React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: titleId, "data-tracking-id": "status-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
96
+ React.createElement(SelectList, null, dropdownOptions))));
127
97
  }
@@ -1,10 +1,8 @@
1
1
  import React from 'react';
2
- import { IProductVersionPivotMap } from '../CaseList';
3
2
  import { IProductFilter } from '../CaseListFilterReducer';
4
3
  interface IProps {
5
4
  productInfo: IProductFilter;
6
- productVersionPivot: IProductVersionPivotMap[];
7
5
  }
8
- export declare function VersionsFilter({ productInfo, productVersionPivot }: IProps): React.JSX.Element;
6
+ export declare function VersionsFilter({ productInfo }: IProps): React.JSX.Element;
9
7
  export {};
10
8
  //# sourceMappingURL=VersionsFilter.d.ts.map