@rh-support/cases 2.1.35 → 2.1.37
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/CaseList.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseList.js +38 -33
- package/lib/esm/components/case-list/CaseListFilterReducer.d.ts +3 -0
- package/lib/esm/components/case-list/CaseListFilterReducer.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseListFilterReducer.js +3 -0
- package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts +0 -1
- 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 +186 -93
- package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts +16 -0
- package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.js +273 -0
- package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.scss +27 -0
- package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.js +14 -91
- package/lib/esm/components/case-list/case-search/SaveCaseSearchModal.js +1 -1
- package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.d.ts +1 -0
- package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.d.ts.map +1 -1
- package/lib/esm/components/index.d.ts +0 -7
- package/lib/esm/components/index.d.ts.map +1 -1
- package/lib/esm/components/index.js +0 -7
- package/lib/esm/css/caseList.css +33 -39
- package/lib/esm/models/caseList.d.ts +3 -0
- package/lib/esm/models/caseList.d.ts.map +1 -1
- package/lib/esm/utils/caseListUtils.js +2 -2
- package/package.json +6 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownloadCSVFileModal.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-table/DownloadCSVFileModal.tsx"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AAGrC,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAiBlE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAQxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,UAAU,MAAM;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,kBAAkB,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAClD,oBAAoB,EAAE,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7D,WAAW,EAAE,oBAAoB,CAAC;CACrC;AAYD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,KAAK,EAAE,MAAM,eAuXzD"}
|
|
@@ -0,0 +1,273 @@
|
|
|
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 './DownloadCSVFileModal.scss';
|
|
11
|
+
import { publicApi } from '@cee-eng/hydrajs';
|
|
12
|
+
import { Button, Checkbox, Form, FormGroup, Grid, GridItem, InputGroup, Modal, ModalVariant, Spinner, TextInput, } from '@patternfly/react-core';
|
|
13
|
+
import DownloadIcon from '@patternfly/react-icons/dist/js/icons/download-icon';
|
|
14
|
+
import TimesCircleIcon from '@patternfly/react-icons/dist/js/icons/times-circle-icon';
|
|
15
|
+
import { ToastNotification, useFetch } from '@rh-support/components';
|
|
16
|
+
import { downloadCSV, formatDateTime, toNewCaseTypeSwitcher } from '@rh-support/utils';
|
|
17
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
18
|
+
import { useTranslation } from 'react-i18next';
|
|
19
|
+
import { SFDCKeys, SolrKeys } from '../../../enums/filters';
|
|
20
|
+
import { getCaseListFromSolr } from '../../../utils/caseListUtils';
|
|
21
|
+
import { createQueryForCSVDownload } from '../../../utils/caseSearchUtils';
|
|
22
|
+
const csvHeadersSolr = [
|
|
23
|
+
{ label: 'Case number', key: SolrKeys.caseNumber },
|
|
24
|
+
{ label: 'Summary', key: SolrKeys.caseSummary },
|
|
25
|
+
];
|
|
26
|
+
const csvHeadersSFDC = [
|
|
27
|
+
{ label: 'Case number', key: SFDCKeys.caseNumber },
|
|
28
|
+
{ label: 'Summary', key: SFDCKeys.caseSummary },
|
|
29
|
+
];
|
|
30
|
+
export default function DownloadCSVFileModal(props) {
|
|
31
|
+
const { onClose, onModalshow, isDisabled, loggedInUserRights, loggedInUsersAccount, filterState } = props;
|
|
32
|
+
const { t } = useTranslation();
|
|
33
|
+
const { isFetching, request } = useFetch(getCaseListFromSolr, { propgateErrors: true });
|
|
34
|
+
const [downloadCSVFileName, setDownloadCSVFileName] = useState('');
|
|
35
|
+
const [isFetchingSFDC, setIsFetchingSFDC] = useState(false);
|
|
36
|
+
const [generatedCsvHeaders, setGeneratedCsvHeaders] = useState([]);
|
|
37
|
+
const [checkboxes, setCheckboxes] = useState({
|
|
38
|
+
selectAll: false,
|
|
39
|
+
ownerName: false,
|
|
40
|
+
modifiedBy: false,
|
|
41
|
+
severity: false,
|
|
42
|
+
status: false,
|
|
43
|
+
createdBy: false,
|
|
44
|
+
productVersion: false,
|
|
45
|
+
accountNumber: false,
|
|
46
|
+
alternateId: false,
|
|
47
|
+
type: false,
|
|
48
|
+
caseClosedDate: false,
|
|
49
|
+
});
|
|
50
|
+
function getKey(key, isSecureSupport) {
|
|
51
|
+
return isSecureSupport ? SFDCKeys[key] : SolrKeys[key];
|
|
52
|
+
}
|
|
53
|
+
const headerDefinitions = useMemo(() => [
|
|
54
|
+
{
|
|
55
|
+
checkbox: checkboxes.ownerName,
|
|
56
|
+
key: getKey('ownerName', loggedInUsersAccount.data.secureSupport),
|
|
57
|
+
label: 'Owner name',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
checkbox: checkboxes.severity,
|
|
61
|
+
key: getKey('severity', loggedInUsersAccount.data.secureSupport),
|
|
62
|
+
label: 'Severity',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
checkbox: checkboxes.createdBy,
|
|
66
|
+
key: getKey('createdBy', loggedInUsersAccount.data.secureSupport),
|
|
67
|
+
label: 'Created by',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
checkbox: checkboxes.createdBy,
|
|
71
|
+
key: getKey('createdDate', loggedInUsersAccount.data.secureSupport),
|
|
72
|
+
label: 'Created date',
|
|
73
|
+
transform: formatDateTime,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
checkbox: checkboxes.accountNumber,
|
|
77
|
+
key: getKey('accountNumber', loggedInUsersAccount.data.secureSupport),
|
|
78
|
+
label: 'Account number',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
checkbox: checkboxes.type,
|
|
82
|
+
key: getKey('type', loggedInUsersAccount.data.secureSupport),
|
|
83
|
+
label: 'Case type',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
checkbox: checkboxes.modifiedBy,
|
|
87
|
+
key: getKey('modifiedBy', loggedInUsersAccount.data.secureSupport),
|
|
88
|
+
label: 'Modified by',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
checkbox: checkboxes.modifiedBy,
|
|
92
|
+
key: getKey('modifiedDate', loggedInUsersAccount.data.secureSupport),
|
|
93
|
+
label: 'Modified date',
|
|
94
|
+
transform: formatDateTime,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
checkbox: checkboxes.status,
|
|
98
|
+
key: getKey('status', loggedInUsersAccount.data.secureSupport),
|
|
99
|
+
label: 'Status',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
checkbox: checkboxes.productVersion,
|
|
103
|
+
key: getKey('product', loggedInUsersAccount.data.secureSupport),
|
|
104
|
+
label: 'Product',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
checkbox: checkboxes.productVersion,
|
|
108
|
+
key: getKey('version', loggedInUsersAccount.data.secureSupport),
|
|
109
|
+
label: 'Version',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
checkbox: checkboxes.alternateId,
|
|
113
|
+
key: getKey('alternateId', loggedInUsersAccount.data.secureSupport),
|
|
114
|
+
label: 'Alternate ID',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
checkbox: checkboxes.caseClosedDate,
|
|
118
|
+
key: getKey('caseClosedDate', loggedInUsersAccount.data.secureSupport),
|
|
119
|
+
label: 'Closed date',
|
|
120
|
+
transform: formatDateTime,
|
|
121
|
+
},
|
|
122
|
+
], [checkboxes, loggedInUsersAccount.data.secureSupport]);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
const updatedCsvHeaders = loggedInUsersAccount.data.secureSupport
|
|
125
|
+
? csvHeadersSFDC
|
|
126
|
+
: csvHeadersSolr;
|
|
127
|
+
headerDefinitions.forEach((headerDefinition) => {
|
|
128
|
+
const { checkbox, key, label, transform } = headerDefinition;
|
|
129
|
+
const index = updatedCsvHeaders.findIndex((header) => header.key === key);
|
|
130
|
+
if (checkbox) {
|
|
131
|
+
if (index === -1) {
|
|
132
|
+
updatedCsvHeaders.push({ key, label, transform });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
if (index !== -1) {
|
|
137
|
+
updatedCsvHeaders.splice(index, 1);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
setGeneratedCsvHeaders(updatedCsvHeaders);
|
|
142
|
+
}, [loggedInUsersAccount.data.secureSupport, checkboxes, headerDefinitions]);
|
|
143
|
+
const isFetchingCSVData = isFetching || isFetchingSFDC;
|
|
144
|
+
const isOrgAdmin = loggedInUserRights.data.isOrgAdmin();
|
|
145
|
+
const partnerSearch = loggedInUserRights.data.hasManagedAccounts();
|
|
146
|
+
const splitExtensionName = downloadCSVFileName.split('.')[0];
|
|
147
|
+
const onCancel = () => {
|
|
148
|
+
onClose && onClose();
|
|
149
|
+
};
|
|
150
|
+
const handleCSVFileNameChange = (value) => {
|
|
151
|
+
setDownloadCSVFileName(value);
|
|
152
|
+
};
|
|
153
|
+
const clearDownloadCSVFileName = () => {
|
|
154
|
+
setDownloadCSVFileName('');
|
|
155
|
+
};
|
|
156
|
+
const handleCheckboxChange = (key) => {
|
|
157
|
+
setCheckboxes((prevCheckboxes) => (Object.assign(Object.assign({}, prevCheckboxes), { [key]: !prevCheckboxes[key] })));
|
|
158
|
+
};
|
|
159
|
+
// Group header for SOLR
|
|
160
|
+
const groupHeaderSOLR = { label: 'Group', key: SolrKeys.groupName };
|
|
161
|
+
// For SOLR
|
|
162
|
+
const onExportCSVClick = () => __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
try {
|
|
164
|
+
const res = yield request(createQueryForCSVDownload(filterState, loggedInUserRights.data, loggedInUsersAccount.data), partnerSearch, null, loggedInUsersAccount.data.secureSupport);
|
|
165
|
+
const headers = isOrgAdmin ? [...csvHeadersSolr, groupHeaderSOLR] : generatedCsvHeaders;
|
|
166
|
+
// To map the values in csv to new support type
|
|
167
|
+
const updatedCsvData = res.response.docs.map((row) => (Object.assign(Object.assign({}, row), { case_type: toNewCaseTypeSwitcher(row.case_type) })));
|
|
168
|
+
downloadCSV(updatedCsvData, headers, splitExtensionName ? `${splitExtensionName}.csv` : 'CaseList.csv');
|
|
169
|
+
onCancel();
|
|
170
|
+
ToastNotification.addSuccessMessage(t('File downloaded successfully!'));
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
onCancel();
|
|
174
|
+
ToastNotification.addDangerMessage(t('File could not be downloaded. Please try again! '));
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
// Group header for SFDC
|
|
178
|
+
const groupHeaderSFDC = { label: 'Group', key: SFDCKeys.groupName };
|
|
179
|
+
// For SFDC
|
|
180
|
+
const onExportCSVClickSecureSupport = () => __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
try {
|
|
182
|
+
const sfdcFilter = createQueryForCSVDownload(filterState, loggedInUserRights.data, loggedInUsersAccount.data);
|
|
183
|
+
setIsFetchingSFDC(true);
|
|
184
|
+
const sfdcResponse = yield publicApi.caseList.getCaseListFromSFDC(sfdcFilter, false, true);
|
|
185
|
+
setIsFetchingSFDC(false);
|
|
186
|
+
const headers = isOrgAdmin ? [...csvHeadersSFDC, groupHeaderSFDC] : csvHeadersSFDC;
|
|
187
|
+
// To map the values in csv to new support type
|
|
188
|
+
const updatedCsvData = sfdcResponse.cases.map((row) => (Object.assign(Object.assign({}, row), { caseType: toNewCaseTypeSwitcher(row.caseType) })));
|
|
189
|
+
downloadCSV(updatedCsvData, headers, splitExtensionName ? `${splitExtensionName}.csv` : 'CaseList.csv');
|
|
190
|
+
onCancel();
|
|
191
|
+
ToastNotification.addSuccessMessage(t('File downloaded successfully!'));
|
|
192
|
+
}
|
|
193
|
+
catch (e) {
|
|
194
|
+
setIsFetchingSFDC(false);
|
|
195
|
+
onCancel();
|
|
196
|
+
ToastNotification.addDangerMessage(t('Could not export CSV'));
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
useEffect(() => {
|
|
200
|
+
const commonState = checkboxes.selectAll;
|
|
201
|
+
const updatedCheckboxes = {
|
|
202
|
+
ownerName: commonState,
|
|
203
|
+
modifiedBy: commonState,
|
|
204
|
+
severity: commonState,
|
|
205
|
+
status: commonState,
|
|
206
|
+
createdBy: commonState,
|
|
207
|
+
productVersion: commonState,
|
|
208
|
+
accountNumber: commonState,
|
|
209
|
+
alternateId: commonState,
|
|
210
|
+
type: commonState,
|
|
211
|
+
caseClosedDate: commonState,
|
|
212
|
+
};
|
|
213
|
+
setCheckboxes((prevCheckboxes) => (Object.assign(Object.assign({}, prevCheckboxes), updatedCheckboxes)));
|
|
214
|
+
}, [checkboxes.selectAll]);
|
|
215
|
+
const handleSelectAll = () => {
|
|
216
|
+
setCheckboxes((prevCheckboxes) => (Object.assign(Object.assign({}, prevCheckboxes), { selectAll: !prevCheckboxes.selectAll })));
|
|
217
|
+
};
|
|
218
|
+
const csvHeadersOne = [
|
|
219
|
+
{ label: 'Owner', key: 'ownerName' },
|
|
220
|
+
{ label: 'Severity', key: 'severity' },
|
|
221
|
+
{ label: 'Created by', key: 'createdBy' },
|
|
222
|
+
{ label: 'Account number', key: 'accountNumber' },
|
|
223
|
+
{ label: 'Case type', key: 'type' },
|
|
224
|
+
];
|
|
225
|
+
const csvHeadersTwo = [
|
|
226
|
+
{ label: 'Modified by', key: 'modifiedBy' },
|
|
227
|
+
{ label: 'Status', key: 'status' },
|
|
228
|
+
{ label: 'Product and version', key: 'productVersion' },
|
|
229
|
+
{ label: 'Alternate case ID', key: 'alternateId' },
|
|
230
|
+
{ label: 'Closed date', key: 'caseClosedDate' },
|
|
231
|
+
];
|
|
232
|
+
const generateCheckboxes = (fieldDefinitions) => {
|
|
233
|
+
return fieldDefinitions.map((field) => (React.createElement(Checkbox, { key: field.key, className: "nested", label: t(field.label), isChecked: checkboxes[field.key], onChange: () => {
|
|
234
|
+
handleCheckboxChange(field.key);
|
|
235
|
+
}, id: field.key, name: field.key })));
|
|
236
|
+
};
|
|
237
|
+
// CSV Modal Body
|
|
238
|
+
const downloadCSVModalBody = () => {
|
|
239
|
+
return (React.createElement(Form, { className: "download-csv-modal-body" },
|
|
240
|
+
React.createElement(FormGroup, { label: t('File name'), fieldId: "download-csv-file-name" },
|
|
241
|
+
React.createElement(InputGroup, null,
|
|
242
|
+
React.createElement(TextInput, { type: "text", id: "csv-file-name", name: "download-csv-file-name", value: downloadCSVFileName, onChange: (_event, value) => handleCSVFileNameChange(value) }),
|
|
243
|
+
React.createElement(Button, { variant: "plain", onClick: clearDownloadCSVFileName, icon: React.createElement(TimesCircleIcon, null) }))),
|
|
244
|
+
React.createElement(FormGroup, { label: t('Please select the fields you want included in your download.'), fieldId: "download-csv-file-fields-select" },
|
|
245
|
+
React.createElement(Grid, null,
|
|
246
|
+
React.createElement(Checkbox, { label: t('Select all'), isChecked: checkboxes.selectAll, onChange: handleSelectAll, id: "selectAll", name: "selectAll" }),
|
|
247
|
+
React.createElement(GridItem, { span: 6 },
|
|
248
|
+
React.createElement(Checkbox, { className: "nested", label: t('Case ID'), defaultChecked: true, isDisabled: true, id: "controlled-check-2", name: "check2" }),
|
|
249
|
+
generateCheckboxes(csvHeadersOne)),
|
|
250
|
+
React.createElement(GridItem, { span: 6 },
|
|
251
|
+
React.createElement(Checkbox, { className: "nested", label: t('Issue summary'), defaultChecked: true, isDisabled: true, id: "controlled-check-3", name: "check3" }),
|
|
252
|
+
generateCheckboxes(csvHeadersTwo))))));
|
|
253
|
+
};
|
|
254
|
+
const downloadCSVModalDescription = () => {
|
|
255
|
+
const numberOfCases = 1 | 2 | 3;
|
|
256
|
+
switch (numberOfCases) {
|
|
257
|
+
case 1:
|
|
258
|
+
return t('Your download will include 100 cases. ');
|
|
259
|
+
case 2:
|
|
260
|
+
return t('Your download will include 512 cases.');
|
|
261
|
+
case 3:
|
|
262
|
+
return t('Only the first 1000 cases will be included in your download. Please note this may take a while. ');
|
|
263
|
+
default:
|
|
264
|
+
return '';
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
// Download CSV modal buttons
|
|
268
|
+
const modalActions = [
|
|
269
|
+
React.createElement(Button, { key: "submit", icon: isFetchingCSVData ? React.createElement(Spinner, { size: "md" }) : React.createElement(DownloadIcon, null), variant: "primary", "data-tracking-id": "download-csv-modal-submit", onClick: loggedInUsersAccount.data.secureSupport ? onExportCSVClickSecureSupport : onExportCSVClick, isDisabled: isDisabled || isFetchingCSVData }, t('Download')),
|
|
270
|
+
React.createElement(Button, { key: "back", variant: "secondary", onClick: onCancel, isDisabled: isDisabled || isFetchingCSVData, "data-tracking-id": "download-csv-modal-cancel" }, t('Cancel')),
|
|
271
|
+
];
|
|
272
|
+
return (React.createElement(Modal, { title: t('Download CSV file'), description: downloadCSVModalDescription(), className: "download-csv-modal", variant: ModalVariant.large, isOpen: onModalshow, onClose: onCancel, actions: modalActions }, downloadCSVModalBody()));
|
|
273
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.pf-c-form__group {
|
|
2
|
+
.pf-c-form__group-control {
|
|
3
|
+
.pf-l-grid {
|
|
4
|
+
.pf-c-check {
|
|
5
|
+
.pf-c-check__label {
|
|
6
|
+
font-size: 16px;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
.pf-l-grid__item.pf-m-6-col {
|
|
13
|
+
.pf-c-check.nested {
|
|
14
|
+
margin-top: 8px;
|
|
15
|
+
}
|
|
16
|
+
margin-left: 21px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.download-csv-select-all {
|
|
20
|
+
align-items: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.download-csv-modal {
|
|
24
|
+
.download-csv-modal-body {
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportCaseListCSV.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-table/ExportCaseListCSV.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExportCaseListCSV.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-table/ExportCaseListCSV.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAIzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAK7D,UAAU,MAAM;IACZ,uBAAuB,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC1D,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAID,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,eAmE9C"}
|
|
@@ -1,63 +1,11 @@
|
|
|
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
1
|
import { Button, Spinner } from '@patternfly/react-core';
|
|
12
|
-
import {
|
|
2
|
+
import { useFetch } from '@rh-support/components';
|
|
13
3
|
import { GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
14
|
-
import { downloadCSV, formatDateTime, toNewCaseTypeSwitcher } from '@rh-support/utils';
|
|
15
4
|
import React, { useContext, useState } from 'react';
|
|
16
5
|
import { Trans, useTranslation } from 'react-i18next';
|
|
17
|
-
import { SFDCKeys, SolrKeys } from '../../../enums/filters';
|
|
18
6
|
import { getCaseListFromSolr } from '../../../utils/caseListUtils';
|
|
19
|
-
import { createQueryForCSVDownload } from '../../../utils/caseSearchUtils';
|
|
20
7
|
import { CaseListFilterStateContext } from '../CaseListFilterContext';
|
|
21
|
-
|
|
22
|
-
{ label: 'Account number', key: SolrKeys.accountNumber },
|
|
23
|
-
{ label: 'Case number', key: SolrKeys.caseNumber },
|
|
24
|
-
{ label: 'Summary', key: SolrKeys.caseSummary },
|
|
25
|
-
{ label: 'Status', key: SolrKeys.status },
|
|
26
|
-
{ label: 'Severity', key: SolrKeys.severity },
|
|
27
|
-
{ label: 'Escalated', key: SolrKeys.escalation },
|
|
28
|
-
{ label: 'Owner', key: SolrKeys.contactName },
|
|
29
|
-
{ label: 'Product', key: SolrKeys.product },
|
|
30
|
-
{ label: 'Version', key: SolrKeys.version },
|
|
31
|
-
{ label: 'Created by', key: SolrKeys.createdBy },
|
|
32
|
-
{ label: 'Created date', key: SolrKeys.createdDate, transform: formatDateTime },
|
|
33
|
-
{ label: 'Modified by', key: SolrKeys.modifiedBy },
|
|
34
|
-
{ label: 'Modified date', key: SolrKeys.modifiedDate, transform: formatDateTime },
|
|
35
|
-
{ label: 'Uri', key: SolrKeys.uri },
|
|
36
|
-
{ label: 'Personal reference number', key: SolrKeys.alternateId },
|
|
37
|
-
{ label: 'Support type', key: SolrKeys.type },
|
|
38
|
-
{ label: 'Closed date', key: SolrKeys.caseClosedDate, transform: formatDateTime },
|
|
39
|
-
];
|
|
40
|
-
const csvHeadersSFDC = [
|
|
41
|
-
{ label: 'Account number', key: SFDCKeys.accountNumber },
|
|
42
|
-
{ label: 'Case number', key: SFDCKeys.caseNumber },
|
|
43
|
-
{ label: 'Summary', key: SFDCKeys.caseSummary },
|
|
44
|
-
{ label: 'Status', key: SFDCKeys.status },
|
|
45
|
-
{ label: 'Severity', key: SFDCKeys.severity },
|
|
46
|
-
{ label: 'Escalated', key: SFDCKeys.escalation },
|
|
47
|
-
{ label: 'Owner', key: SFDCKeys.ownerName },
|
|
48
|
-
{ label: 'Product', key: SFDCKeys.product },
|
|
49
|
-
{ label: 'Version', key: SFDCKeys.version },
|
|
50
|
-
{ label: 'Created by', key: SFDCKeys.createdBy },
|
|
51
|
-
{ label: 'Created date', key: SFDCKeys.createdDate, transform: formatDateTime },
|
|
52
|
-
{ label: 'Modified by', key: SFDCKeys.lastPublicUpdateDateBy },
|
|
53
|
-
{ label: 'Modified date', key: SFDCKeys.lastPublicUpdateDate, transform: formatDateTime },
|
|
54
|
-
{ label: 'Uri', key: SFDCKeys.uri },
|
|
55
|
-
{ label: 'Personal reference number', key: SFDCKeys.alternateId },
|
|
56
|
-
{ label: 'Support type', key: SFDCKeys.caseType },
|
|
57
|
-
{ label: 'Closed date', key: SFDCKeys.caseClosedDate, transform: formatDateTime },
|
|
58
|
-
];
|
|
59
|
-
const groupHeaderSOLR = { label: 'Group', key: SolrKeys.groupName };
|
|
60
|
-
const groupHeaderSFDC = { label: 'Group', key: SFDCKeys.groupName };
|
|
8
|
+
import DownloadCSVFileModal from './DownloadCSVFileModal';
|
|
61
9
|
const MAX_LIMIT = 1000;
|
|
62
10
|
export function ExportCaseListCSV(props) {
|
|
63
11
|
var _a, _b;
|
|
@@ -65,45 +13,13 @@ export function ExportCaseListCSV(props) {
|
|
|
65
13
|
const btnToolTip = t('Export the current list of cases to CSV. Please note that exporting a large number of cases may take a while.');
|
|
66
14
|
const maxLengthTooltip = t('Export the current list of cases to CSV. Please note that only the top {{limit}} cases will be exported and that it may take awhile.', { limit: MAX_LIMIT });
|
|
67
15
|
const currentFilteredCaseCount = (_b = (_a = props.currentFilteredCaseList) === null || _a === void 0 ? void 0 : _a.numFound) !== null && _b !== void 0 ? _b : 0;
|
|
68
|
-
const { isFetching
|
|
69
|
-
const [
|
|
70
|
-
const isFetchingCSVData = isFetching
|
|
16
|
+
const { isFetching } = useFetch(getCaseListFromSolr, { propgateErrors: true });
|
|
17
|
+
const [openUpdateSeverityModal, setOpenUpdateSeverityModal] = useState(false);
|
|
18
|
+
const isFetchingCSVData = isFetching;
|
|
71
19
|
const isBtnDisabled = isFetchingCSVData || currentFilteredCaseCount === 0;
|
|
72
20
|
let btnTitle = currentFilteredCaseCount >= MAX_LIMIT ? maxLengthTooltip : btnToolTip;
|
|
73
21
|
const filterState = useContext(CaseListFilterStateContext);
|
|
74
22
|
const { globalMetadataState: { loggedInUserRights, loggedInUsersAccount }, } = useContext(GlobalMetadataStateContext);
|
|
75
|
-
const isOrgAdmin = loggedInUserRights.data.isOrgAdmin();
|
|
76
|
-
// CSV For Secure Support Users
|
|
77
|
-
const onExportCSVClickSecureSupport = () => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
try {
|
|
79
|
-
const sfdcFilter = createQueryForCSVDownload(filterState, loggedInUserRights.data, loggedInUsersAccount.data);
|
|
80
|
-
setIsFetchingSFDC(true);
|
|
81
|
-
const sfdcResponse = yield publicApi.caseList.getCaseListFromSFDC(sfdcFilter, false, true);
|
|
82
|
-
setIsFetchingSFDC(false);
|
|
83
|
-
const headers = isOrgAdmin ? [...csvHeadersSFDC, groupHeaderSFDC] : csvHeadersSFDC;
|
|
84
|
-
// To map the values in csv to new support type
|
|
85
|
-
const updatedCsvData = sfdcResponse.cases.map((row) => (Object.assign(Object.assign({}, row), { caseType: toNewCaseTypeSwitcher(row.caseType) })));
|
|
86
|
-
downloadCSV(updatedCsvData, headers, 'CaseList.csv');
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
setIsFetchingSFDC(false);
|
|
90
|
-
ToastNotification.addDangerMessage(t('Could not export CSV'));
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
const partnerSearch = loggedInUserRights.data.isPartner();
|
|
94
|
-
// CSV For Normal Users
|
|
95
|
-
const onExportCSVClick = () => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
try {
|
|
97
|
-
const res = yield request(createQueryForCSVDownload(filterState, loggedInUserRights.data, loggedInUsersAccount.data), partnerSearch, null, loggedInUsersAccount.data.secureSupport);
|
|
98
|
-
const headers = isOrgAdmin ? [...csvHeadersSolr, groupHeaderSOLR] : csvHeadersSolr;
|
|
99
|
-
// To map the values in csv to new support type
|
|
100
|
-
const updatedCsvData = res.response.docs.map((row) => (Object.assign(Object.assign({}, row), { case_type: toNewCaseTypeSwitcher(row.case_type) })));
|
|
101
|
-
downloadCSV(updatedCsvData, headers, 'CaseList.csv');
|
|
102
|
-
}
|
|
103
|
-
catch (e) {
|
|
104
|
-
ToastNotification.addDangerMessage(t('Could not export CSV'));
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
23
|
// To show tooltip if export csv is disabled when SOLR is down
|
|
108
24
|
const getTooltipContent = () => {
|
|
109
25
|
let tooltipText = t('Export Cases');
|
|
@@ -112,8 +28,15 @@ export function ExportCaseListCSV(props) {
|
|
|
112
28
|
}
|
|
113
29
|
return tooltipText;
|
|
114
30
|
};
|
|
31
|
+
// To check if export csv button is disabled
|
|
32
|
+
const isExportButtonDisabled = isBtnDisabled || props.isExportCsvDisabled;
|
|
33
|
+
// To toggle download csv modal
|
|
34
|
+
const toggleDownloadCSVModal = () => {
|
|
35
|
+
setOpenUpdateSeverityModal((openUpdateSeverityModal) => !openUpdateSeverityModal);
|
|
36
|
+
};
|
|
115
37
|
return (React.createElement("span", { title: (props.isExportCsvDisabled && getTooltipContent()) || '' },
|
|
116
|
-
React.createElement(Button, { variant: "tertiary",
|
|
38
|
+
React.createElement(Button, { variant: "tertiary", onClick: toggleDownloadCSVModal, title: btnTitle, "data-tracking-id": "case-list-toolbar-export-csv", isDisabled: isExportButtonDisabled }, isFetchingCSVData ? (React.createElement(React.Fragment, null,
|
|
117
39
|
React.createElement(Trans, null, "Exporting CSV"),
|
|
118
|
-
React.createElement(Spinner, { size: "md", "aria-label": "loading", className: "export-csv-loader pf-v5-u-ml-xs" }))) : (React.createElement(Trans, null, "Export CSV")))
|
|
40
|
+
React.createElement(Spinner, { size: "md", "aria-label": "loading", className: "export-csv-loader pf-v5-u-ml-xs" }))) : (React.createElement(Trans, null, "Export CSV"))),
|
|
41
|
+
React.createElement(DownloadCSVFileModal, { filterState: filterState, loggedInUserRights: loggedInUserRights, loggedInUsersAccount: loggedInUsersAccount, isDisabled: isExportButtonDisabled, onModalshow: openUpdateSeverityModal, onClose: toggleDownloadCSVModal })));
|
|
119
42
|
}
|
|
@@ -202,5 +202,5 @@ export function SaveCaseSearchModal({ isModalOpen, modalToggle, isAdding, select
|
|
|
202
202
|
? 'error'
|
|
203
203
|
: 'default' })),
|
|
204
204
|
React.createElement(FormGroup, { label: React.createElement("span", { className: "save-for-later-label-query" }, t('Search and filter query')), isRequired: true, fieldId: "filter-query", className: "form-group pf-v5-u-mt-lg save-for-later-query" },
|
|
205
|
-
React.createElement(TextArea, { isRequired: true, validated: saveButtonIsClicked ? 'error' : 'default', type: "text", id: "filter-query", name: "filter-query", "aria-describedby": "filter-query-helper", value: getQueryStr(), isDisabled: true, resizeOrientation: "vertical" })))));
|
|
205
|
+
React.createElement(TextArea, { isRequired: true, validated: saveButtonIsClicked && isEmpty(getQueryStr()) ? 'error' : 'default', type: "text", id: "filter-query", name: "filter-query", "aria-describedby": "filter-query-helper", value: getQueryStr(), isDisabled: true, resizeOrientation: "vertical" })))));
|
|
206
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAdvanceSearchParser.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-search/useAdvanceSearchParser.tsx"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAAE,MAAM,EAAE;;CAAA;yBASzB,MAAM;6BAIF,MAAM;;EA6LzC"}
|
|
1
|
+
{"version":3,"file":"useAdvanceSearchParser.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-search/useAdvanceSearchParser.tsx"],"names":[],"mappings":";AASA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAAE,MAAM,EAAE;;CAAA;yBASzB,MAAM;6BAIF,MAAM;;EA6LzC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IPfeCollapse } from '@rh-support/types/pfe/pfe-collapse';
|
|
2
1
|
import { RouteComponentProps } from 'react-router-dom';
|
|
3
2
|
export interface ICasesRouteURLParams {
|
|
4
3
|
}
|
|
@@ -10,19 +9,13 @@ declare global {
|
|
|
10
9
|
interface Window {
|
|
11
10
|
sessionjs: any;
|
|
12
11
|
MSInputMethodContext: any;
|
|
13
|
-
chrometwo_require: (component: string[], callback: (...params: any[]) => any) => any;
|
|
14
12
|
portal: any;
|
|
15
13
|
Raven: any;
|
|
16
|
-
chrometwo_ready: any;
|
|
17
14
|
seVersionInfo: {
|
|
18
15
|
packageVersion: string;
|
|
19
16
|
hydrajs: string;
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
|
-
namespace JSX {
|
|
23
|
-
interface IntrinsicElements extends IPfeCollapse {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
19
|
interface Document {
|
|
27
20
|
documentMode: any;
|
|
28
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAmB,mBAAmB,EAAU,MAAM,kBAAkB,CAAC;AAMhF,MAAM,WAAW,oBAAoB;CAAG;AACxC,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;IACtD,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,EAAE,GAAG,CAAC;QACf,oBAAoB,EAAE,GAAG,CAAC;QAC1B,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,aAAa,EAAE;YACX,cAAc,EAAE,MAAM,CAAC;YACvB,OAAO,EAAE,MAAM,CAAC;SACnB,CAAC;KACL;IAED,UAAU,QAAQ;QACd,YAAY,EAAE,GAAG,CAAC;KACrB;CACJ;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,eAiBlC"}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { CustomElements, requireCustomElement } from '@rh-support/utils';
|
|
2
1
|
import React, { useEffect } from 'react';
|
|
3
2
|
import { Redirect, Route, Switch } from 'react-router-dom';
|
|
4
3
|
import RouteUtils from '../utils/routeUtils';
|
|
5
4
|
import { CaseList } from './case-list/CaseList';
|
|
6
5
|
import { PartnerEscalation } from './escalations/PartnerEscalation';
|
|
7
|
-
requireCustomElement([
|
|
8
|
-
{
|
|
9
|
-
element: CustomElements.pfeCollapse,
|
|
10
|
-
requireCb: () => require('@patternfly/pfe-collapse'),
|
|
11
|
-
},
|
|
12
|
-
]);
|
|
13
6
|
export function Cases(props) {
|
|
14
7
|
RouteUtils.casesBasePath = props.basePath || '';
|
|
15
8
|
// Loading app metadata
|