@rh-support/cases 0.2.27 → 0.2.31

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 (26) hide show
  1. package/lib/esm/components/case-list/CaseList.d.ts.map +1 -1
  2. package/lib/esm/components/case-list/CaseList.js +48 -27
  3. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts +8 -3
  4. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts.map +1 -1
  5. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.js +8 -10
  6. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts +2 -1
  7. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts.map +1 -1
  8. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.js +8 -1
  9. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts +2 -1
  10. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts.map +1 -1
  11. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.js +6 -5
  12. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts +2 -0
  13. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts.map +1 -1
  14. package/lib/esm/components/case-list/case-list-filters/StatusFilter.js +17 -9
  15. package/lib/esm/components/case-list/case-list-filters/TypeFilter.d.ts.map +1 -1
  16. package/lib/esm/components/case-list/case-list-filters/TypeFilter.js +6 -2
  17. package/lib/esm/components/case-list/case-list-table/CaseListTable.js +1 -1
  18. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.js +1 -1
  19. package/lib/esm/test-utils/mockData.d.ts +1 -0
  20. package/lib/esm/test-utils/mockData.d.ts.map +1 -1
  21. package/lib/esm/test-utils/mockData.js +1 -0
  22. package/lib/esm/utils/caseListUtils.d.ts +7 -1
  23. package/lib/esm/utils/caseListUtils.d.ts.map +1 -1
  24. package/lib/esm/utils/caseListUtils.js +63 -37
  25. package/lib/esm/utils/constants.js +1 -1
  26. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"CaseList.d.ts","sourceRoot":"","sources":["../../../../src/components/case-list/CaseList.tsx"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAChC,OAAO,0BAA0B,CAAC;AAyBlC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAKH,0BAA0B,EAK7B,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,mBAAmB,EAAe,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAK1C,OAAO,EAAgB,WAAW,EAA2B,MAAM,uBAAuB,CAAC;AA4B3F,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,uBAAwB,SAAQ,cAAc;IAC3D,YAAY,EAAE,cAAc,EAAE,CAAC;CAClC;AAED,oBAAY,YAAY,GAAG,0BAA0B,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;AAM5F,MAAM,WAAW,gBAAgB;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,eA6arC"}
1
+ {"version":3,"file":"CaseList.d.ts","sourceRoot":"","sources":["../../../../src/components/case-list/CaseList.tsx"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAChC,OAAO,0BAA0B,CAAC;AA4BlC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAKH,0BAA0B,EAI7B,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,mBAAmB,EAAe,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAK1C,OAAO,EAAgB,WAAW,EAA2B,MAAM,uBAAuB,CAAC;AA4B3F,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,uBAAwB,SAAQ,cAAc;IAC3D,YAAY,EAAE,cAAc,EAAE,CAAC;CAClC;AAED,oBAAY,YAAY,GAAG,0BAA0B,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;AAM5F,MAAM,WAAW,gBAAgB;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,eAucrC"}
@@ -15,9 +15,8 @@ import AngleDoubleLeftIcon from '@patternfly/react-icons/dist/js/icons/angle-dou
15
15
  import AngleDoubleRightIcon from '@patternfly/react-icons/dist/js/icons/angle-double-right-icon';
16
16
  import AngleDoubleUpIcon from '@patternfly/react-icons/dist/js/icons/angle-double-up-icon';
17
17
  import { ErrorBoundary, ToastNotification, useBreakpoint, useDocumentTitle, useForceUpdate, usePrevious, } from '@rh-support/components';
18
- import { fetchCaseGroupsForSSO, fetchCaseTypes, GlobalMetadataDispatchContext, GlobalMetadataStateContext, setUserPreferences, updateUserPreferences, UserPreferencesKeys, } from '@rh-support/react-context';
19
- import { getConfigField, getStringifiedParams, getUrlParsedParams, haventLoadedMetadata, PCM_CONFIG_FIELD_TYPE, pendoTrackEvent, solrResponseToFacetFields, solrResponseToPivotFields, } from '@rh-support/utils';
20
- import every from 'lodash/every';
18
+ import { fetchAllStatuses, fetchCaseGroupsForSSO, fetchCaseSeverities, fetchCaseTypes, fetchProducts, GlobalMetadataDispatchContext, GlobalMetadataStateContext, setUserPreferences, updateUserPreferences, UserPreferencesKeys, } from '@rh-support/react-context';
19
+ import { getStringifiedParams, getUrlParsedParams, haventLoadedMetadata, haventLoadedProductsMetadata, pendoTrackEvent, solrResponseToFacetFields, solrResponseToPivotFields, } from '@rh-support/utils';
21
20
  import get from 'lodash/get';
22
21
  import some from 'lodash/some';
23
22
  import React, { useContext, useEffect, useRef, useState } from 'react';
@@ -48,7 +47,7 @@ export function CaseList(props) {
48
47
  const { caseList, pivotValues, isFetching, filterValuesFromFacetResponse, currentQuery } = useCaseListStateContext();
49
48
  const CaseListDispatch = useCaseListDispatchContext();
50
49
  const breakPoint = useBreakpoint();
51
- const { globalMetadataState, globalMetadataState: { caseGroups, loggedInUserJwtToken, loggedInUserRights, loggedInUsersAccount, userPreferences, managedAccounts, bookmarkedAccounts, bookmarkedGroupAccounts, allCaseTypes, pcmConfig, }, } = useContext(GlobalMetadataStateContext);
50
+ const { globalMetadataState, globalMetadataState: { caseGroups, loggedInUserJwtToken, loggedInUserRights, loggedInUsersAccount, userPreferences, managedAccounts, bookmarkedAccounts, bookmarkedGroupAccounts, allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts, }, } = useContext(GlobalMetadataStateContext);
52
51
  const location = useLocation();
53
52
  const searchParams = getUrlParsedParams(location.search);
54
53
  const queryFromUrl = searchParams[FILTER_URL_QUERY_SEARCH_PARAM];
@@ -68,11 +67,10 @@ export function CaseList(props) {
68
67
  const prevSearchType = usePrevious(filterState.filterQueryInfo.type);
69
68
  let isSearchTypeChanged = filterState.filterQueryInfo.type !== prevSearchType;
70
69
  const [hasError, setHasError] = useState(null);
71
- const alwaysUseSFDC = getConfigField(pcmConfig.data, 'alwaysUseSFDC', PCM_CONFIG_FIELD_TYPE.FEATURE_FLAG);
72
- // sfdc call should be called only when we don't have any filter applied
73
- const forceSfdcSearch = () => every(filterState.filterInfo, (filter) => filter.length === 0);
70
+ const [isSolrSearchDown, setSolrSearchDown] = useState(false);
74
71
  function getCases(currentFilterState) {
75
72
  return __awaiter(this, void 0, void 0, function* () {
73
+ let showError;
76
74
  try {
77
75
  setIsFetching(CaseListDispatch, true);
78
76
  setHasError(false);
@@ -83,10 +81,12 @@ export function CaseList(props) {
83
81
  // recreate a new AbortController for each call
84
82
  let controller = new AbortController();
85
83
  abortControllerRef.current = controller;
86
- const res = yield getCaseList(currentFilterState, loggedInUserRights.data, loggedInUsersAccount.data, controller.signal, forceSfdcSearch(), alwaysUseSFDC);
87
- setFilterValuesFromFacetResponse(CaseListDispatch, solrResponseToFacetFields(res));
88
- setPivotValues(CaseListDispatch, solrResponseToPivotFields(res));
89
- setCaseList(CaseListDispatch, res.response);
84
+ const { caseListResponse, isSolrSearchDownSFDCUp, showErrorMessage } = yield getCaseList(currentFilterState, loggedInUserRights.data, loggedInUsersAccount.data, controller.signal);
85
+ showError = showErrorMessage;
86
+ setSolrSearchDown(isSolrSearchDownSFDCUp);
87
+ setFilterValuesFromFacetResponse(CaseListDispatch, solrResponseToFacetFields(caseListResponse));
88
+ setPivotValues(CaseListDispatch, solrResponseToPivotFields(caseListResponse));
89
+ setCaseList(CaseListDispatch, caseListResponse.response);
90
90
  setIsFetching(CaseListDispatch, false);
91
91
  }
92
92
  catch (err) {
@@ -94,7 +94,7 @@ export function CaseList(props) {
94
94
  if (!isAbortError) {
95
95
  setIsFetching(CaseListDispatch, false);
96
96
  setHasError(true);
97
- ToastNotification.addXHRErrorMessage(err);
97
+ showError && ToastNotification.addXHRErrorMessage(err);
98
98
  }
99
99
  }
100
100
  });
@@ -130,15 +130,16 @@ export function CaseList(props) {
130
130
  };
131
131
  const checkNewCases = () => __awaiter(this, void 0, void 0, function* () {
132
132
  try {
133
- const res = yield getCaseList(filterState, loggedInUserRights.data, loggedInUsersAccount.data, null, forceSfdcSearch(), alwaysUseSFDC);
133
+ const { caseListResponse, isSolrSearchDownSFDCUp } = yield getCaseList(filterState, loggedInUserRights.data, loggedInUsersAccount.data, null);
134
+ setSolrSearchDown(isSolrSearchDownSFDCUp);
134
135
  let changed = false;
135
- if (res.response.numFound <= filterState.paginationInfo.pageSize &&
136
- res.response.numFound !== caseList.numFound) {
136
+ if (caseListResponse.response.numFound <= filterState.paginationInfo.pageSize &&
137
+ caseListResponse.response.numFound !== caseList.numFound) {
137
138
  changed = true;
138
139
  }
139
140
  else {
140
141
  const caseIDModifiedDateObj = {};
141
- res.response.docs.forEach((res) => {
142
+ caseListResponse.response.docs.forEach((res) => {
142
143
  caseIDModifiedDateObj[res.case_number] = res.case_lastModifiedDate;
143
144
  });
144
145
  changed = some(caseList.docs, (doc) => {
@@ -150,8 +151,8 @@ export function CaseList(props) {
150
151
  }
151
152
  });
152
153
  }
153
- if (changed) {
154
- setCaseList(CaseListDispatch, res.response);
154
+ if (changed && location.pathname === '/case/list') {
155
+ setCaseList(CaseListDispatch, caseListResponse.response);
155
156
  pendoTrackEvent(UpdatedCaseDataEvent);
156
157
  ToastNotification.addSuccessMessage(t('Case data has been updated'));
157
158
  }
@@ -169,7 +170,27 @@ export function CaseList(props) {
169
170
  if (haventLoadedMetadata(allCaseTypes)) {
170
171
  fetchCaseTypes(dispatchToGlobalMetadataReducer, loggedInUsersAccount.data.secureSupport);
171
172
  }
172
- }, [allCaseTypes, dispatchToGlobalMetadataReducer, loggedInUsersAccount.data.secureSupport]);
173
+ // when solr is down, we use hydra metadata api to populated filter dropdowns
174
+ if (isSolrSearchDown) {
175
+ if (haventLoadedMetadata(allCaseSeverities)) {
176
+ fetchCaseSeverities(dispatchToGlobalMetadataReducer, loggedInUsersAccount.data.secureSupport);
177
+ }
178
+ if (haventLoadedMetadata(allCaseStatuses)) {
179
+ fetchAllStatuses(dispatchToGlobalMetadataReducer, loggedInUsersAccount.data.secureSupport);
180
+ }
181
+ if (haventLoadedProductsMetadata(allProducts)) {
182
+ fetchProducts(dispatchToGlobalMetadataReducer);
183
+ }
184
+ }
185
+ }, [
186
+ allCaseTypes,
187
+ allCaseSeverities,
188
+ allCaseStatuses,
189
+ allProducts,
190
+ dispatchToGlobalMetadataReducer,
191
+ loggedInUsersAccount.data.secureSupport,
192
+ isSolrSearchDown,
193
+ ]);
173
194
  // effect to update url query and call get case api whenever filter state changes
174
195
  useEffect(() => {
175
196
  var _a;
@@ -279,14 +300,14 @@ export function CaseList(props) {
279
300
  // eslint-disable-next-line react-hooks/exhaustive-deps
280
301
  }, [breakPoint]);
281
302
  return (React.createElement("article", { id: "rh-support-cases", className: "cases-main" },
303
+ isSolrSearchDown && (React.createElement("div", null,
304
+ React.createElement(Alert, { isInline: true, variant: AlertVariant.warning, title: React.createElement(Trans, null,
305
+ "Case search is working with limited functionality. Please check",
306
+ ' ',
307
+ React.createElement("a", { href: "https://status.redhat.com", target: "_blank", rel: "noreferrer" }, "status page"),
308
+ ' ',
309
+ "for details.") }))),
282
310
  React.createElement("section", { className: "case-search-top" },
283
- alwaysUseSFDC && (React.createElement("div", null,
284
- React.createElement(Alert, { className: "pf-u-mb-md", isInline: true, variant: AlertVariant.warning, title: React.createElement(Trans, null,
285
- "Case search is working with limited functionality. Please check",
286
- ' ',
287
- React.createElement("a", { href: "https://status.redhat.com", target: "_blank", rel: "noreferrer" }, "status page"),
288
- ' ',
289
- "for details.") }))),
290
311
  React.createElement("div", { className: "search-wrapper" },
291
312
  React.createElement("div", { className: "open-case" },
292
313
  React.createElement(NewCaseButton, { routeProps: props.routeProps })),
@@ -304,7 +325,7 @@ export function CaseList(props) {
304
325
  React.createElement("div", { className: "filter-wrapper" },
305
326
  React.createElement("pfe-collapse-panel", { id: "case-filters-panel", "pfe-animation": "false", ref: filterSectionRef },
306
327
  React.createElement(ErrorBoundary, { errorMsgInfo: { message: t('There was an error loading filters') } },
307
- React.createElement(CaseListFilters, { filterValues: filterValuesFromFacetResponse, allCaseTypes: allCaseTypes })))))),
328
+ React.createElement(CaseListFilters, { filterValues: filterValuesFromFacetResponse, allCaseTypes: allCaseTypes, allCaseStatuses: allCaseStatuses, allCaseSeverities: allCaseSeverities, allProducts: allProducts, isSolrSearchDown: isSolrSearchDown })))))),
308
329
  React.createElement("section", { className: "case-search-table" },
309
330
  React.createElement(CaseListTable, { caseList: caseList, caseGroups: caseGroups.data || [], loggedInUserRights: loggedInUserRights.data, sortInfo: filterState.sortInfo, paginationInfo: filterState.paginationInfo, isCaseListPageLoading: isFetching, hasError: hasError })))));
310
331
  }
@@ -1,9 +1,14 @@
1
- import { ISolrResponseToFacetFields } from '@rh-support/utils';
1
+ import { IApiResponseDetails } from '@rh-support/types/shared';
2
+ import { ISolrResponseToFacetFields, ITroubleshootProductResponse } from '@rh-support/utils';
2
3
  import { IFacetFields } from '../../../models/caseList';
3
4
  interface IProps {
4
5
  filterValues: ISolrResponseToFacetFields<IFacetFields>;
5
- allCaseTypes: any;
6
+ isSolrSearchDown: boolean;
7
+ allCaseTypes: IApiResponseDetails<string[]>;
8
+ allCaseStatuses: IApiResponseDetails<string[]>;
9
+ allCaseSeverities: IApiResponseDetails<string[]>;
10
+ allProducts: IApiResponseDetails<ITroubleshootProductResponse>;
6
11
  }
7
- export declare const CaseListFilters: ({ filterValues, allCaseTypes }: IProps) => JSX.Element;
12
+ export declare const CaseListFilters: ({ filterValues, allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts, isSolrSearchDown, }: IProps) => JSX.Element;
8
13
  export {};
9
14
  //# 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":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAK/D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAWxD,UAAU,MAAM;IACZ,YAAY,EAAE,0BAA0B,CAAC,YAAY,CAAC,CAAC;IACvD,YAAY,EAAE,GAAG,CAAC;CACrB;AAID,eAAO,MAAM,eAAe,mCAAoC,MAAM,gBAoErE,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;AAK7F,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,uGAOzB,MAAM,gBA0ER,CAAC"}
@@ -1,4 +1,3 @@
1
- import { GlobalMetadataStateContext } from '@rh-support/react-context';
2
1
  import { AbilityContext, CaseListFields, resourceActions, resources } from '@rh-support/user-permissions';
3
2
  import get from 'lodash/get';
4
3
  import React, { useContext } from 'react';
@@ -14,9 +13,9 @@ import { StatusFilter } from './StatusFilter';
14
13
  import { TypeFilter } from './TypeFilter';
15
14
  // Adding a new filter here? Make sure you add in caseSearchUtils also so that
16
15
  // it get included in the solr search query fq parameter
17
- export const CaseListFilters = ({ filterValues, allCaseTypes }) => {
16
+ export const CaseListFilters = ({ filterValues, allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts, isSolrSearchDown, }) => {
17
+ var _a;
18
18
  const ability = useContext(AbilityContext);
19
- const { globalMetadataState: { loggedInUsersAccount }, } = useContext(GlobalMetadataStateContext);
20
19
  const canReadBookmarkAccounts = ability.can(resourceActions.READ, resources.BOOKMARK_ACCOUNTS);
21
20
  const canManageBookmarkAccounts = ability.can(resourceActions.CREATE, resources.BOOKMARK_ACCOUNTS);
22
21
  const canAccessManagedAccounts = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.MANAGED_ACCOUNTS);
@@ -25,18 +24,17 @@ export const CaseListFilters = ({ filterValues, allCaseTypes }) => {
25
24
  const canAccessSeverityFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.SEVERITY_FILTER);
26
25
  const canAccessAdditionalFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.ADDITIONAL_FILTER);
27
26
  const canAccessGroupsFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.GROUPS_FILTER);
28
- const isSecureSupportAccount = loggedInUsersAccount.data.secureSupport;
29
27
  const canAccessCreatorFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.CREATOR_FILTER);
30
28
  const canAccessTypeFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.TYPE_FILTER);
31
29
  return (React.createElement(React.Fragment, null,
32
30
  React.createElement("div", { className: "filter-group" },
33
- canReadBookmarkAccounts && React.createElement(AccountsFilter, { canReadBookmarkAccounts: canReadBookmarkAccounts }),
31
+ !isSolrSearchDown && canReadBookmarkAccounts && (React.createElement(AccountsFilter, { canReadBookmarkAccounts: canReadBookmarkAccounts })),
34
32
  (canReadBookmarkAccounts || canAccessManagedAccounts) && (React.createElement(AccountsFilterWrapper, { canManageBookmarkAccounts: canManageBookmarkAccounts, canReadBookmarkAccounts: canReadBookmarkAccounts, canAccessManagedAccounts: canAccessManagedAccounts })),
35
33
  canAccessGroupsFilter && React.createElement(GroupsFilter, null),
36
- canAccessProductsFilter && (React.createElement(ProductsFilter, { filterValues: get(filterValues, SolrKeys.product, []), forceSingleSelect: isSecureSupportAccount })),
37
- canAccessSeverityFilter && (React.createElement(SeverityFilter, { filterValues: get(filterValues, SolrKeys.severity, []), forceSingleSelect: isSecureSupportAccount })),
38
- canAccessStatusFilter && React.createElement(StatusFilter, { filterValues: get(filterValues, SolrKeys.status, []) }),
34
+ canAccessProductsFilter && (React.createElement(ProductsFilter, { filterValues: get(filterValues, SolrKeys.product, []), isSolrSearchDown: isSolrSearchDown, allProducts: ((_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult.map((p) => p.product)) || [] })),
35
+ canAccessSeverityFilter && (React.createElement(SeverityFilter, { filterValues: get(filterValues, SolrKeys.severity, []), isSolrSearchDown: isSolrSearchDown, allCaseSeverities: allCaseSeverities.data })),
36
+ canAccessStatusFilter && (React.createElement(StatusFilter, { filterValues: get(filterValues, SolrKeys.status, []), allCaseStatuses: allCaseStatuses.data, isSolrSearchDown: isSolrSearchDown })),
39
37
  canAccessCreatorFilter && React.createElement(CreatorSsoNameFilter, null),
40
- canAccessTypeFilter && React.createElement(TypeFilter, { allCaseTypes: allCaseTypes.data }),
41
- canAccessAdditionalFilter && React.createElement(AdditionalFilters, null))));
38
+ !isSolrSearchDown && canAccessTypeFilter && React.createElement(TypeFilter, { allCaseTypes: allCaseTypes.data }),
39
+ !isSolrSearchDown && canAccessAdditionalFilter && React.createElement(AdditionalFilters, null))));
42
40
  };
@@ -1,7 +1,8 @@
1
1
  import { IFacetResponse } from '@rh-support/types/shared';
2
2
  interface IProps {
3
3
  filterValues: IFacetResponse[];
4
- forceSingleSelect?: boolean;
4
+ isSolrSearchDown: boolean;
5
+ allProducts: string[];
5
6
  }
6
7
  export declare function ProductsFilter(props: IProps): JSX.Element;
7
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ProductsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductsFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAe,MAAM,0BAA0B,CAAC;AAUvE,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,eAkE3C"}
1
+ {"version":3,"file":"ProductsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/ProductsFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAe,MAAM,0BAA0B,CAAC;AAUvE,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,eA+D3C"}
@@ -29,5 +29,12 @@ export function ProductsFilter(props) {
29
29
  const list = toOptions(props.filterValues, {
30
30
  labelKey: 'value',
31
31
  });
32
- return (React.createElement(React.Fragment, null, props.forceSingleSelect ? (React.createElement(Dropdown, { placeholder: getDropdownBtnPlaceholder(t('Select a product'), filterInfo[SolrPivotKeys.product_version].map((i) => i.value), ' '), "data-tracking-id": "severity-filter", id: "case-list-products-filter", title: t(filterNamesMap[SolrKeys.product]), label: t(filterNamesMap[SolrKeys.product]), onChange: onFilterChangeSingleSelect, selectedItem: toOption(filterInfo[SolrPivotKeys.product_version][0], { labelKey: 'value' }), list: list, searchable: true })) : (React.createElement(MultiSelectDropDownList, { placeholder: getDropdownBtnPlaceholder(t('Select a product'), filterInfo[SolrPivotKeys.product_version].map((i) => i.value), ' ', props.filterValues.length, t('All selected')), "data-tracking-id": "products-filter", id: "case-list-products-filter", title: t(filterNamesMap[SolrKeys.product]), label: t(filterNamesMap[SolrKeys.product]), onChange: onFilterChangeMultipleSelect, selectedItems: toOptions(filterInfo[SolrPivotKeys.product_version], { labelKey: 'value' }), list: list, searchable: true }))));
32
+ // solr is down and solr filter values are not available
33
+ // we get filter values from hydra metadata api
34
+ const singleSelectSolrIsDown = () => {
35
+ var _a;
36
+ return (React.createElement(Dropdown, { placeholder: t('Select a product'), "data-tracking-id": "products-filter", id: "case-list-products-filter", title: t(filterNamesMap[SolrKeys.product]), label: t(filterNamesMap[SolrKeys.product]), onChange: onFilterChangeSingleSelect, selectedItem: toOption((_a = filterInfo[SolrPivotKeys.product_version][0]) === null || _a === void 0 ? void 0 : _a.value), list: toOptions(props.allProducts) }));
37
+ };
38
+ const multiSelect = () => (React.createElement(MultiSelectDropDownList, { placeholder: getDropdownBtnPlaceholder(t('Select a product'), filterInfo[SolrPivotKeys.product_version].map((i) => i.value), ' ', props.filterValues.length, t('All selected')), "data-tracking-id": "products-filter", id: "case-list-products-filter", title: t(filterNamesMap[SolrKeys.product]), label: t(filterNamesMap[SolrKeys.product]), onChange: onFilterChangeMultipleSelect, selectedItems: toOptions(filterInfo[SolrPivotKeys.product_version], { labelKey: 'value' }), list: list, searchable: true }));
39
+ return React.createElement(React.Fragment, null, props.isSolrSearchDown ? singleSelectSolrIsDown() : multiSelect());
33
40
  }
@@ -1,7 +1,8 @@
1
1
  import { IFacetResponse } from '@rh-support/types/shared';
2
2
  interface IProps {
3
3
  filterValues: IFacetResponse[];
4
- forceSingleSelect?: boolean;
4
+ allCaseSeverities: string[];
5
+ isSolrSearchDown: boolean;
5
6
  }
6
7
  export declare function SeverityFilter(props: IProps): JSX.Element;
7
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"SeverityFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/SeverityFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAa,MAAM,0BAA0B,CAAC;AAUrE,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,eAqE3C"}
1
+ {"version":3,"file":"SeverityFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/SeverityFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAa,MAAM,0BAA0B,CAAC;AAUrE,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,eAiE3C"}
@@ -23,11 +23,12 @@ export function SeverityFilter(props) {
23
23
  })), {
24
24
  labelKey: 'value',
25
25
  });
