@rh-support/cases 2.6.170 → 2.6.173

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 +7 -0
  2. package/lib/esm/components/case-list/CaseList.d.ts.map +1 -1
  3. package/lib/esm/components/case-list/CaseList.js +107 -106
  4. package/lib/esm/components/case-list/CaseListContext.d.ts.map +1 -1
  5. package/lib/esm/components/case-list/CaseListContext.js +2 -0
  6. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts +1 -5
  7. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts.map +1 -1
  8. package/lib/esm/components/case-list/CaseListFilterReducer.js +1 -2
  9. package/lib/esm/components/case-list/CaseListReducer.d.ts +8 -2
  10. package/lib/esm/components/case-list/CaseListReducer.d.ts.map +1 -1
  11. package/lib/esm/components/case-list/CaseListReducer.js +13 -1
  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 +11 -18
  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 +2 -4
  16. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts +7 -1
  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 +15 -7
  19. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts +5 -2
  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 +3 -1
  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 +4 -5
  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 +54 -15
  28. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts +3 -0
  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 +44 -18
  31. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts +3 -0
  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 +44 -14
  34. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts +3 -1
  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 +32 -61
  37. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts +1 -0
  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 +6 -5
  40. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts +5 -0
  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 +68 -38
  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 +15 -5
  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 +3 -2
  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 +0 -1
  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 +1 -2
  54. package/lib/esm/enums/case.d.ts +1 -2
  55. package/lib/esm/enums/case.d.ts.map +1 -1
  56. package/lib/esm/enums/case.js +1 -14
  57. package/lib/esm/hooks/useExportCaseListCSV.d.ts.map +1 -1
  58. package/lib/esm/hooks/useExportCaseListCSV.js +9 -1
  59. package/lib/esm/test-utils/mockData.js +1 -1
  60. package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
  61. package/lib/esm/utils/caseSearchUtils.js +1 -26
  62. package/lib/esm/utils/constants.d.ts +1 -2
  63. package/lib/esm/utils/constants.d.ts.map +1 -1
  64. package/lib/esm/utils/constants.js +3 -14
  65. package/lib/esm/utils/mockSolrResponse.js +1 -1
  66. package/package.json +6 -6
  67. package/lib/esm/utils/caseListGraphQLUtils.d.ts +0 -16
  68. package/lib/esm/utils/caseListGraphQLUtils.d.ts.map +0 -1
  69. package/lib/esm/utils/caseListGraphQLUtils.js +0 -193
  70. package/lib/esm/utils/caseListMapper.d.ts +0 -6
  71. package/lib/esm/utils/caseListMapper.d.ts.map +0 -1
  72. package/lib/esm/utils/caseListMapper.js +0 -36
  73. package/lib/esm/utils/caseListVariablesBuilder.d.ts +0 -13
  74. package/lib/esm/utils/caseListVariablesBuilder.d.ts.map +0 -1
  75. package/lib/esm/utils/caseListVariablesBuilder.js +0 -160
  76. package/lib/esm/utils/statusUtils.d.ts +0 -3
  77. package/lib/esm/utils/statusUtils.d.ts.map +0 -1
  78. package/lib/esm/utils/statusUtils.js +0 -22
@@ -1,3 +1,9 @@
1
1
  import React from 'react';
2
- export declare function CaseListFilterChips(): React.JSX.Element;
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 {};
3
9
  //# 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;AAU1C,wBAAgB,mBAAmB,sBAwHlC"}
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"}
@@ -7,10 +7,11 @@ 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';
10
11
  import { clearFilters, removeFilterItem } from '../CaseListFilterReducer';
11
12
  import { CreatorSsoNameFilterChip } from './CreatorSsoNameFilterChip';
12
13
  import { ProductFilterChip } from './ProductFilterChip';
13
- export function CaseListFilterChips() {
14
+ export function CaseListFilterChips(props) {
14
15
  const { filterInfo } = useContext(CaseListFilterStateContext);
15
16
  const dispatch = useContext(CaseListFilterDispatchContext);
16
17
  const currentFilterLength = flatMap(filterInfo).length;
@@ -36,10 +37,15 @@ export function CaseListFilterChips() {
36
37
  };
37
38
  const getChipGroupForFilter = (filterKey, filterValues, groupName = '') => {
38
39
  const caseTypeFilter = filterKey === 'case_type' ? toNewCaseTypeMapper(filterValues) : filterValues;
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))));
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
+ }
43
49
  };
