@rh-support/cases 2.6.4 → 2.6.6
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.
- package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-table/CaseListTable.js +4 -6
- package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.d.ts +8 -0
- package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.js +77 -0
- package/lib/esm/css/caseList.css +20 -0
- package/lib/esm/hooks/useCloseCase.d.ts +22 -0
- package/lib/esm/hooks/useCloseCase.d.ts.map +1 -0
- package/lib/esm/hooks/useCloseCase.js +111 -0
- package/lib/esm/hooks/useExportCaseListCSV.d.ts +16 -0
- package/lib/esm/hooks/useExportCaseListCSV.d.ts.map +1 -0
- package/lib/esm/hooks/useExportCaseListCSV.js +39 -0
- package/package.json +6 -6
|
@@ -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;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;
|
|
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,qBA+jB1C"}
|
|
@@ -16,10 +16,9 @@ import { Link } from 'react-router-dom';
|
|
|
16
16
|
import { CaseListColumnIds } from '../../../enums/case';
|
|
17
17
|
import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../CaseListFilterContext';
|
|
18
18
|
import { clearFilters, resetFilterToDefaultState, updatePagination, updateSort, } from '../CaseListFilterReducer';
|
|
19
|
-
import CloseCaseBtn from './CloseCaseBtn';
|
|
20
|
-
import { ExportCaseListCSV } from './ExportCaseListCSV';
|
|
21
19
|
import SeverityLabel from './SeverityLabel';
|
|
22
20
|
import { TableColumnSelector } from './table-column-selector/TableColumnSelector';
|
|
21
|
+
import { TableActionsDropdown } from './TableActionsDropdown';
|
|
23
22
|
// initially selected columns
|
|
24
23
|
const initialSelectedColumns = [
|
|
25
24
|
CaseListColumnIds.caseId,
|
|
@@ -346,10 +345,9 @@ export function CaseListTable(props) {
|
|
|
346
345
|
return (React.createElement(React.Fragment, null,
|
|
347
346
|
React.createElement(TableComponent, { columns: columns, data: caseListData, selectedColumns: selectedColumns },
|
|
348
347
|
React.createElement("div", { className: "case-list-table-toolbar pf-v5-l-flex", ref: tableToolbarRef },
|
|
349
|
-
React.createElement("div", { className: "toolbar-actions pf-v5-l-flex
|
|
350
|
-
React.createElement(
|
|
351
|
-
React.createElement(
|
|
352
|
-
React.createElement(CloseCaseBtn, { selectedCases: selectedCases, caseList: caseListData, onCasesCloseSuccess: onCasesCloseSuccess })),
|
|
348
|
+
React.createElement("div", { className: "toolbar-actions pf-v5-l-flex" },
|
|
349
|
+
React.createElement(TableActionsDropdown, { caseList: caseListData, selectedCases: selectedCases, onCasesCloseSuccess: onCasesCloseSuccess, currentFilteredCaseList: props.caseList }),
|
|
350
|
+
React.createElement(TableColumnSelector, { onColumnSelectorChange: onColumnSelectorChange, cachedColumns: selectedColumns })),
|
|
353
351
|
React.createElement("span", { className: "toolbar-pagination" },
|
|
354
352
|
React.createElement(TablePagination, { perPage: (_c = props.paginationInfo) === null || _c === void 0 ? void 0 : _c.pageSize, currentPage: (_d = props.paginationInfo) === null || _d === void 0 ? void 0 : _d.currentPage, onPerPageSelect: onPerPageSelect, onSetPage: onSetPage, variant: PaginationVariant.top, itemCount: getItemCount() }))),
|
|
355
353
|
React.createElement("div", { className: "pf-v5-c-scroll-inner-wrapper" },
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IUseCloseCaseProps } from '../../../hooks/useCloseCase';
|
|
3
|
+
import { IUseExportCaseListCSV } from '../../../hooks/useExportCaseListCSV';
|
|
4
|
+
interface IProps extends IUseCloseCaseProps, IUseExportCaseListCSV {
|
|
5
|
+
}
|
|
6
|
+
export declare function TableActionsDropdown(props: IProps): React.JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=TableActionsDropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableActionsDropdown.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-table/TableActionsDropdown.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,kBAAkB,EAAgB,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAwB,MAAM,qCAAqC,CAAC;AASlG,UAAU,MAAO,SAAQ,kBAAkB,EAAE,qBAAqB;CAAG;AAErE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,qBAwHjD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Badge, Icon, Tooltip } from '@patternfly/react-core';
|
|
2
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
|
|
3
|
+
import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
|
|
4
|
+
import WarningTriangleIcon from '@patternfly/react-icons/dist/js/icons/warning-triangle-icon';
|
|
5
|
+
import { SingleSelectDropdown } from '@rh-support/components';
|
|
6
|
+
import { CloseCaseModal, GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
7
|
+
import React, { useContext } from 'react';
|
|
8
|
+
import { useTranslation } from 'react-i18next';
|
|
9
|
+
import { useCloseCase } from '../../../hooks/useCloseCase';
|
|
10
|
+
import { useExportCaseListCSV } from '../../../hooks/useExportCaseListCSV';
|
|
11
|
+
import { CaseListFilterStateContext } from '../CaseListFilterContext';
|
|
12
|
+
import DownloadCSVFileModal from './DownloadCSVFileModal';
|
|
13
|
+
var ToolbarLabels;
|
|
14
|
+
(function (ToolbarLabels) {
|
|
15
|
+
ToolbarLabels["ExportCSV"] = "Export CSV";
|
|
16
|
+
ToolbarLabels["CloseCase"] = "Close Case";
|
|
17
|
+
})(ToolbarLabels || (ToolbarLabels = {}));
|
|
18
|
+
export function TableActionsDropdown(props) {
|
|
19
|
+
var _a;
|
|
20
|
+
const { selectedCases, currentFilteredCaseList } = props;
|
|
21
|
+
const { t } = useTranslation();
|
|
22
|
+
const currentFilteredCaseCount = (_a = currentFilteredCaseList === null || currentFilteredCaseList === void 0 ? void 0 : currentFilteredCaseList.numFound) !== null && _a !== void 0 ? _a : 0;
|
|
23
|
+
const filterState = useContext(CaseListFilterStateContext);
|
|
24
|
+
const { isExportButtonDisabled, openUpdateSeverityModal, showError: showExportCSVError, getTooltipContent: getExportCSVTooltipContent, toggleDownloadCSVModal, } = useExportCaseListCSV(props);
|
|
25
|
+
const { globalMetadataState: { loggedInUserRights, loggedInUsersAccount }, } = useContext(GlobalMetadataStateContext);
|
|
26
|
+
const { isModalOpen, isPostingComment, showError, showWarning, getTooltipContent, onCancel, onConfirm, onBtnClick, } = useCloseCase(props);
|
|
27
|
+
let closeCaseIconStatus = 'danger';
|
|
28
|
+
if (showWarning) {
|
|
29
|
+
closeCaseIconStatus = 'warning';
|
|
30
|
+
}
|
|
31
|
+
let exportCSVIconStatus = 'info';
|
|
32
|
+
if (showExportCSVError) {
|
|
33
|
+
exportCSVIconStatus = 'danger';
|
|
34
|
+
}
|
|
35
|
+
const toolbarDropdownItems = [
|
|
36
|
+
{
|
|
37
|
+
value: 'export-csv',
|
|
38
|
+
label: ToolbarLabels.ExportCSV,
|
|
39
|
+
disabled: showExportCSVError,
|
|
40
|
+
title: t('Export CSV'),
|
|
41
|
+
element: (React.createElement("div", { className: "pf-v5-u-display-flex pf-v5-u-justify-content-space-between" },
|
|
42
|
+
t('Export CSV'),
|
|
43
|
+
React.createElement(Tooltip, { content: getExportCSVTooltipContent() },
|
|
44
|
+
React.createElement(Icon, { "data-testid": "export-csv-warning-icon", className: "pf-v5-u-align-self-center", status: exportCSVIconStatus, isInline: true },
|
|
45
|
+
showExportCSVError && React.createElement(ExclamationCircleIcon, null),
|
|
46
|
+
!showExportCSVError && React.createElement(InfoCircleIcon, null))))),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
value: 'close-case-btn',
|
|
50
|
+
label: ToolbarLabels.CloseCase,
|
|
51
|
+
disabled: showError,
|
|
52
|
+
title: t('Close selected cases'),
|
|
53
|
+
element: (React.createElement("div", { className: "pf-v5-u-display-flex pf-v5-u-justify-content-space-between" },
|
|
54
|
+
t('Close case'),
|
|
55
|
+
(showError || showWarning) && selectedCases.length > 0 && (React.createElement(Tooltip, { content: getTooltipContent() },
|
|
56
|
+
React.createElement(Icon, { "data-testid": "close-case-warning-icon", className: "pf-v5-u-align-self-center", status: closeCaseIconStatus, isInline: true },
|
|
57
|
+
showWarning && React.createElement(WarningTriangleIcon, null),
|
|
58
|
+
showError && React.createElement(ExclamationCircleIcon, null)))))),
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
const onSelect = (option) => {
|
|
62
|
+
switch (option.label) {
|
|
63
|
+
case ToolbarLabels.CloseCase:
|
|
64
|
+
onBtnClick();
|
|
65
|
+
break;
|
|
66
|
+
case ToolbarLabels.ExportCSV:
|
|
67
|
+
toggleDownloadCSVModal();
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return (React.createElement(React.Fragment, null,
|
|
72
|
+
isModalOpen && React.createElement(CloseCaseModal, { onClose: onCancel, onConfirm: onConfirm, isUpdating: !!isPostingComment }),
|
|
73
|
+
React.createElement(DownloadCSVFileModal, { filterState: filterState, loggedInUserRights: loggedInUserRights, loggedInUsersAccount: loggedInUsersAccount, isDisabled: isExportButtonDisabled, onModalshow: openUpdateSeverityModal, onClose: toggleDownloadCSVModal, selectedCases: selectedCases, filteredCaseCount: currentFilteredCaseCount }),
|
|
74
|
+
React.createElement(SingleSelectDropdown, { selected: { value: null, label: '' }, placeholder: React.createElement(React.Fragment, null,
|
|
75
|
+
"Actions ",
|
|
76
|
+
React.createElement(Badge, { key: 1 }, selectedCases.length)), onSelect: onSelect, options: toolbarDropdownItems, id: "table-actions-dropdown" })));
|
|
77
|
+
}
|
package/lib/esm/css/caseList.css
CHANGED
|
@@ -223,6 +223,10 @@
|
|
|
223
223
|
border: 1px solid #ccc;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
.case-list-table td[data-label='Title'] {
|
|
227
|
+
text-align: start !important;
|
|
228
|
+
}
|
|
229
|
+
|
|
226
230
|
.case-search-bottom .case-list-table input[type='checkbox'] {
|
|
227
231
|
margin-top: 4px;
|
|
228
232
|
}
|
|
@@ -467,6 +471,22 @@
|
|
|
467
471
|
--pf-v5-c-select__toggle-text--Color: var(--pf-v5-c-select__toggle--m-placeholder__toggle-text--Color) !important;
|
|
468
472
|
}
|
|
469
473
|
|
|
474
|
+
.toolbar-actions > :first-child {
|
|
475
|
+
margin-right: 1rem;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
#table-actions-dropdown button {
|
|
479
|
+
pointer-events: fill !important;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
#table-actions-dropdown .pf-v5-c-icon {
|
|
483
|
+
cursor: pointer;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
#table-actions-dropdown .pf-v5-c-icon {
|
|
487
|
+
margin-left: 1rem;
|
|
488
|
+
}
|
|
489
|
+
|
|
470
490
|
@media (min-width: 770px) {
|
|
471
491
|
/* Checkbox */
|
|
472
492
|
.case-list-table thead > tr > :nth-child(1),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ICaseListResponse } from '../models/caseList';
|
|
2
|
+
export declare const MAX_ALLOWED_CASES = 5;
|
|
3
|
+
export interface IUseCloseCaseProps {
|
|
4
|
+
caseList: ICaseListResponse[];
|
|
5
|
+
selectedCases: string[];
|
|
6
|
+
onCasesCloseSuccess?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function useCloseCase(props: IUseCloseCaseProps): {
|
|
9
|
+
areAllSelectedCasesClosed: boolean;
|
|
10
|
+
hasAtLeastOneCaseClosed: boolean;
|
|
11
|
+
isBtnDisabled: boolean;
|
|
12
|
+
isPostingComment: boolean;
|
|
13
|
+
isModalOpen: boolean;
|
|
14
|
+
maxCasesSelected: boolean;
|
|
15
|
+
showWarning: boolean;
|
|
16
|
+
showError: boolean;
|
|
17
|
+
getTooltipContent: () => any;
|
|
18
|
+
onCancel: () => void;
|
|
19
|
+
onConfirm: (commentBody: any) => Promise<void>;
|
|
20
|
+
onBtnClick: () => void;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useCloseCase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCloseCase.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCloseCase.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAQD,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB;;;;;;;;;;;;;EAiGrD"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { publicApi } from '@cee-eng/hydrajs';
|
|
11
|
+
import { ToastNotification, useFetch } from '@rh-support/components';
|
|
12
|
+
import { useCanCreateCase } from '@rh-support/react-context';
|
|
13
|
+
import { dtmTrackEventCaseStepEncountered } from '@rh-support/utils';
|
|
14
|
+
import filter from 'lodash/filter';
|
|
15
|
+
import find from 'lodash/find';
|
|
16
|
+
import includes from 'lodash/includes';
|
|
17
|
+
import { useState } from 'react';
|
|
18
|
+
import { useTranslation } from 'react-i18next';
|
|
19
|
+
export const MAX_ALLOWED_CASES = 5;
|
|
20
|
+
const reflect = (p) => p.then((v) => ({ v, status: 'fulfilled' }), (e) => ({ e, status: 'rejected' }));
|
|
21
|
+
export function useCloseCase(props) {
|
|
22
|
+
const { caseList, selectedCases, onCasesCloseSuccess } = props;
|
|
23
|
+
const { t } = useTranslation();
|
|
24
|
+
const maxCasesSelected = (selectedCases || []).length > MAX_ALLOWED_CASES;
|
|
25
|
+
const { request, isFetching } = useFetch(publicApi.kase.updateCase);
|
|
26
|
+
const closedCaseIds = filter(selectedCases, (selected) => {
|
|
27
|
+
const caseDetails = find(caseList, (caseObj) => caseObj['case_number'] === selected);
|
|
28
|
+
return caseDetails && caseDetails['case_status'] !== 'Closed' ? false : true;
|
|
29
|
+
});
|
|
30
|
+
const hasAtLeastOneCaseClosed = closedCaseIds.length > 0;
|
|
31
|
+
const areAllSelectedCasesClosed = closedCaseIds.length === selectedCases.length;
|
|
32
|
+
const showWarning = hasAtLeastOneCaseClosed && !areAllSelectedCasesClosed && !maxCasesSelected;
|
|
33
|
+
const showError = areAllSelectedCasesClosed || maxCasesSelected;
|
|
34
|
+
const isBtnDisabled = (selectedCases || []).length < 1 ||
|
|
35
|
+
caseList.length < 1 ||
|
|
36
|
+
maxCasesSelected ||
|
|
37
|
+
areAllSelectedCasesClosed ||
|
|
38
|
+
isFetching;
|
|
39
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
40
|
+
const canCreateCase = useCanCreateCase();
|
|
41
|
+
const { request: postCommentRequest, isFetching: isPostingComment } = useFetch(publicApi.kase.postComment, {
|
|
42
|
+
propgateErrors: true,
|
|
43
|
+
});
|
|
44
|
+
// To handle button click
|
|
45
|
+
const onBtnClick = () => {
|
|
46
|
+
if (canCreateCase.alert()) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
setIsModalOpen(true);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const onConfirm = (commentBody) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const promiseArr = [];
|
|
55
|
+
setIsModalOpen(false);
|
|
56
|
+
const toastId = ToastNotification.addSuccessMessage(t(`Closing selected cases`));
|
|
57
|
+
filter(selectedCases, (selected) => !includes(closedCaseIds, selected)).forEach((caseNumber, i) => {
|
|
58
|
+
const product = caseList[i].case_product[0];
|
|
59
|
+
const version = caseList[i].case_version;
|
|
60
|
+
const p = request(caseNumber, { status: 'Closed' });
|
|
61
|
+
promiseArr.push(p);
|
|
62
|
+
p.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
yield postCommentRequest({
|
|
64
|
+
caseNumber,
|
|
65
|
+
commentBody,
|
|
66
|
+
contentType: `markdown`,
|
|
67
|
+
doNotChangeStatus: true,
|
|
68
|
+
});
|
|
69
|
+
ToastNotification.clearToast(toastId);
|
|
70
|
+
ToastNotification.addSuccessMessage(t('Case {{caseNumber}} successfully closed', { caseNumber }));
|
|
71
|
+
// Only call dtm track event only when the case has been closed successfully.
|
|
72
|
+
dtmTrackEventCaseStepEncountered('close', caseNumber, product, version);
|
|
73
|
+
}), (err) => {
|
|
74
|
+
ToastNotification.clearToast(toastId);
|
|
75
|
+
ToastNotification.addDangerMessage(t('Could not close case {{caseNumber}}', { caseNumber }));
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
yield Promise.all(promiseArr.map(reflect));
|
|
79
|
+
onCasesCloseSuccess && onCasesCloseSuccess();
|
|
80
|
+
});
|
|
81
|
+
const onCancel = () => {
|
|
82
|
+
setIsModalOpen(false);
|
|
83
|
+
};
|
|
84
|
+
const getTooltipContent = () => {
|
|
85
|
+
let tooltipText = t('Close selected cases');
|
|
86
|
+
if (maxCasesSelected) {
|
|
87
|
+
tooltipText = t('You can only close {{maxCase}} cases at once.', { maxCase: MAX_ALLOWED_CASES });
|
|
88
|
+
}
|
|
89
|
+
else if (areAllSelectedCasesClosed) {
|
|
90
|
+
tooltipText = t(`The case(s) that you have selected are already closed.`);
|
|
91
|
+
}
|
|
92
|
+
else if (hasAtLeastOneCaseClosed) {
|
|
93
|
+
tooltipText = t('Some of the selected cases are already closed. The remaining open cases will be closed.');
|
|
94
|
+
}
|
|
95
|
+
return tooltipText;
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
areAllSelectedCasesClosed,
|
|
99
|
+
hasAtLeastOneCaseClosed,
|
|
100
|
+
isBtnDisabled,
|
|
101
|
+
isPostingComment,
|
|
102
|
+
isModalOpen,
|
|
103
|
+
maxCasesSelected,
|
|
104
|
+
showWarning,
|
|
105
|
+
showError,
|
|
106
|
+
getTooltipContent,
|
|
107
|
+
onCancel,
|
|
108
|
+
onConfirm,
|
|
109
|
+
onBtnClick,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ISolrResponse } from '@rh-support/types/shared';
|
|
2
|
+
import { ICaseListResponse } from '../models/caseList';
|
|
3
|
+
export declare const MAX_LIMIT = 1000;
|
|
4
|
+
export interface IUseExportCaseListCSV {
|
|
5
|
+
currentFilteredCaseList: ISolrResponse<ICaseListResponse>;
|
|
6
|
+
isExportCsvDisabled?: boolean;
|
|
7
|
+
selectedCases: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function useExportCaseListCSV(props: IUseExportCaseListCSV): {
|
|
10
|
+
isExportButtonDisabled: boolean;
|
|
11
|
+
openUpdateSeverityModal: boolean;
|
|
12
|
+
showError: boolean;
|
|
13
|
+
getTooltipContent: () => any;
|
|
14
|
+
toggleDownloadCSVModal: () => void;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=useExportCaseListCSV.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExportCaseListCSV.d.ts","sourceRoot":"","sources":["../../../src/hooks/useExportCaseListCSV.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAIzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvD,eAAO,MAAM,SAAS,OAAO,CAAC;AAC9B,MAAM,WAAW,qBAAqB;IAClC,uBAAuB,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC1D,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,qBAAqB;;;;;;EAqChE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useFetch } from '@rh-support/components';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { getCaseListFromSolr } from '../utils/caseListUtils';
|
|
5
|
+
export const MAX_LIMIT = 1000;
|
|
6
|
+
export function useExportCaseListCSV(props) {
|
|
7
|
+
const { isExportCsvDisabled, selectedCases } = props;
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
// const currentFilteredCaseCount = currentFilteredCaseList?.numFound ?? 0;
|
|
10
|
+
const { isFetching } = useFetch(getCaseListFromSolr, { propgateErrors: true });
|
|
11
|
+
const [openUpdateSeverityModal, setOpenUpdateSeverityModal] = useState(false);
|
|
12
|
+
const isFetchingCSVData = isFetching;
|
|
13
|
+
let showError = selectedCases.length > MAX_LIMIT;
|
|
14
|
+
const isBtnDisabled = isFetchingCSVData || showError;
|
|
15
|
+
// To show tooltip if export csv is disabled when SOLR is down
|
|
16
|
+
const getTooltipContent = () => {
|
|
17
|
+
let tooltipText = t('Your download will include the first 1000 cases in your list.');
|
|
18
|
+
if (showError) {
|
|
19
|
+
tooltipText = t('Your download can only include up to {{limit}} cases.', { limit: MAX_LIMIT });
|
|
20
|
+
}
|
|
21
|
+
else if (selectedCases.length > 0) {
|
|
22
|
+
tooltipText = t('Your download will include {{numOfCases}} cases.', { numOfCases: selectedCases.length });
|
|
23
|
+
}
|
|
24
|
+
return tooltipText;
|
|
25
|
+
};
|
|
26
|
+
// To check if export csv button is disabled
|
|
27
|
+
const isExportButtonDisabled = isBtnDisabled || isExportCsvDisabled;
|
|
28
|
+
// To toggle download csv modal
|
|
29
|
+
const toggleDownloadCSVModal = () => {
|
|
30
|
+
setOpenUpdateSeverityModal((openUpdateSeverityModal) => !openUpdateSeverityModal);
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
isExportButtonDisabled,
|
|
34
|
+
openUpdateSeverityModal,
|
|
35
|
+
showError,
|
|
36
|
+
getTooltipContent,
|
|
37
|
+
toggleDownloadCSVModal,
|
|
38
|
+
};
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/cases",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"@patternfly/patternfly": "5.4.2",
|
|
44
44
|
"@patternfly/react-core": "5.4.2",
|
|
45
45
|
"@patternfly/react-table": "5.4.2",
|
|
46
|
-
"@rh-support/components": "2.5.
|
|
47
|
-
"@rh-support/react-context": "2.5.
|
|
46
|
+
"@rh-support/components": "2.5.24",
|
|
47
|
+
"@rh-support/react-context": "2.5.26",
|
|
48
48
|
"@rh-support/types": "2.0.5",
|
|
49
|
-
"@rh-support/user-permissions": "2.5.
|
|
50
|
-
"@rh-support/utils": "2.5.
|
|
49
|
+
"@rh-support/user-permissions": "2.5.16",
|
|
50
|
+
"@rh-support/utils": "2.5.15",
|
|
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": "
|
|
99
|
+
"gitHead": "c3b867501d42f1a3b5cfd0ae1dd6c262003fdb23"
|
|
100
100
|
}
|