Skip to content

Commit

Permalink
UIEXPMGR-106 parametrize download endpoint only fro multifiles jobs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaSedyx authored Apr 15, 2024
1 parent cb720d8 commit 8ed9948
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/common/components/ExportJobId/ExportJobId.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import { TextLink } from '@folio/stripes/components';

import { useExportManagerPerms, useSecureDownload } from '../../hooks';
import { EXPORTED_JOB_TYPES } from '../../constants';
import { MULTIPLE_EXPORTED_JOB_TYPES, EXPORTED_JOB_TYPES } from '../../constants';
import { BULK_ENTITY_TYPES } from '../../../ExportJobs/constants';

export const ExportJobId = ({ job }) => {
Expand Down Expand Up @@ -32,7 +32,7 @@ export const ExportJobId = ({ job }) => {
e.stopPropagation();

if (EXPORTED_JOB_TYPES.includes(jobType) && fileNames) {
downloadSecurely(fileNames);
downloadSecurely(fileNames, MULTIPLE_EXPORTED_JOB_TYPES.includes(jobType));
} else {
files.forEach((file, index) => {
if (file && index !== 2) {
Expand Down
5 changes: 4 additions & 1 deletion src/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ export const EXPORT_JOB_STATUS_OPTIONS = Object.values(EXPORT_JOB_STATUSES).map(

export const EXPORT_CONFIGS_API = 'data-export-spring/configs';
export const EXPORT_JOBS_API = 'data-export-spring/jobs';
export const EXPORTED_JOB_TYPES = [
export const MULTIPLE_EXPORTED_JOB_TYPES = [
'BULK_EDIT_IDENTIFIERS',
'BULK_EDIT_QUERY',
'BULK_EDIT_UPDATE',
];
export const EXPORTED_JOB_TYPES = [
...MULTIPLE_EXPORTED_JOB_TYPES,
'CIRCULATION_LOG',
'E_HOLDINGS',
'AUTH_HEADINGS_UPDATES',
Expand Down
10 changes: 5 additions & 5 deletions src/common/hooks/useSecureDownload/useSecureDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export const useSecureDownload = (jobId) => {
const ky = useOkapiKy();
const showCallout = useShowCallout();

const downloadSingleFile = async (fileName) => {
const key = encodeURIComponent(fileName);
const downloadSingleFile = async (fileName, parameterized) => {
const key = parameterized ? `key=${encodeURIComponent(fileName)}` : '';

return ky.get(`${EXPORT_JOBS_API}/${jobId}/download?key=${key}`, {
return ky.get(`${EXPORT_JOBS_API}/${jobId}/download?${key}`, {
headers: { accept: 'application/octet-stream' },
})
.blob()
Expand All @@ -31,8 +31,8 @@ export const useSecureDownload = (jobId) => {
});
};

const download = async (fileNames) => {
return Promise.all(fileNames.map(downloadSingleFile));
const download = async (fileNames, parameterized) => {
return Promise.all(fileNames.map((fileName) => downloadSingleFile(fileName, parameterized)));
}

return { download };
Expand Down

0 comments on commit 8ed9948

Please sign in to comment.