44
50
  const renderAccountFilterChip = () => {
45
51
  const visibleChips = [];
@@ -80,8 +86,10 @@ export function CaseListFilterChips() {
80
86
  return (React.createElement(React.Fragment, null, isAnyFilterApplied && (React.createElement("div", { className: "filter-chip-wrapper" },
81
87
  React.createElement("h2", null, "Filtering by"),
82
88
  React.createElement("div", { className: "filter-chips" },
83
- Array.isArray(filterInfo[ProductVersionKey]) && filterInfo[ProductVersionKey].length > 0 && (React.createElement(ProductFilterChip, { productList: filterInfo[ProductVersionKey] })),
84
- showUsernameFilter && React.createElement(CreatorSsoNameFilterChip, null),
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),
85
93
  renderChips(),
86
94
  currentFilterLength > 1 && (React.createElement(Button, { variant: "link", isInline: true, onClick: clearAllFilters, "data-tracking-id": "case-list-clear-filters", className: "clear-filters" },
87
95
  React.createElement(Trans, null, "Clear all filters"))))))));
@@ -1,12 +1,15 @@
1
1
  import { IApiResponseDetails } from '@rh-support/types/shared';
2
- import { ITroubleshootProductResponse } from '@rh-support/utils';
2
+ import { ISolrResponseToFacetFields, ITroubleshootProductResponse } from '@rh-support/utils';
3
3
  import React from 'react';
4
+ import { IFacetFields } from '../../../models/caseList';
4
5
  interface IProps {
6
+ filterValues: ISolrResponseToFacetFields<IFacetFields>;
7
+ isSolrSearchDown: boolean;
5
8
  allCaseTypes: IApiResponseDetails<string[]>;
6
9
  allCaseStatuses: IApiResponseDetails<string[]>;
7
10
  allCaseSeverities: IApiResponseDetails<string[]>;
8
11
  allProducts: IApiResponseDetails<ITroubleshootProductResponse>;
9
12
  }
10
- export declare const CaseListFilters: ({ allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts }: IProps) => React.JSX.Element;
13
+ export declare const CaseListFilters: ({ filterValues, allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts, isSolrSearchDown, }: IProps) => React.JSX.Element;
11
14
  export {};
12
15
  //# 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,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
+ {"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,5 +1,7 @@
1
1
  import { AbilityContext, CaseListFields, resourceActions, resources } from '@rh-support/user-permissions';
2
+ import get from 'lodash/get';
2
3
  import React, { useContext } from 'react';
4
+ import { SolrKeys } from '../../../enums/filters';
3
5
  import { AccountsBookmarkedGroupFilter } from './AccountsBookmarkedGroupFilter';
4
6
  import { AccountsFilter } from './AccountsFilter';
5
7
  import { AdditionalFilters } from './AdditionalFilters';
@@ -9,7 +11,9 @@ import { ProductsFilter } from './ProductsFilter';
9
11
  import { SeverityFilter } from './SeverityFilter';
10
12
  import { StatusFilter } from './StatusFilter';
11
13
  import { TypeFilter } from './TypeFilter';
12
- export const CaseListFilters = ({ allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts }) => {
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, }) => {
13
17
  var _a, _b;
14
18
  const ability = useContext(AbilityContext);
15
19
  const canReadAccountFilter = ability.can(resourceActions.READ, resources.ACCOUNTS_FILTER);
@@ -21,21 +25,17 @@ export const CaseListFilters = ({ allCaseTypes, allCaseSeverities, allCaseStatus
21
25
  const canAccessSeverityFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.SEVERITY_FILTER);
22
26
  const canAccessAdditionalFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.ADDITIONAL_FILTER);
23
27
  const canAccessGroupsFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.GROUPS_FILTER);
24
- void canAccessGroupsFilter;
25
- void GroupsFilter;
26
28
  const canAccessCreatorFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.CREATOR_FILTER);
27
29
  const canAccessTypeFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.TYPE_FILTER);
