@rh-support/cases 2.1.62 → 2.1.63

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AdditionalFilters.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/AdditionalFilters.tsx"],"names":[],"mappings":"AACA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,wBAAgB,iBAAiB,sBAwChC"}
1
+ {"version":3,"file":"AdditionalFilters.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/AdditionalFilters.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,wBAAgB,iBAAiB,sBAqDhC"}
@@ -1,4 +1,6 @@
1
1
  import { Checkbox } from '@patternfly/react-core';
2
+ import isEmpty from 'lodash/isEmpty';
3
+ import isEqual from 'lodash/isEqual';
2
4
  import React, { useContext, useEffect, useState } from 'react';
3
5
  import { Trans, useTranslation } from 'react-i18next';
4
6
  import { AdditionalFilterLabels, SolrKeys } from '../../../enums/filters';
@@ -17,8 +19,21 @@ export function AdditionalFilters() {
17
19
  setIsEscalated(checked);
18
20
  };
19
21
  useEffect(() => {
20
- (case_customer_escalation || []).length < 1 && escalated && setIsEscalated(false);
21
- (case_customer_escalation || []).length > 0 && !escalated && setIsEscalated(true);
22
+ var _a, _b;
23
+ updateFilter(dispatch, {
24
+ filterKey: SolrKeys.escalation,
25
+ values: !isEmpty(case_customer_escalation) && isEqual((_a = case_customer_escalation[0]) === null || _a === void 0 ? void 0 : _a.key, 'true')
26
+ ? [{ key: (_b = case_customer_escalation[0]) === null || _b === void 0 ? void 0 : _b.key, value: AdditionalFilterLabels[SolrKeys.escalation] }]
27
+ : [],
28
+ });
29
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30
+ }, []);
31
+ useEffect(() => {
32
+ var _a;
33
+ isEmpty(case_customer_escalation) && escalated && setIsEscalated(false);
34
+ if (!isEmpty(case_customer_escalation)) {
35
+ isEqual((_a = case_customer_escalation[0]) === null || _a === void 0 ? void 0 : _a.key, 'true') ? setIsEscalated(true) : setIsEscalated(false);
36
+ }
22
37
  // eslint-disable-next-line react-hooks/exhaustive-deps
23
38
  }, [case_customer_escalation]);