26
- return (React.createElement(React.Fragment, null, props.forceSingleSelect ? (React.createElement(Dropdown, { placeholder: getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' '), "data-tracking-id": "severity-filter", id: "case-list-severity-filter", title: t(filterNamesMap[SolrKeys.severity]), label: t(filterNamesMap[SolrKeys.severity]), onChange: onFilterChangeSingleSelect, selectedItem: toOption({
27
- key: filterInfo[SolrKeys.severity][0],
28
- value: filterInfo[SolrKeys.severity][0],
29
- }, { labelKey: 'value' }), list: list })) : (React.createElement(MultiSelectDropDownList, { placeholder: getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', props.filterValues.length, t('All selected')), "data-tracking-id": "severity-filter", id: "case-list-severity-filter", title: t(filterNamesMap[SolrKeys.severity]), label: t(filterNamesMap[SolrKeys.severity]), onChange: onFilterChangeMultipleSelect, selectedItems: toOptions(filterInfo[SolrKeys.severity].map((filterValue) => ({
26
+ // solr is down and solr filter values are not available
27
+ // we get filter values from hydra metadata api
28
+ const singleSelectSolrIsDown = () => (React.createElement(Dropdown, { placeholder: t('Select a severity'), "data-tracking-id": "severity-filter", id: "case-list-severity-filter", title: t(filterNamesMap[SolrKeys.severity]), label: t(filterNamesMap[SolrKeys.severity]), onChange: onFilterChangeSingleSelect, selectedItem: toOption(filterInfo[SolrKeys.severity][0]), list: toOptions(props.allCaseSeverities) }));
29
+ const multiSelect = () => (React.createElement(MultiSelectDropDownList, { placeholder: getDropdownBtnPlaceholder(t('Select a severity'), filterInfo[SolrKeys.severity], ' ', props.filterValues.length, t('All selected')), "data-tracking-id": "severity-filter", id: "case-list-severity-filter", title: t(filterNamesMap[SolrKeys.severity]), label: t(filterNamesMap[SolrKeys.severity]), onChange: onFilterChangeMultipleSelect, selectedItems: toOptions(filterInfo[SolrKeys.severity].map((filterValue) => ({
30
30
  key: filterValue,
31
31
  value: filterValue,
32
- })), { labelKey: 'value' }), list: list }))));
32
+ })), { labelKey: 'value' }), list: list }));
33
+ return React.createElement(React.Fragment, null, props.isSolrSearchDown ? singleSelectSolrIsDown() : multiSelect());
33
34
  }