28
30
  return (React.createElement(React.Fragment, null,
29
31
  React.createElement("div", { className: "filter-group" },
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))));
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))));
41
41
  };
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
+ import { IProductVersionPivotMap } from '../CaseList';
2
3
  import { IProductFilter } from '../CaseListFilterReducer';
3
4
  interface IProps {
4
5
  productList: IProductFilter[];
6
+ productVersionPivot: IProductVersionPivotMap[];
5
7
  }
6
- export declare function ProductFilterChip({ productList }: IProps): React.JSX.Element;
8
+ export declare function ProductFilterChip({ productList, productVersionPivot }: IProps): React.JSX.Element;
7
9
  export {};
8
10
  //# 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;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"}
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"}
@@ -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 }) {
10
+ export function ProductFilterChip({ productList, productVersionPivot = [] }) {
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 }) {
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 }),
29
+ React.createElement(VersionsFilter, { productInfo: currentProduct, productVersionPivot: productVersionPivot }),
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,10 +1,9 @@
1
+ import { IFacetResponse } from '@rh-support/types/shared';
1
2
  import React from 'react';
2
- interface IProductOption {
3
- name: string;
4
- productId: string;
5
- }
6
3
  interface IProps {
7
- allProducts: IProductOption[];
4
+ filterValues: IFacetResponse[];
5
+ isSolrSearchDown: boolean;
6
+ allProducts: string[];
8
7
  }
9
8
  export declare function ProductsFilter(props: IProps): React.JSX.Element;
10
9
  export {};
@@ -1 +1 @@
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
+ {"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,5 +1,5 @@
1
1
  import { MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, } from '@patternfly/react-core';
2
- import { useSelectKeyboardNavigator } from '@rh-support/components';
2
+ import { SingleSelectDropdown, useSelectKeyboardNavigator } from '@rh-support/components';
3
3
  import { getDropdownBtnPlaceholder } from '@rh-support/utils';
4
4
  import isEmpty from 'lodash/isEmpty';
5
5
  import 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;
13
+ var _a, _b, _c, _d, _f;
14
14
  const { t } = useTranslation();
15
15
  const dispatch = useContext(CaseListFilterDispatchContext);
16
16
  const { filterInfo } = useContext(CaseListFilterStateContext);
17
- const { allProducts } = props;
17
+ const { allProducts, filterValues, isSolrSearchDown } = props;
18
18
  const [isOpen, setIsOpen] = useState(false);
19
19
  const [selectedItems, setSelectedItems] = useState({});
20
20
  const [activeItem, setActiveItem] = useState(null);
@@ -23,24 +23,51 @@ 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 = allProducts.map((product) => ({
26
+ const productOptions = filterValues.map((product) => ({
27
27
  field: SolrKeys.product,
28
- value: product.name,
29
- productId: product.productId,
28
+ value: product.value,
30
29
  [SolrKeys.version]: [],
31
30
  }));
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
32
61
  const onSelect = (option) => {
33
- var _a;
34
62
  let newSelectedProducts = [];
35
63
  if (selectedProducts === null || selectedProducts === void 0 ? void 0 : selectedProducts.some((product) => option.value === product.value)) {
36
64
  newSelectedProducts = selectedProducts.filter((product) => option.value !== product.value);
37
65
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
38
66
  }
39
67
  else {
40
- const productId = option.productId || ((_a = allProducts.find((p) => p.name === option.value)) === null || _a === void 0 ? void 0 : _a.productId) || '';
41
68
  newSelectedProducts = [
42
69
  ...selectedProducts,
43
- { field: SolrKeys.product, value: option.value, productId, [SolrKeys.version]: [] },
70
+ { field: SolrKeys.product, value: option.value, [SolrKeys.version]: [] },
44
71
  ];
45
72
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
46
73
  }
@@ -66,12 +93,21 @@ export function ProductsFilter(props) {
66
93
  resetIndexOnClose: true,
67
94
  isDisabled: false,
68
95
  setIsOpen,
69
- onSelect,
96
+ onSelect: (item) => {
97
+ if (isSolrSearchDown) {
98
+ onFilterChangeSingleSelect(item);
99
+ }
100
+ else {
101
+ onSelect(item);
102
+ }
103
+ },
70
104
  });
71
105
  const onTextInputChange = (_event, value) => {
72
106
  setInputValue(value);
73
107
  };
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'));
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'));
75
111
  const toggleForMultiSelect = (toggleRef) => (React.createElement(MenuToggle, { variant: "typeahead", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true },
76
112
  React.createElement(TextInputGroup, { isPlain: true },
77
113
  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" })))));
@@ -93,6 +129,9 @@ export function ProductsFilter(props) {
93
129
  }, [inputValue]);
94
130
  useEffect(() => {
95
131
  var _a;
132
+ if (isSolrSearchDown) {
133
+ return;
134
+ }
96
135
  if (isEmpty(filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrPivotKeys.product_version])) {
97
136
  setSelectedItems({});
98
137
  }
@@ -103,13 +142,13 @@ export function ProductsFilter(props) {
103
142
  }, {});
104
143
  setSelectedItems(selectedProductItems || {});
105
144
  }
106
- }, [filterInfo]);
145
+ }, [filterInfo, isSolrSearchDown]);
107
146
  const renderOptions = () => {
108
147
  const filteredOptions = getFilteredOptions();
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)));
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)));
110
149
  };
