@rh-support/cases 2.1.41 → 2.1.42
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":"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;
|
|
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;AAkBlE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AASxD,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,eA8ZzD"}
|
|
@@ -9,11 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import './DownloadCSVFileModal.scss';
|
|
11
11
|
import { publicApi } from '@cee-eng/hydrajs';
|
|
12
|
-
import { Button, Checkbox, Form, FormGroup, Grid, GridItem, InputGroup, Modal, ModalVariant, Spinner, TextInput, } from '@patternfly/react-core';
|
|
12
|
+
import { Button, Checkbox, Form, FormGroup, Grid, GridItem, InputGroup, Modal, ModalVariant, Spinner, TextInput, ValidatedOptions, } from '@patternfly/react-core';
|
|
13
13
|
import DownloadIcon from '@patternfly/react-icons/dist/js/icons/download-icon';
|
|
14
14
|
import TimesCircleIcon from '@patternfly/react-icons/dist/js/icons/times-circle-icon';
|
|
15
15
|
import { ToastNotification, useFetch } from '@rh-support/components';
|
|
16
16
|
import { downloadCSV, formatDateTime, toNewCaseTypeSwitcher } from '@rh-support/utils';
|
|
17
|
+
import { isEmpty } from 'lodash';
|
|
17
18
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
18
19
|
import { useTranslation } from 'react-i18next';
|
|
19
20
|
import { SFDCKeys, SolrKeys } from '../../../enums/filters';
|
|
@@ -31,7 +32,7 @@ export default function DownloadCSVFileModal(props) {
|
|
|
31
32
|
const { onClose, onModalshow, isDisabled, loggedInUserRights, loggedInUsersAccount, filterState } = props;
|
|
32
33
|
const { t } = useTranslation();
|
|
33
34
|
const { isFetching, request } = useFetch(getCaseListFromSolr, { propgateErrors: true });
|
|
34
|
-
const [downloadCSVFileName, setDownloadCSVFileName] = useState('');
|
|
35
|
+
const [downloadCSVFileName, setDownloadCSVFileName] = useState('CaseList.csv');
|
|
35
36
|
const [isFetchingSFDC, setIsFetchingSFDC] = useState(false);
|
|
36
37
|
const [generatedCsvHeaders, setGeneratedCsvHeaders] = useState([]);
|
|
37
38
|
const [checkboxes, setCheckboxes] = useState({
|
|
@@ -48,6 +49,7 @@ export default function DownloadCSVFileModal(props) {
|
|
|
48
49
|
caseClosedDate: false,
|
|
49
50
|
group: false,
|
|
50
51
|
});
|
|
52
|
+
const [isSaveClicked, setIsSavedClicked] = useState(false);
|
|
51
53
|
function getKey(key, isSecureSupport) {
|
|
52
54
|
return isSecureSupport ? SFDCKeys[key] : SolrKeys[key];
|
|
53
55
|
}
|
|
@@ -151,6 +153,8 @@ export default function DownloadCSVFileModal(props) {
|
|
|
151
153
|
const splitExtensionName = downloadCSVFileName.split('.')[0].replace(/ +/g, ''); // To split and trim value before saving PDF
|
|
152
154
|
const onCancel = () => {
|
|
153
155
|
onClose && onClose();
|
|
156
|
+
setIsSavedClicked(false);
|
|
157
|
+
setDownloadCSVFileName('CaseList.csv');
|
|
154
158
|
};
|
|
155
159
|
const handleCSVFileNameChange = (value) => {
|
|
156
160
|
setDownloadCSVFileName(value);
|
|
@@ -166,12 +170,16 @@ export default function DownloadCSVFileModal(props) {
|
|
|
166
170
|
// For SOLR
|
|
167
171
|
const onExportCSVClick = () => __awaiter(this, void 0, void 0, function* () {
|
|
168
172
|
try {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
setIsSavedClicked(true);
|
|
174
|
+
if (!isEmpty(splitExtensionName)) {
|
|
175
|
+
const res = yield request(createQueryForCSVDownload(filterState, loggedInUserRights.data, loggedInUsersAccount.data), partnerSearch, null, loggedInUsersAccount.data.secureSupport);
|
|
176
|
+
// To map the values in csv to new support type
|
|
177
|
+
const updatedCsvData = res.response.docs.map((row) => (Object.assign(Object.assign({}, row), { case_type: toNewCaseTypeSwitcher(row.case_type) })));
|
|
178
|
+
downloadCSV(updatedCsvData, generatedCsvHeaders, splitExtensionName ? `${splitExtensionName}.csv` : 'CaseList.csv');
|
|
179
|
+
onCancel();
|
|
180
|
+
ToastNotification.addSuccessMessage(t('File downloaded successfully!'));
|
|
181
|
+
setIsSavedClicked(false);
|
|
182
|
+
}
|
|
175
183
|
}
|
|
176
184
|
catch (e) {
|
|
177
185
|
onCancel();
|
|
@@ -181,15 +189,19 @@ export default function DownloadCSVFileModal(props) {
|
|
|
181
189
|
// For SFDC
|
|
182
190
|
const onExportCSVClickSecureSupport = () => __awaiter(this, void 0, void 0, function* () {
|
|
183
191
|
try {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
setIsSavedClicked(true);
|
|
193
|
+
if (!isEmpty(splitExtensionName)) {
|
|
194
|
+
const sfdcFilter = createQueryForCSVDownload(filterState, loggedInUserRights.data, loggedInUsersAccount.data);
|
|
195
|
+
setIsFetchingSFDC(true);
|
|
196
|
+
const sfdcResponse = yield publicApi.caseList.getCaseListFromSFDC(sfdcFilter, false, true);
|
|
197
|
+
setIsFetchingSFDC(false);
|
|
198
|
+
// To map the values in csv to new support type
|
|
199
|
+
const updatedCsvData = sfdcResponse.cases.map((row) => (Object.assign(Object.assign({}, row), { caseType: toNewCaseTypeSwitcher(row.caseType) })));
|
|
200
|
+
downloadCSV(updatedCsvData, csvHeadersSFDC, splitExtensionName ? `${splitExtensionName}.csv` : 'CaseList.csv');
|
|
201
|
+
onCancel();
|
|
202
|
+
ToastNotification.addSuccessMessage(t('File downloaded successfully!'));
|
|
203
|
+
setIsSavedClicked(false);
|
|
204
|
+
}
|
|
193
205
|
}
|
|
194
206
|
catch (e) {
|
|
195
207
|
setIsFetchingSFDC(false);
|
|
@@ -237,9 +249,11 @@ export default function DownloadCSVFileModal(props) {
|
|
|
237
249
|
// CSV Modal Body
|
|
238
250
|
const downloadCSVModalBody = () => {
|
|
239
251
|
return (React.createElement(Form, { className: "download-csv-modal-body" },
|
|
240
|
-
React.createElement(FormGroup, { label: t('File name'), fieldId: "download-csv-file-name" },
|
|
252
|
+
React.createElement(FormGroup, { label: t('File name'), fieldId: "download-csv-file-name", isRequired: true },
|
|
241
253
|
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)
|
|
254
|
+
React.createElement(TextInput, { type: "text", id: "csv-file-name", name: "download-csv-file-name", value: downloadCSVFileName, onChange: (_event, value) => handleCSVFileNameChange(value), placeholder: t('Enter a file name'), validated: isSaveClicked && isEmpty(splitExtensionName)
|
|
255
|
+
? ValidatedOptions.error
|
|
256
|
+
: ValidatedOptions.default, isRequired: true }),
|
|
243
257
|
React.createElement(Button, { variant: "plain", onClick: clearDownloadCSVFileName, icon: React.createElement(TimesCircleIcon, null) }))),
|
|
244
258
|
React.createElement(FormGroup, { label: t('Please select the fields you want included in your download.'), fieldId: "download-csv-file-fields-select" },
|
|
245
259
|
React.createElement(Grid, null,
|
|
@@ -266,7 +280,7 @@ export default function DownloadCSVFileModal(props) {
|
|
|
266
280
|
};
|
|
267
281
|
// Download CSV modal buttons
|
|
268
282
|
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')),
|
|
283
|
+
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: (isSaveClicked && isEmpty(splitExtensionName)) || isDisabled || isFetchingCSVData }, t('Download')),
|
|
270
284
|
React.createElement(Button, { key: "back", variant: "secondary", onClick: onCancel, isDisabled: isDisabled || isFetchingCSVData, "data-tracking-id": "download-csv-modal-cancel" }, t('Cancel')),
|
|
271
285
|
];
|
|
272
286
|
// To handle select all checkbox when any of the column checkbox is checked or unchecked
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/cases",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.42",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"defaults and supports es6-module",
|
|
91
91
|
"maintained node versions"
|
|
92
92
|
],
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "9edf1a3bda045f22d2d5187c7a3b154787b9c472"
|
|
94
94
|
}
|