24
39
  return (React.createElement(React.Fragment, null,
@@ -1 +1 @@
1
- {"version":3,"file":"CaseListTable.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-table/CaseListTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAwB3E,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAOxD,OAAO,KAAkD,MAAM,OAAO,CAAC;AAKvE,OAAO,EAAE,iBAAiB,EAAyB,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EAEH,eAAe,EACf,SAAS,EAIZ,MAAM,0BAA0B,CAAC;AA4BlC,UAAU,MAAM;IACZ,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,kBAAkB,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAsBD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,qBA0jB1C"}
1
+ {"version":3,"file":"CaseListTable.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-table/CaseListTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAuB3E,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAQxD,OAAO,KAAkD,MAAM,OAAO,CAAC;AAKvE,OAAO,EAAE,iBAAiB,EAAyB,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EAEH,eAAe,EACf,SAAS,EAIZ,MAAM,0BAA0B,CAAC;AA4BlC,UAAU,MAAM;IACZ,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,kBAAkB,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAsBD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,qBAmjB1C"}
@@ -2,11 +2,12 @@ import { Bullseye, Button, EmptyState, EmptyStateBody, EmptyStateFooter, EmptySt
2
2
  import SearchIcon from '@patternfly/react-icons/dist/js/icons/search-icon';
3
3
  import { Table, TableVariant, Tbody, Td, Th, Thead, Tr, Visibility } from '@patternfly/react-table';
4
4
  import { TableColumnSelector, TableComponent, TablePagination } from '@rh-support/components';
5
- import { GlobalMetadataDispatchContext, GlobalMetadataStateContext, updateUserPreferences, useGlobalStateContext, UserPreferencesKeys, } from '@rh-support/react-context';
5
+ import { GlobalMetadataDispatchContext, updateUserPreferences, useGlobalStateContext, UserPreferencesKeys, } from '@rh-support/react-context';
6
6
  import { formatDate, scrollIntoView, toNewCaseTypeSwitcher } from '@rh-support/utils';
7
7
  import find from 'lodash/find';
8
8
  import flatMap from 'lodash/flatMap';
9
9
  import includes from 'lodash/includes';
10
+ import isEmpty from 'lodash/isEmpty';
10
11
  import isEqual from 'lodash/isEqual';
11
12
  import isUndefined from 'lodash/isUndefined';
12
13
  import React, { useContext, useEffect, useRef, useState } from 'react';
@@ -48,16 +49,13 @@ export function CaseListTable(props) {
48
49
  const [activeSortIndex, setActiveSortIndex] = useState();
49
50
  const [activeSortDirection, setActiveSortDirection] = useState();
50
51
  const [sortedCaseListData, setSortedCaseListData] = useState(caseListData);
51
- const { globalMetadataState: { navBarRef, hydraUserPreferences }, } = useGlobalStateContext();
52
+ const { globalMetadataState: { navBarRef, hydraUserPreferences, loggedInUserRights }, } = useGlobalStateContext();
52
53
  const dispatch = useContext(CaseListFilterDispatchContext);
53
54
  const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
54
- const { filterInfo } = useContext(CaseListFilterStateContext);
55
+ const { filterInfo, filterQueryInfo } = useContext(CaseListFilterStateContext);
55
56
  const currentFilterLength = flatMap(filterInfo).length;
56
57
  const showingFilter = currentFilterLength > 0;
57
- const filterState = useContext(CaseListFilterStateContext);
58
- const { filterQueryInfo } = filterState;
59
58
  const hasSearchQuery = !((filterQueryInfo === null || filterQueryInfo === void 0 ? void 0 : filterQueryInfo.queryString) === '');
60
- const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
61
59
  const isInternal = loggedInUserRights.data.isInternal();
62
60
  const tableToolbarRef = useRef(null);
63
61
  const columns = [
@@ -278,7 +276,7 @@ export function CaseListTable(props) {
278
276
  return (group === null || group === void 0 ? void 0 : group.name) || '';
279
277
  };
280
278
  const localRows = [
281
- ...caseListData.map((row, index) => ({
279
+ ...caseListData === null || caseListData === void 0 ? void 0 : caseListData.map((row, index) => ({
282
280
  case_number: row.case_number,
283
281
  case_summary: row.case_summary,
284
282
  case_createdByName: row.case_createdByName,
@@ -302,7 +300,7 @@ export function CaseListTable(props) {
302
300
  useEffect(() => {
303
301
  var _a;
304
302
  setSelectedCases([]);
305
- setSortedCaseListData((_a = props.caseList) === null || _a === void 0 ? void 0 : _a.docs);
303
+ !isEmpty(localRows) ? setSortedCaseListData(localRows) : setSortedCaseListData((_a = props.caseList) === null || _a === void 0 ? void 0 : _a.docs);
306
304
  // eslint-disable-next-line react-hooks/exhaustive-deps
307
305
  }, [props.caseList]);
308
306
  useEffect(() => {
@@ -316,7 +314,7 @@ export function CaseListTable(props) {
316
314
  direction: activeSortDirection,
317
315
  column: visibleCaseListColumns[activeSortIndex].id,
318
316
  });
319
- sortedRows = localRows.sort((a, b) => {
317
+ sortedRows = localRows === null || localRows === void 0 ? void 0 : localRows.sort((a, b) => {
320
318
  const aValue = getSortableRowValues(a)[activeSortIndex];
321
319
  const bValue = getSortableRowValues(b)[activeSortIndex];
322
320
  if (typeof aValue === 'number') {
@@ -393,6 +391,6 @@ export function CaseListTable(props) {
393
391
  React.createElement(Td, { className: !isColumnVisible('type') ? Visibility.hidden : '', "data-label": "Support type" }, row.case_type),
394
392
  React.createElement(Td, { className: !isColumnVisible('closedDate') ? Visibility.hidden : '', "data-label": "Closed date" }, row.case_closedDate ? formatDate(row.case_closedDate) : ''),
395
393
  React.createElement(Td, { className: !isColumnVisible('folderName') ? Visibility.hidden : '', "data-label": "Group" }, row.case_folderName ? row.case_folderName : ''))))))),
396
- caseListData.length > 9 && (React.createElement("footer", { className: "toolbar-pagination", "data-tracking-id": "case-list-table-pagination" },
397
- React.createElement(TablePagination, { perPage: (_e = props === null || props === void 0 ? void 0 : props.paginationInfo) === null || _e === void 0 ? void 0 : _e.pageSize, currentPage: (_f = props === null || props === void 0 ? void 0 : props.paginationInfo) === null || _f === void 0 ? void 0 : _f.currentPage, onPerPageSelect: onPerPageSelect, onSetPage: onBottomPaginationSetPage, variant: PaginationVariant.bottom, itemCount: getItemCount() }))))));
394
+ React.createElement("footer", { className: "toolbar-pagination", "data-tracking-id": "case-list-table-pagination" },
395
+ React.createElement(TablePagination, { perPage: (_e = props === null || props === void 0 ? void 0 : props.paginationInfo) === null || _e === void 0 ? void 0 : _e.pageSize, currentPage: (_f = props === null || props === void 0 ? void 0 : props.paginationInfo) === null || _f === void 0 ? void 0 : _f.currentPage, onPerPageSelect: onPerPageSelect, onSetPage: onBottomPaginationSetPage, variant: PaginationVariant.bottom, itemCount: getItemCount() })))));
398
396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/cases",
3
- "version": "2.1.62",
3
+ "version": "2.1.63",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -43,11 +43,11 @@
43
43
  "@patternfly/patternfly": "5.1.0",
44
44
  "@patternfly/react-core": "5.1.1",
45
45
  "@patternfly/react-table": "5.1.1",
46
- "@rh-support/components": "2.1.47",
47
- "@rh-support/react-context": "2.1.53",
46
+ "@rh-support/components": "2.1.48",
47
+ "@rh-support/react-context": "2.1.54",
48
48
  "@rh-support/types": "2.0.3",
49
- "@rh-support/user-permissions": "2.1.34",
50
- "@rh-support/utils": "2.1.24",
49
+ "@rh-support/user-permissions": "2.1.35",
50
+ "@rh-support/utils": "2.1.25",
51
51
  "localforage": "^1.10.0",
52
52
  "lodash": "^4.17.21",
53
53
  "pegjs": "^0.10.0",
@@ -96,5 +96,5 @@
96
96
  "defaults and supports es6-module",
97
97
  "maintained node versions"
98
98
  ],
99
- "gitHead": "e7d64b82aee41aebd5b984495eb33be7e3b878a3"
99
+ "gitHead": "e26b6df63ea1cab3872f1679464f4caf5e5a1056"
100
100
  }