111
150
  return (React.createElement("div", { className: "product-filter" },
112
151
  React.createElement("label", { htmlFor: "case-list-products-filter", className: "pf-v6-u-mb-sm products-filter-label" }, t(filterNamesMap[SolrKeys.product])),
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()))));
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())))));
115
154
  }
@@ -1,6 +1,9 @@
1
+ import { IFacetResponse } from '@rh-support/types/shared';
1
2
  import React from 'react';
2
3
  interface IProps {
4
+ filterValues: IFacetResponse[];
3
5
  allCaseSeverities: string[];
6
+ isSolrSearchDown: boolean;
4
7
  }
5
8
  export declare function SeverityFilter(props: IProps): React.JSX.Element;
6
9
  export {};
@@ -1 +1 @@
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
+ {"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,5 +1,5 @@
1
1
  import { Button, MenuToggle, Select, SelectList, SelectOption, } from '@patternfly/react-core';
2
- import { useSelectKeyboardNavigator } from '@rh-support/components';
2
+ import { SingleSelectDropdown, useSelectKeyboardNavigator } from '@rh-support/components';
3
3
  import { getDropdownBtnPlaceholder } from '@rh-support/utils';
4
4
  import isEmpty from 'lodash/isEmpty';
5
5
  import React, { useContext, useEffect, useState } from 'react';
@@ -9,38 +9,56 @@ import { filterNamesMap } from '../../../utils/constants';
9
9
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
10
10
  import { updateFilter } from '../CaseListFilterReducer';
11
11
  export function SeverityFilter(props) {
12
+ var _a;
12
13
  const { t } = useTranslation();
13
14
  const { filterInfo } = useContext(CaseListFilterStateContext);
14
15
  const dispatch = useContext(CaseListFilterDispatchContext);
15
16
  const [isOpen, setIsOpen] = useState(false);
16
17
  const [selectedItems, setSelectedItems] = useState({});
17
- const list = (props.allCaseSeverities || []).map((severity) => ({
18
- value: severity,
19
- key: severity,
18
+ const list = props.isSolrSearchDown
19
+ ? props.allCaseSeverities.map((severity) => ({ value: severity, key: severity }))
20
+ : props.filterValues.map((filterValue) => ({ value: filterValue.value, key: filterValue.value }));
21
+ const singleSelectOptions = list.map((item) => ({
22
+ value: item.value,
23
+ label: item.value,
20
24
  }));
25
+ const selectedSeverity = ((_a = filterInfo[SolrKeys.severity]) === null || _a === void 0 ? void 0 : _a[0]) || '';
26
+ const selectedOption = {
27
+ value: selectedSeverity,
28
+ label: selectedSeverity,
29
+ };
21
30
  const onToggleClick = (e) => {
22
31
  setIsOpen(!isOpen);
23
32
  };
24
33
  const onSelect = (option) => {
25
- const prevSelectedSeverities = Object.keys(selectedItems).filter((item) => selectedItems[item] && item);
26
- if (selectedItems[option.value]) {
27
- setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
34
+ if (props.isSolrSearchDown) {
28
35
  updateFilter(dispatch, {
29
36
  filterKey: SolrKeys.severity,
30
- values: prevSelectedSeverities.filter((item) => item !== option.value),
37
+ values: [option.value],
31
38
  });
39
+ setIsOpen(false);
40
+ return;
41
+ }
42
+ const prevSelectedSeverities = Object.keys(selectedItems).filter((item) => selectedItems[item] && item);
43
+ if (selectedItems[option.value]) {
44
+ setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
45
+ const index = prevSelectedSeverities.indexOf(option.value);
46
+ prevSelectedSeverities.splice(index, 1);
32
47
  }
33
48
  else {
34
49
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: true })));
35
- updateFilter(dispatch, {
36
- filterKey: SolrKeys.severity,
37
- values: [...prevSelectedSeverities, option.value],
38
- });
50
+ prevSelectedSeverities.push(option.value);
39
51
  }
52
+ updateFilter(dispatch, {
53
+ filterKey: SolrKeys.severity,
54
+ values: prevSelectedSeverities,
55
+ });
40
56
  };
57
+ // Use the keyboard navigator hook
41
58
  const { focusedItemIndex, onInputKeyDown } = useSelectKeyboardNavigator({
42
59
  list,
43
60
  isOpen,
61
+ resetIndexOnClose: true,
44
62
  setIsOpen,
45
63
  onSelect,
46
64
  });
@@ -51,17 +69,25 @@ export function SeverityFilter(props) {
51
69
  values: [],
52
70
  });
53
71
  };
