@rh-support/cases 2.1.48 → 2.1.49

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;AAkBlE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAGxD,OAAO,KAAuC,MAAM,OAAO,CAAC;AAM5D,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;IAClC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC7B;AAoBD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,KAAK,EAAE,MAAM,qBAuazD"}
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;AAGxD,OAAO,KAAuC,MAAM,OAAO,CAAC;AAM5D,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;IAClC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC7B;AAoBD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,KAAK,EAAE,MAAM,qBAgazD"}
@@ -42,7 +42,6 @@ export default function DownloadCSVFileModal(props) {
42
42
  const { isFetching, request } = useFetch(getCaseListFromSolr, { propgateErrors: true });
43
43
  const [downloadCSVFileName, setDownloadCSVFileName] = useState('CaseList.csv');
44
44
  const [isFetchingSFDC, setIsFetchingSFDC] = useState(false);
45
- const [generatedCsvHeaders, setGeneratedCsvHeaders] = useState([]);
46
45
  const [checkboxes, setCheckboxes] = useState({
47
46
  selectAll: false,
48
47
  ownerName: false,
@@ -61,85 +60,84 @@ export default function DownloadCSVFileModal(props) {
61
60
  function getKey(key, isSecureSupport) {
62
61
  return isSecureSupport ? SFDCKeys[key] : SolrKeys[key];
63
62
  }
63
+ const isSecureSupportUser = loggedInUsersAccount.data.secureSupport;
64
64
  const headerDefinitions = useMemo(() => [
65
65
  {
66
66
  checkbox: checkboxes.ownerName,
67
- key: getKey('ownerName', loggedInUsersAccount.data.secureSupport),
67
+ key: getKey('ownerName', isSecureSupportUser),
68
68
  label: 'Owner name',
69
69
  },
70
70
  {
71
71
  checkbox: checkboxes.severity,
72
- key: getKey('severity', loggedInUsersAccount.data.secureSupport),
72
+ key: getKey('severity', isSecureSupportUser),
73
73
  label: 'Severity',
74
74
  },
75
75
  {
76
76
  checkbox: checkboxes.createdBy,
77
- key: getKey('createdBy', loggedInUsersAccount.data.secureSupport),
77
+ key: getKey('createdBy', isSecureSupportUser),
78
78
  label: 'Created by',
79
79
  },
80
80
  {
81
81
  checkbox: checkboxes.createdBy,
82
- key: getKey('createdDate', loggedInUsersAccount.data.secureSupport),
82
+ key: getKey('createdDate', isSecureSupportUser),
83
83
  label: 'Created date',
84
84
  transform: formatDateTime,
85
85
  },
86
86
  {
87
87
  checkbox: checkboxes.accountNumber,
88
- key: getKey('accountNumber', loggedInUsersAccount.data.secureSupport),
88
+ key: getKey('accountNumber', isSecureSupportUser),
89
89
  label: 'Account number',
90
90
  },
91
91
  {
92
92
  checkbox: checkboxes.type,
93
- key: getKey('type', loggedInUsersAccount.data.secureSupport),
93
+ key: getKey(isSecureSupportUser ? 'caseType' : 'type', isSecureSupportUser),
94
94
  label: 'Support type',
95
95
  },
96
96
  {
97
97
  checkbox: checkboxes.modifiedBy,
98
- key: getKey('modifiedBy', loggedInUsersAccount.data.secureSupport),
98
+ key: getKey('modifiedBy', isSecureSupportUser),
99
99
  label: 'Modified by',
100
100
  },
101
101
  {
102
102
  checkbox: checkboxes.modifiedBy,
103
- key: getKey('modifiedDate', loggedInUsersAccount.data.secureSupport),
103
+ key: getKey('modifiedDate', isSecureSupportUser),
104
104
  label: 'Modified date',
105
105
  transform: formatDateTime,
106
106
  },
107
107
  {
108
108
  checkbox: checkboxes.status,
109
- key: getKey('status', loggedInUsersAccount.data.secureSupport),
109
+ key: getKey('status', isSecureSupportUser),
110
110
  label: 'Status',
111
111
  },
112
112
  {
113
113
  checkbox: checkboxes.productVersion,
114
- key: getKey('product', loggedInUsersAccount.data.secureSupport),
114
+ key: getKey('product', isSecureSupportUser),
115
115
  label: 'Product',
116
116
  },
117
117
  {
118
118
  checkbox: checkboxes.productVersion,
119
- key: getKey('version', loggedInUsersAccount.data.secureSupport),
119
+ key: getKey('version', isSecureSupportUser),
120
120
  label: 'Version',
121
121
  },
122
122
  {
123
123
  checkbox: checkboxes.alternateId,
124
- key: getKey('alternateId', loggedInUsersAccount.data.secureSupport),
124
+ key: getKey('alternateId', isSecureSupportUser),
125
125
  label: 'Alternate ID',
126
126
  },
127
127
  {
128
128
  checkbox: checkboxes.caseClosedDate,
129
- key: getKey('caseClosedDate', loggedInUsersAccount.data.secureSupport),
129
+ key: getKey('caseClosedDate', isSecureSupportUser),
130
130
  label: 'Closed date',
131
131
  transform: formatDateTime,
132
132
  },
133
133
  {
134
134
  checkbox: checkboxes.group,
135
- key: getKey('groupName', loggedInUsersAccount.data.secureSupport),
135
+ key: getKey('groupName', isSecureSupportUser),
136
136
  label: 'Group',
137
137
  },
138
- ], [checkboxes, loggedInUsersAccount.data.secureSupport]);
139
- useEffect(() => {
140
- const updatedCsvHeaders = loggedInUsersAccount.data.secureSupport
141
- ? csvHeadersSFDC
142
- : csvHeadersSolr;
138
+ ], [checkboxes, isSecureSupportUser]);
139
+ const getHeaders = () => {
140
+ const updatedCsvHeaders = isSecureSupportUser ? csvHeadersSFDC : csvHeadersSolr;
143
141
  headerDefinitions.forEach((headerDefinition) => {
144
142
  const { checkbox, key, label, transform } = headerDefinition;
145
143
  const index = updatedCsvHeaders.findIndex((header) => header.key === key);
@@ -154,9 +152,8 @@ export default function DownloadCSVFileModal(props) {
154
152
  }
155
153
  }
156
154
  });
157
- setGeneratedCsvHeaders(updatedCsvHeaders);
158
- }, [loggedInUsersAccount.data.secureSupport, checkboxes, headerDefinitions]);
159
- const isOrgAdmin = loggedInUserRights.data.isOrgAdmin();
155
+ return updatedCsvHeaders;
156
+ };
160
157
  const isFetchingCSVData = isFetching || isFetchingSFDC;
161
158
  const partnerSearch = loggedInUserRights.data.hasManagedAccounts();
162
159
  const splitExtensionName = downloadCSVFileName.split('.')[0].replace(/ +/g, ''); // To split and trim value before saving PDF
@@ -174,8 +171,6 @@ export default function DownloadCSVFileModal(props) {
174
171
  const handleCheckboxChange = (key) => {
175
172
  setCheckboxes((prevCheckboxes) => (Object.assign(Object.assign({}, prevCheckboxes), { [key]: !prevCheckboxes[key] })));
176
173
  };
177
- // Group header for SOLR
178
- const groupHeaderSOLR = { label: 'Group', key: SolrKeys.groupName };
179
174
  const checkboxValues = Object.values(checkboxes).slice(1); // as we don't want selectAll value
180
175
  const allCheckBoxNotSelected = checkboxValues.includes(false);
181
176
  // For SOLR
@@ -184,11 +179,10 @@ export default function DownloadCSVFileModal(props) {
184
179
  setIsSavedClicked(true);
185
180
  if (!isEmpty(splitExtensionName)) {
186
181
  const query = createQueryForCSVDownload(filterState, loggedInUserRights.data, loggedInUsersAccount.data, selectedCases);
187
- const res = yield request(query, partnerSearch, null, loggedInUsersAccount.data.secureSupport);
188
- const headers = isOrgAdmin ? [...csvHeadersSolr, groupHeaderSOLR] : generatedCsvHeaders;
182
+ const res = yield request(query, partnerSearch, null, isSecureSupportUser);
189
183
  // To map the values in csv to new support type
190
184
  const updatedCsvData = res.response.docs.map((row) => (Object.assign(Object.assign({}, row), { case_type: toNewCaseTypeSwitcher(row.case_type), case_link: `https://${window.location.host}${window.location.pathname}/#/case/${row.case_number}` })));
191
- downloadCSV(updatedCsvData, headers, splitExtensionName ? `${splitExtensionName}.csv` : 'CaseList.csv');
185
+ downloadCSV(updatedCsvData, getHeaders(), splitExtensionName ? `${splitExtensionName}.csv` : 'CaseList.csv');
192
186
  onCancel();
193
187
  ToastNotification.addSuccessMessage(t('File downloaded successfully!'));
194
188
  setIsSavedClicked(false);
@@ -199,8 +193,6 @@ export default function DownloadCSVFileModal(props) {
199
193
  ToastNotification.addDangerMessage(t('File could not be downloaded. Please try again! '));
200
194
  }
201
195
  });
202
- // Group header for SFDC
203
- const groupHeaderSFDC = { label: 'Group', key: SFDCKeys.groupName };
204
196
  // For SFDC
205
197
  const onExportCSVClickSecureSupport = () => __awaiter(this, void 0, void 0, function* () {
206
198
  try {
@@ -210,10 +202,9 @@ export default function DownloadCSVFileModal(props) {
210
202
  setIsFetchingSFDC(true);
211
203
  const sfdcResponse = yield publicApi.caseList.getCaseListFromSFDC(sfdcFilter, false, true);
212
204
  setIsFetchingSFDC(false);
213
- const headers = isOrgAdmin ? [...csvHeadersSFDC, groupHeaderSFDC] : csvHeadersSFDC;
214
205
  // To map the values in csv to new support type
215
- const updatedCsvData = sfdcResponse.cases.map((row) => (Object.assign(Object.assign({}, row), { caseType: toNewCaseTypeSwitcher(row.caseType) })));
216
- downloadCSV(updatedCsvData, headers, splitExtensionName ? `${splitExtensionName}.csv` : 'CaseList.csv');
206
+ const updatedCsvData = sfdcResponse.cases.map((row) => (Object.assign(Object.assign({}, row), { caseType: toNewCaseTypeSwitcher(row.caseType), case_link: `https://${window.location.host}${window.location.pathname}/#/case/${row.caseNumber}` })));
207
+ downloadCSV(updatedCsvData, getHeaders(), splitExtensionName ? `${splitExtensionName}.csv` : 'CaseList.csv');
217
208
  onCancel();
218
209
  ToastNotification.addSuccessMessage(t('File downloaded successfully!'));
219
210
  setIsSavedClicked(false);
@@ -288,7 +279,7 @@ export default function DownloadCSVFileModal(props) {
288
279
  };
289
280
  // Download CSV modal buttons
290
281
  const modalActions = [
291
- 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')),
282
+ 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: isSecureSupportUser ? onExportCSVClickSecureSupport : onExportCSVClick, isDisabled: (isSaveClicked && isEmpty(splitExtensionName)) || isDisabled || isFetchingCSVData }, t('Download')),
292
283
  React.createElement(Button, { key: "back", variant: "secondary", onClick: onCancel, isDisabled: isDisabled || isFetchingCSVData, "data-tracking-id": "download-csv-modal-cancel" }, t('Cancel')),
293
284
  ];
294
285
  // 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.48",
3
+ "version": "2.1.49",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -26,7 +26,7 @@
26
26
  "lib/**/*"
27
27
  ],
28
28
  "peerDependencies": {
29
- "@cee-eng/hydrajs": "4.17.1",
29
+ "@cee-eng/hydrajs": "4.17.3",
30
30
  "@patternfly/patternfly": "5.1.0",
31
31
  "@patternfly/react-core": "5.1.1",
32
32
  "@patternfly/react-table": "5.1.1",
@@ -39,15 +39,15 @@
39
39
  "solr-query-builder": "1.0.1"
40
40
  },
41
41
  "dependencies": {
42
- "@cee-eng/hydrajs": "4.17.1",
42
+ "@cee-eng/hydrajs": "4.17.3",
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.38",
47
- "@rh-support/react-context": "2.1.41",
46
+ "@rh-support/components": "2.1.39",
47
+ "@rh-support/react-context": "2.1.42",
48
48
  "@rh-support/types": "2.0.3",
49
- "@rh-support/user-permissions": "2.1.27",
50
- "@rh-support/utils": "2.1.19",
49
+ "@rh-support/user-permissions": "2.1.28",
50
+ "@rh-support/utils": "2.1.20",
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": "19f893dca537531c7f828ffa92daf8fe40649d78"
99
+ "gitHead": "0e07f257ebbb2d665193b3bf245666bf03df10cd"
100
100
  }