@@ -1,6 +1,8 @@
1
1
  import { IFacetResponse } from '@rh-support/types/shared';
2
2
  interface IProps {
3
3
  filterValues: IFacetResponse[];
4
+ isSolrSearchDown: boolean;
5
+ allCaseStatuses: string[];
4
6
  }
5
7
  export interface IStatusFilterOptions {
6
8
  key: string;
@@ -1 +1 @@
1
- {"version":3,"file":"StatusFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/StatusFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAa,MAAM,0BAA0B,CAAC;AAUrE,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,eAwEzC"}
1
+ {"version":3,"file":"StatusFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/StatusFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAa,MAAM,0BAA0B,CAAC;AAUrE,UAAU,MAAM;IACZ,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,eA+FzC"}
@@ -1,5 +1,5 @@
1
- import { MultiSelectDropDownList } from '@rh-support/components';
2
- import { toOptions } from '@rh-support/utils';
1
+ import { Dropdown, MultiSelectDropDownList } from '@rh-support/components';
2
+ import { toOption, toOptions } from '@rh-support/utils';
3
3
  import React, { useContext } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { SolrKeys } from '../../../enums/filters';
@@ -14,6 +14,9 @@ export function StatusFilter(props) {
14
14
  selectedStatus = selectedStatus.map((i) => i.label);
15
15
  updateFilter(dispatch, { filterKey: SolrKeys.status, values: selectedStatus });
16
16
  };
17
+ const onFilterChangeSingleSelect = (selectedStatus) => {
18
+ updateFilter(dispatch, { filterKey: SolrKeys.status, values: [selectedStatus.label] });
19
+ };
17
20
  const getBtnPlaceholder = (btnPlaceholder, selectedValues, type, totalLength, totalLengthString) => {
18
21
  if (!selectedValues || (selectedValues && selectedValues.length === 0)) {
19
22
  return btnPlaceholder;
@@ -38,13 +41,18 @@ export function StatusFilter(props) {
38
41
  }
39
42
  }
40
43
  };
41
- return (React.createElement(MultiSelectDropDownList, { placeholder: getBtnPlaceholder(t('Select a status'), filterInfo[SolrKeys.status], ' ', props.filterValues.length, t('All selected')), "data-tracking-id": "status-filter", id: "case-list-status-filter", title: t(filterNamesMap[SolrKeys.status]), label: t(filterNamesMap[SolrKeys.status]), onChange: onFilterChange, selectedItems: toOptions(filterInfo[SolrKeys.status].map((filterValue) => ({
44
+ const list = toOptions(props.filterValues.map((filterValue) => ({
45
+ key: filterValue.value,
46
+ value: filterValue.value,
47
+ })), {
48
+ labelKey: 'value',
49
+ });
50
+ // solr is down and solr filter values are not available
51
+ // we get filter values from hydra metadata api
52
+ const singleSelectSolrIsDown = () => (React.createElement(Dropdown, { placeholder: t('Select a status'), "data-tracking-id": "status-filter", id: "case-list-status-filter", title: t(filterNamesMap[SolrKeys.status]), label: t(filterNamesMap[SolrKeys.status]), onChange: onFilterChangeSingleSelect, selectedItem: toOption(filterInfo[SolrKeys.status][0]), list: toOptions(props.allCaseStatuses) }));
53
+ const multiSelect = () => (React.createElement(MultiSelectDropDownList, { placeholder: getBtnPlaceholder(t('Select a status'), filterInfo[SolrKeys.status], ' ', props.filterValues.length, t('All selected')), "data-tracking-id": "status-filter", id: "case-list-status-filter", title: t(filterNamesMap[SolrKeys.status]), label: t(filterNamesMap[SolrKeys.status]), onChange: onFilterChange, selectedItems: toOptions(filterInfo[SolrKeys.status].map((filterValue) => ({
42
54
  key: filterValue,
43
55
  value: filterValue,
44
- })), { labelKey: 'value' }), list: toOptions(props.filterValues.map((filterValue) => ({
45
- key: filterValue.value,
46
- value: filterValue.value,
47
- })), {
48
- labelKey: 'value',
49
- }) }));
56
+ })), { labelKey: 'value' }), list: list }));
57
+ return React.createElement(React.Fragment, null, props.isSolrSearchDown ? singleSelectSolrIsDown() : multiSelect());
50
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TypeFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/TypeFilter.tsx"],"names":[],"mappings":"AAUA,UAAU,MAAM;IACZ,YAAY,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eA6BvC"}
1
+ {"version":3,"file":"TypeFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/TypeFilter.tsx"],"names":[],"mappings":"AAWA,UAAU,MAAM;IACZ,YAAY,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eA6CvC"}
@@ -1,7 +1,8 @@
1
1
  import { MultiSelectDropDownList } from '@rh-support/components';