54
- const placeholder = getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', list.length, t('All selected'));
72
+ const placeholder = props.isSolrSearchDown
73
+ ? t('Select a severity')
74
+ : getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', list.length, t('All selected'));
55
75
  const toggle = (toggleRef) => (React.createElement(MenuToggle, { variant: "default", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true, onKeyDown: onInputKeyDown },
56
76
  placeholder,
57
77
  Object.keys(selectedItems).filter((key) => selectedItems[key] === true).length > 0 && (React.createElement(Button, { icon: "", variant: "plain", onClick: onClick, "aria-label": "Clear selection", className: "pf-v6-c-select__toggle-clear" }))));
58
- const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: true, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-severity-${option.value.replace(' ', '-')}` }, option.value)));
78
+ const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: !props.isSolrSearchDown, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-severity-${option.value.replace(' ', '-')}` }, option.value)));
79
+ const onSingleSelectChange = (option) => {
80
+ updateFilter(dispatch, {
81
+ filterKey: SolrKeys.severity,
82
+ values: [option.value],
83
+ });
84
+ };
59
85
  useEffect(() => {
60
86
  var _a;
61
87
  if (isEmpty(filterInfo[SolrKeys.severity])) {
62
88
  setSelectedItems({});
63
89
  }
64
- else {
90
+ else if (!props.isSolrSearchDown) {
65
91
  const selectedSeverities = (_a = filterInfo[SolrKeys.severity]) === null || _a === void 0 ? void 0 : _a.reduce((selection, severity) => {
66
92
  selection[severity] = true;
67
93
  return selection;
@@ -69,9 +95,9 @@ export function SeverityFilter(props) {
69
95
  setSelectedItems(selectedSeverities);
70
96
  }
71
97
  // eslint-disable-next-line react-hooks/exhaustive-deps
72
- }, [filterInfo[SolrKeys.severity]]);
98
+ }, [filterInfo[SolrKeys.severity], props.isSolrSearchDown]);
73
99
  return (React.createElement("div", { className: "severity-filter" },
74
100
  React.createElement("label", { htmlFor: "case-list-severity-filter", className: "pf-v6-u-mb-sm severity-filter-label" }, t(filterNamesMap[SolrKeys.severity])),
75
- React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: "case-list-severity-filter", "data-tracking-id": "severity-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
76
- React.createElement(SelectList, null, dropdownOptions))));
101
+ props.isSolrSearchDown ? (React.createElement(SingleSelectDropdown, { id: "case-list-severity-filter", selected: selectedOption, options: singleSelectOptions, placeholder: t('Select a severity'), onSelect: onSingleSelectChange, dataTrackingId: "severity-filter", isScrollable: true })) : (React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: "case-list-severity-filter", "data-tracking-id": "severity-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
102
+ React.createElement(SelectList, null, dropdownOptions)))));
77
103
  }
@@ -1,5 +1,8 @@
1
+ import { IFacetResponse } from '@rh-support/types/shared';
1
2
  import React from 'react';
2
3
  interface IProps {
4
+ filterValues: IFacetResponse[];
5
+ isSolrSearchDown: boolean;
3
6
  allCaseStatuses: string[];
4
7
  }
5
8
  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":"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
+ {"version":3,"file":"StatusFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/StatusFilter.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,qBAkNzC"}
@@ -1,23 +1,43 @@
1
1
  import { Button, MenuToggle, Select, SelectList, SelectOption, } from '@patternfly/react-core';
2
- import { useSelectKeyboardNavigator } from '@rh-support/components';
2
+ import { SingleSelectDropdown, useSelectKeyboardNavigator } from '@rh-support/components';
3
3
  import isEmpty from 'lodash/isEmpty';
4
4
  import React, { useContext, useEffect, useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { SolrKeys } from '../../../enums/filters';
7
- import { filterNamesMap, PORTAL_DISPLAY_STATUSES } from '../../../utils/constants';
7
+ import { filterNamesMap } from '../../../utils/constants';
8
8
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
9
9
  import { updateFilter } from '../CaseListFilterReducer';
10
10
  export function StatusFilter(props) {
11
+ var _a;
11
12
  const dispatch = useContext(CaseListFilterDispatchContext);
12
13
  const { t } = useTranslation();
13
14
  const { filterInfo } = useContext(CaseListFilterStateContext);
14
15
  const [isOpen, setIsOpen] = useState(false);
15
16
  const [selectedItems, setSelectedItems] = useState({});
16
- const list = PORTAL_DISPLAY_STATUSES.map((status) => ({ value: status, key: status }));
17
+ const list = props.isSolrSearchDown
18
+ ? props.allCaseStatuses.map((status) => ({ value: status, key: status }))
19
+ : props.filterValues.map((filterValue) => ({ value: filterValue.value, key: filterValue.value }));
20
+ const singleSelectOptions = list.map((item) => ({
21
+ value: item.value,
22
+ label: item.value,
23
+ }));
24
+ const selectedStatus = ((_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) === null || _a === void 0 ? void 0 : _a[0]) || '';
25
+ const selectedOption = {
26
+ value: selectedStatus,
27
+ label: selectedStatus,
28
+ };
17
29
  const onToggleClick = (e) => {
18
30
  setIsOpen(!isOpen);
19
31
  };
20
32
  const onSelect = (option) => {
33
+ if (props.isSolrSearchDown) {
34
+ updateFilter(dispatch, {
35
+ filterKey: SolrKeys.status,
36
+ values: [option.value],
37
+ });
38
+ setIsOpen(false);
39
+ return;
40
+ }
21
41
  const prevSelectedStatuses = Object.keys(selectedItems).filter((item) => selectedItems[item] && item);
22
42
  if (selectedItems[option.value]) {
23
43
  setSelectedItems((prevData) => (Object.assign(Object.assign({}, prevData), { [option.value]: false })));
@@ -55,32 +75,42 @@ export function StatusFilter(props) {
55
75
  else if (selectedValues && selectedValues.length === 1) {
56
76
  return selectedValues[0];
57
77
  }
58
- else if (selectedValues && totalLength && selectedValues.length === totalLength) {
78
+ else if (selectedValues && selectedValues.length === 3) {
59
79
  return t('All cases');
60
80
  }
61
81
  else {
62
- const hasAllOpenSelected = selectedValues.includes('In Progress') &&
63
- selectedValues.includes('Waiting on Customer') &&
64
- !selectedValues.includes('Closed');
65
- if (hasAllOpenSelected) {
82
+ if (selectedValues &&
83
+ selectedValues.length === 2 &&
84
+ selectedValues.every((item) => item.includes('Waiting'))) {
66
85
  return t('All open cases');
67
86
  }
87
+ else if (selectedValues && totalLength && selectedValues.length === totalLength) {
88
+ return totalLengthString || btnPlaceholder;
89
+ }
68
90
  else {
69
91
  return `${selectedValues.length} ${type} selected`;
70
92
  }
71
93
  }
72
94
  };
73
- const placeholder = getBtnPlaceholder(t('Select a status'), (filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) || [], ' ', list.length, t('All selected'));
95
+ const placeholder = props.isSolrSearchDown
96
+ ? t('Select a status')
97
+ : getBtnPlaceholder(t('Select a status'), (filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) || [], ' ', list.length, t('All selected'));
74
98
  const toggle = (toggleRef) => (React.createElement(MenuToggle, { variant: "default", onClick: onToggleClick, innerRef: toggleRef, isExpanded: isOpen, isFullWidth: true, onKeyDown: onInputKeyDown },
75
99
  placeholder,
76
100
  Object.keys(selectedItems).filter((key) => selectedItems[key] === true).length > 0 && (React.createElement(Button, { icon: "", variant: "plain", onClick: onClick, "aria-label": "Clear selection", className: "pf-v6-c-select__toggle-clear" }))));
77
- const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: true, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-status-${option.value.replace(' ', '-')}` }, option.value)));
101
+ const dropdownOptions = list.map((option, index) => !isEmpty(option.value) && (React.createElement(SelectOption, { key: option.key, value: option, hasCheckbox: !props.isSolrSearchDown, isSelected: selectedItems[option.value], isFocused: focusedItemIndex !== null && focusedItemIndex === index, id: `select-status-${option.value.replace(' ', '-')}` }, option.value)));
102
+ const onSingleSelectChange = (option) => {
103
+ updateFilter(dispatch, {
104
+ filterKey: SolrKeys.status,
105
+ values: [option.value],
106
+ });
107
+ };
78
108
  useEffect(() => {
79
109
  var _a;
80
110
  if (isEmpty(filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status])) {
81
111
  setSelectedItems({});
82
112
  }
83
- else {
113
+ else if (!props.isSolrSearchDown) {
84
114
  const selectedStatuses = (_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]) === null || _a === void 0 ? void 0 : _a.reduce((selection, status) => {
85
115
  selection[status] = true;
86
116
  return selection;
@@ -88,10 +118,10 @@ export function StatusFilter(props) {
88
118
  setSelectedItems(selectedStatuses || {});
89
119
  }
90
120
  // eslint-disable-next-line react-hooks/exhaustive-deps
91
- }, [filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status]]);
121
+ }, [filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.status], props.isSolrSearchDown]);
92
122
  const titleId = 'case-list-status-filter';
93
123
  return (React.createElement("div", { className: "status-filter" },
94
124
  React.createElement("label", { htmlFor: titleId, className: "pf-v6-u-mb-sm status-filter-label" }, t(filterNamesMap[SolrKeys.status])),
95
- React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: titleId, "data-tracking-id": "status-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
96
- React.createElement(SelectList, null, dropdownOptions))));
125
+ props.isSolrSearchDown ? (React.createElement(SingleSelectDropdown, { id: titleId, selected: selectedOption, options: singleSelectOptions, placeholder: t('Select a status'), onSelect: onSingleSelectChange, dataTrackingId: "status-filter", isScrollable: true })) : (React.createElement(Select, { shouldFocusToggleOnSelect: true, shouldPreventScrollOnItemFocus: true, id: titleId, "data-tracking-id": "status-filter", isOpen: isOpen, selected: selectedItems, onSelect: (_e, v) => onSelect(v), onOpenChange: (nextOpen) => setIsOpen(nextOpen), toggle: toggle, isScrollable: true, popperProps: { direction: 'down', enableFlip: false } },
126
+ React.createElement(SelectList, null, dropdownOptions)))));
97
127
  }
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
+ import { IProductVersionPivotMap } from '../CaseList';
2
3
  import { IProductFilter } from '../CaseListFilterReducer';
3
4
  interface IProps {
4
5
  productInfo: IProductFilter;
6
+ productVersionPivot: IProductVersionPivotMap[];
5
7
  }
6
- export declare function VersionsFilter({ productInfo }: IProps): React.JSX.Element;
8
+ export declare function VersionsFilter({ productInfo, productVersionPivot }: IProps): React.JSX.Element;
7
9
  export {};
8
10
  //# sourceMappingURL=VersionsFilter.d.ts.map