2
+ import { FeatureAnnouncementKeys, NewFeatureLabel } from '@rh-support/react-context';
2
3
  import { getDropdownBtnPlaceholder, toOptions } from '@rh-support/utils';
3
4
  import React, { useContext } from 'react';
4
- import { useTranslation } from 'react-i18next';
5
+ import { Trans, useTranslation } from 'react-i18next';
5
6
  import { SolrKeys } from '../../../enums/filters';
6
7
  import { filterNamesMap } from '../../../utils/constants';
7
8
  import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
@@ -14,5 +15,8 @@ export function TypeFilter(props) {
14
15
  filterKey: SolrKeys.type,
15
16
  values: selectedTypes.map((selectedType) => selectedType.label),
16
17
  });
17
- return (React.createElement(MultiSelectDropDownList, { placeholder: getDropdownBtnPlaceholder(t('Select a type'), filterInfo[SolrKeys.type], ' ', props.allCaseTypes.length, t('All selected')), "data-tracking-id": "type-filter", id: "case-list-type-filter", title: t(filterNamesMap[SolrKeys.type]), label: t(filterNamesMap[SolrKeys.type]), onChange: onFilterChangeMultipleSelect, selectedItems: toOptions(filterInfo[SolrKeys.type]), list: toOptions(props.allCaseTypes) }));
18
+ return (React.createElement(MultiSelectDropDownList, { placeholder: getDropdownBtnPlaceholder(t('Select a case type'), filterInfo[SolrKeys.type], ' ', props.allCaseTypes.length, t('All selected')), "data-tracking-id": "type-filter", id: "case-list-type-filter", title: t(filterNamesMap[SolrKeys.type]), label: React.createElement("h3", { className: "pull-bottom-narrow" },
19
+ t(filterNamesMap[SolrKeys.type]),
20
+ React.createElement(NewFeatureLabel, { "aria-label": "send notification new feature announcement", hasAutoWidth: true, featureName: FeatureAnnouncementKeys.CASE_TYPE_FILTER, headerContent: React.createElement(Trans, null, "New filter available"), position: 'right', bodyContent: React.createElement("div", null,
21
+ React.createElement(Trans, null, "You can now filter by case type.")) })), onChange: onFilterChangeMultipleSelect, selectedItems: toOptions(filterInfo[SolrKeys.type]), list: toOptions(props.allCaseTypes) }));
18
22
  }
@@ -155,7 +155,7 @@ export function CaseListTable(props) {
155
155
  {
156
156
  id: CaseListColumnIds.type,
157
157
  cellWidth: 10,
158
- title: t('Type'),
158
+ title: t('Case type'),
159
159
  sortable: true,
160
160
  accessor: (data) => data.case_type,
161
161
  show: isColumnVisible(CaseListColumnIds.type),
@@ -52,7 +52,7 @@ const csvHeadersSFDC = [
52
52
  { label: 'Modified date', key: SFDCKeys.lastPublicUpdateDate, transform: formatDateTime },
53
53
  { label: 'Uri', key: SFDCKeys.uri },
54
54
  { label: 'Alternate case ID', key: SFDCKeys.alternateId },
55
- { label: 'Type', key: SFDCKeys.caseType },
55
+ { label: 'Case type', key: SFDCKeys.caseType },
56
56
  ];
57
57
  const groupHeaderSOLR = { label: 'Group', key: SolrKeys.groupName };
58
58
  const groupHeaderSFDC = { label: 'Group', key: SFDCKeys.groupName };
@@ -60,6 +60,7 @@ export declare const mockCaseList: {
60
60
  case_last_public_update_date: string;
61
61
  case_last_public_update_by: string;
62
62
  case_customer_escalation: boolean;
63
+ case_type: string;
63
64
  uri: string;
64
65
  case_owner: string;
65
66
  }[];
@@ -1 +1 @@
1
- {"version":3,"file":"mockData.d.ts","sourceRoot":"","sources":["../../../src/test-utils/mockData.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;GAI1B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;GAgBlC,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;GA4BvC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;GAgBnC,CAAC;AAEF,eAAO,MAAM,4BAA4B;;;;;;;;;;CAExC,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;CAyBxB,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;GAS/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,GAG9B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgC5B,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;GA6GpB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;GA8B9B,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;CA+d7C,CAAC"}
1
+ {"version":3,"file":"mockData.d.ts","sourceRoot":"","sources":["../../../src/test-utils/mockData.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;GAI1B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;GAgBlC,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;GA4BvC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;GAgBnC,CAAC;AAEF,eAAO,MAAM,4BAA4B;;;;;;;;;;CAExC,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;CA0BxB,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;GAS/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,GAG9B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgC5B,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;GA6GpB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;GA4B9B,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;CA+d7C,CAAC"}
@@ -90,6 +90,7 @@ export const mockCaseList = {
90
90
  case_last_public_update_date: '2019-10-25T05:30:54Z',
91
91
  case_last_public_update_by: 'Bipin Kunal',
92
92
  case_customer_escalation: false,
93
+ case_type: '',
93
94
  uri: 'https://api.access.qa.redhat.com/rs/cases/02428475',
94
95
  case_owner: 'New Case Queue',
95
96
  },
@@ -8,6 +8,12 @@ export interface IPromiseReflection<T> {
8
8
  status: 'fulfilled' | 'rejected';
9
9
  e?: Error;
10
10
  }
11
- export declare function getCaseList(filterState: ICaseListFilterState, loggedInUser: UserAuth, loggedInUserAccount: Partial<IAccount>, abortSignal: AbortSignal, forceSfdcSearch?: boolean, alwaysUseSFDC?: boolean): Promise<ISolrCaseSearchResponse>;
11
+ interface ICaseListResponse {
12
+ caseListResponse: ISolrCaseSearchResponse;
13
+ isSolrSearchDownSFDCUp: boolean;
14
+ showErrorMessage: boolean;
15
+ }
16
+ export declare function getCaseList(filterState: ICaseListFilterState, loggedInUser: UserAuth, loggedInUserAccount: Partial<IAccount>, abortSignal: AbortSignal, forceSfdcSearch?: boolean): Promise<ICaseListResponse>;
12
17
  export declare function getCaseListFromSolr(solrQuery: ISearchSolrQuery, partnerSearch: boolean, abortSignal: AbortSignal, isSecureSupport?: boolean): Promise<ISolrCaseSearchResponse>;
18
+ export {};
13
19
  //# sourceMappingURL=caseListUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"caseListUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseListUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAIxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AACrF,OAAO,EAAuC,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAQlG,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACjC,CAAC,CAAC,EAAE,CAAC,CAAC;IACN,MAAM,EAAE,WAAW,GAAG,UAAU,CAAC;IACjC,CAAC,CAAC,EAAE,KAAK,CAAC;CACb;AAoBD,wBAAsB,WAAW,CAC7B,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,QAAQ,EACtB,mBAAmB,EAAE,OAAO,CAAC,QAAQ,CAAC,EACtC,WAAW,EAAE,WAAW,EACxB,eAAe,CAAC,EAAE,OAAO,EACzB,aAAa,UAAQ,GACtB,OAAO,CAAC,uBAAuB,CAAC,CA4ClC;AAED,wBAAgB,mBAAmB,CAC/B,SAAS,EAAE,gBAAgB,EAC3B,aAAa,EAAE,OAAO,EACtB,WAAW,EAAE,WAAW,EACxB,eAAe,GAAE,OAAe,GACjC,OAAO,CAAC,uBAAuB,CAAC,CASlC"}
1
+ {"version":3,"file":"caseListUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseListUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAIxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AACrF,OAAO,EAAuC,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAOlG,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACjC,CAAC,CAAC,EAAE,CAAC,CAAC;IACN,MAAM,EAAE,WAAW,GAAG,UAAU,CAAC;IACjC,CAAC,CAAC,EAAE,KAAK,CAAC;CACb;AAED,UAAU,iBAAiB;IACvB,gBAAgB,EAAE,uBAAuB,CAAC;IAC1C,sBAAsB,EAAE,OAAO,CAAC;IAChC,gBAAgB,EAAE,OAAO,CAAC;CAC7B;AAiBD,wBAAsB,WAAW,CAC7B,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,QAAQ,EACtB,mBAAmB,EAAE,OAAO,CAAC,QAAQ,CAAC,EACtC,WAAW,EAAE,WAAW,EACxB,eAAe,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAmF5B;AAED,wBAAgB,mBAAmB,CAC/B,SAAS,EAAE,gBAAgB,EAC3B,aAAa,EAAE,OAAO,EACtB,WAAW,EAAE,WAAW,EACxB,eAAe,GAAE,OAAe,GACjC,OAAO,CAAC,uBAAuB,CAAC,CASlC"}
@@ -19,19 +19,14 @@ var __rest = (this && this.__rest) || function (s, e) {
19
19
  return t;
20
20
  };
21
21
  import { publicApi, search } from '@cee-eng/hydrajs';
22
- import isEmpty from 'lodash/isEmpty';
22
+ import { promiseReflection } from '@rh-support/utils';
23
23
  import { isNoFilterApplied, isSearchSupportedBySFDC } from '../components/case-list/CaseListFilterHelpers';
24
24
  import { createSFDCQueryFromFilterState, createSolrQueryFromFilterState, mapSFDCCaseListToSolrCaseList, } from './caseSearchUtils';
25
- import { mockSolrResponse } from './mockSolrResponse';
26
- const reflect = (p) => __awaiter(void 0, void 0, void 0, function* () {
27
- try {
28
- const v = yield p;
29
- return { v, status: 'fulfilled' };
30
- }
31
- catch (e) {
32
- return { e, status: 'rejected' };
33
- }
34
- });
25
+ const throwErrorOnAbort = (message) => {
26
+ const isAbortError = message && message.toLowerCase().indexOf('abort') > -1;
27
+ if (isAbortError)
28
+ throw new Error(message);
29
+ };
35
30
  // currently while fetching case list we need to decide whether to call only solr or solr and sfdc both
36
31
  // solr call will always be there because all the filters values are returned by the solr as facets.
37
32
  // the problem with solr is that it takes 10 secs to index the latest data from SFDC and user might see some stale data in the meanwhile.
@@ -41,40 +36,71 @@ const reflect = (p) => __awaiter(void 0, void 0, void 0, function* () {
41
36
  // and override the solr result with sfdc.
42
37
  // Even though SFDC support most of the filters but another problem with SFDC is it doesnot support multiple values for a praticular filter.
43
38
  // if user applies any filter apart from default filter we will always call solr and assume that(not safely) 10 sec scenario is not bound to happen.
44
- export function getCaseList(filterState, loggedInUser, loggedInUserAccount, abortSignal, forceSfdcSearch, alwaysUseSFDC = false) {
45
- var _a, _b, _c, _d;
39
+ export function getCaseList(filterState, loggedInUser, loggedInUserAccount, abortSignal, forceSfdcSearch) {
40
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
46
41
  return __awaiter(this, void 0, void 0, function* () {
42
+ let isSolrSearchDownSFDCUp = false;
43
+ let showErrorMessage = false;
44
+ let caseListResponse;
47
45
  const solrFilter = createSolrQueryFromFilterState(filterState, loggedInUser);
48
- const isSfdcSearchRequired = ((forceSfdcSearch || isSearchSupportedBySFDC(filterState)) && !filterState.filterQueryInfo.queryString) ||
49
- loggedInUserAccount.secureSupport;
50
46
  const partnerSearch = loggedInUser.hasManagedAccounts() && ((_b = (_a = filterState.filterInfo) === null || _a === void 0 ? void 0 : _a.case_accountNumber) !== null && _b !== void 0 ? _b : []).length > 0;
51
- let solrPromise = Promise.resolve(undefined);
52
- if (!alwaysUseSFDC) {
53
- solrPromise = getCaseListFromSolr(solrFilter, partnerSearch, abortSignal, loggedInUserAccount === null || loggedInUserAccount === void 0 ? void 0 : loggedInUserAccount.secureSupport);
47
+ const isSfdcSearchRequired = (forceSfdcSearch || isSearchSupportedBySFDC(filterState)) && !filterState.filterQueryInfo.queryString;
48
+ let solrPromise = getCaseListFromSolr(solrFilter, partnerSearch, abortSignal, loggedInUserAccount === null || loggedInUserAccount === void 0 ? void 0 : loggedInUserAccount.secureSupport);
49
+ const sfdcAPICall = () => publicApi.caseList.getCaseListFromSFDC(createSFDCQueryFromFilterState(filterState, loggedInUser, loggedInUserAccount, isNoFilterApplied(filterState)), partnerSearch, loggedInUserAccount === null || loggedInUserAccount === void 0 ? void 0 : loggedInUserAccount.secureSupport, abortSignal);
50
+ const sfdcPromise = isSfdcSearchRequired ? sfdcAPICall() : Promise.resolve(undefined);
51
+ const [solrResponse, sfdcResponse] = yield Promise.all([solrPromise, sfdcPromise].filter((item) => !!item).map(promiseReflection));
52
+ // on abort we throw an error and don't proceed with the rest
53
+ if (solrResponse.e)
54
+ throwErrorOnAbort(solrResponse === null || solrResponse === void 0 ? void 0 : solrResponse.e.message);
55
+ if (sfdcResponse.e)
56
+ throwErrorOnAbort(sfdcResponse === null || sfdcResponse === void 0 ? void 0 : sfdcResponse.e.message);
57
+ const solrFullfilled = !!(solrResponse.status === 'fulfilled' && ((_c = solrResponse.v) === null || _c === void 0 ? void 0 : _c.response));
58
+ let sfdcFullfilled = !!(sfdcResponse.status === 'fulfilled' && ((_d = sfdcResponse.v) === null || _d === void 0 ? void 0 : _d.cases));
59
+ const sfdcCallIsMadeAndFailed = !sfdcFullfilled && isSfdcSearchRequired;
60
+ const sfdcCallNotMade = !sfdcFullfilled && !isSfdcSearchRequired;
61
+ if (!solrFullfilled && sfdcCallIsMadeAndFailed) {
62
+ showErrorMessage = true;
54
63
  }
55
- let sfdcPromise;
56
- const needToUseSFDC = isSfdcSearchRequired || alwaysUseSFDC;
57
- if (needToUseSFDC) {
58
- const sfdcFilter = createSFDCQueryFromFilterState(filterState, loggedInUser, loggedInUserAccount, isNoFilterApplied(filterState));
59
- sfdcPromise = publicApi.caseList.getCaseListFromSFDC(sfdcFilter, partnerSearch, loggedInUserAccount === null || loggedInUserAccount === void 0 ? void 0 : loggedInUserAccount.secureSupport, abortSignal);
64
+ else if (!solrFullfilled && sfdcCallNotMade) {
65
+ const sfdcRes = yield promiseReflection(sfdcAPICall());
66
+ sfdcFullfilled = !!(sfdcRes.status === 'fulfilled' && ((_e = sfdcRes.v) === null || _e === void 0 ? void 0 : _e.cases));
67
+ if (sfdcFullfilled) {
68
+ isSolrSearchDownSFDCUp = true;
69
+ const mappedSfdcRes = mapSFDCCaseListToSolrCaseList((_g = (_f = sfdcRes === null || sfdcRes === void 0 ? void 0 : sfdcRes.v) === null || _f === void 0 ? void 0 : _f.cases) !== null && _g !== void 0 ? _g : []);
70
+ caseListResponse = {
71
+ response: {
72
+ docs: mappedSfdcRes,
73
+ numFound: sfdcRes.v.totalCount,
74
+ },
75
+ };
76
+ }
77
+ else {
78
+ showErrorMessage = true;
79
+ }
60
80
  }
61
- const res = yield Promise.all([solrPromise, sfdcPromise].filter((item) => !!item).map(reflect));
62
- let solrResponse = res[0];
63
- if (isEmpty(solrResponse === null || solrResponse === void 0 ? void 0 : solrResponse.v) && alwaysUseSFDC) {
64
- solrResponse.v = mockSolrResponse;
81
+ else if (solrFullfilled && sfdcFullfilled) {
82
+ caseListResponse = Object.assign(Object.assign({}, solrResponse.v), { response: {
83
+ docs: mapSFDCCaseListToSolrCaseList((_j = (_h = sfdcResponse === null || sfdcResponse === void 0 ? void 0 : sfdcResponse.v) === null || _h === void 0 ? void 0 : _h.cases) !== null && _j !== void 0 ? _j : []),
84
+ numFound: sfdcResponse.v.totalCount,
85
+ } });
65
86
  }
66
- const sfdcResponse = res[1];
67
- if ((solrResponse === null || solrResponse === void 0 ? void 0 : solrResponse.status) === 'rejected') {
68
- throw new Error(solrResponse === null || solrResponse === void 0 ? void 0 : solrResponse.e.message);
87
+ else if (!solrFullfilled && sfdcFullfilled) {
88
+ isSolrSearchDownSFDCUp = true;
89
+ caseListResponse = {
90
+ response: {
91
+ docs: mapSFDCCaseListToSolrCaseList((_l = (_k = sfdcResponse === null || sfdcResponse === void 0 ? void 0 : sfdcResponse.v) === null || _k === void 0 ? void 0 : _k.cases) !== null && _l !== void 0 ? _l : []),
92
+ numFound: sfdcResponse.v.totalCount,
93
+ },
94
+ };
69
95
  }
70
- if (needToUseSFDC && sfdcResponse) {
71
- if (sfdcResponse.status === 'fulfilled') {
72
- const mappedSfdcRes = sfdcResponse && mapSFDCCaseListToSolrCaseList((_d = (_c = sfdcResponse === null || sfdcResponse === void 0 ? void 0 : sfdcResponse.v) === null || _c === void 0 ? void 0 : _c.cases) !== null && _d !== void 0 ? _d : []);
73
- solrResponse.v.response.docs = mappedSfdcRes;
74
- solrResponse.v.response.numFound = sfdcResponse.v.totalCount;
75
- }
96
+ else if (solrFullfilled && !sfdcFullfilled) {
97
+ caseListResponse = solrResponse.v;
76
98
  }
77
- return solrResponse.v;
99
+ return {
100
+ caseListResponse,
101
+ isSolrSearchDownSFDCUp,
102
+ showErrorMessage,
103
+ };
78
104
  });
79
105
  }
80
106
  export function getCaseListFromSolr(solrQuery, partnerSearch, abortSignal, isSecureSupport = false) {
@@ -17,7 +17,7 @@ export const filterNamesMap = {
17
17
  [SolrKeys.caseNumber]: 'Case number',
18
18
  [SolrKeys.createdBySsoUsername]: 'Created by me',
19
19
  [SolrKeys.caseContactSSO]: 'Owned by me',
20
- [SolrKeys.type]: 'Type',
20
+ [SolrKeys.type]: 'Case type',
21
21
  usernameFilterTitle: 'Username',
22
22
  };
23
23
  export const UpdatedCaseDataEvent = 'PCM-Next > case-list-data-background-refresh';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/cases",
3
- "version": "0.2.27",
3
+ "version": "0.2.31",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -53,11 +53,11 @@
53
53
  "@patternfly/react-core": "4.128.2",
54
54
  "@patternfly/react-table": "4.26.7",
55
55
  "@rh-support/api": "0.3.9",
56
- "@rh-support/components": "1.1.20",
57
- "@rh-support/react-context": "0.2.22",
56
+ "@rh-support/components": "1.1.23",
57
+ "@rh-support/react-context": "0.2.26",
58
58
  "@rh-support/types": "0.2.0",
59
- "@rh-support/user-permissions": "0.2.15",
60
- "@rh-support/utils": "0.2.13",
59
+ "@rh-support/user-permissions": "0.2.17",
60
+ "@rh-support/utils": "0.2.15",
61
61
  "i18next": "^19.0.1",
62
62
  "localforage": "^1.7.3",
63
63
  "lodash": "^4.17.15",
@@ -101,5 +101,5 @@
101
101
  "not ie <= 11",
102
102
  "not op_mini all"
103
103
  ],
104
- "gitHead": "cdaf99c40c84eb9dbf63b52cc8c227e1e3d131a4"
104
+ "gitHead": "9716b639be720a135816d69baebd35a3ea9ae0e1"
105
105
  }