X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/67d77b206ebee7c776bd4d7dbc112ebb0c7ba800..5e12403f4dcfe39eda79c256a94ceadc90458a99:/src/views-components/context-menu/actions/download-action.tsx diff --git a/src/views-components/context-menu/actions/download-action.tsx b/src/views-components/context-menu/actions/download-action.tsx index 86694c8b..352f84bd 100644 --- a/src/views-components/context-menu/actions/download-action.tsx +++ b/src/views-components/context-menu/actions/download-action.tsx @@ -2,11 +2,11 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; +import React from 'react'; import { ListItemIcon, ListItemText, ListItem } from '@material-ui/core'; import { DownloadIcon } from '../../../components/icon/icon'; -import * as JSZip from 'jszip'; -import * as FileSaver from 'file-saver'; +import JSZip from 'jszip'; +import FileSaver from 'file-saver'; import axios from 'axios'; export const DownloadAction = (props: { href?: any, download?: any, onClick?: () => void, kind?: string, currentCollectionUuid?: string; }) => { @@ -21,27 +21,26 @@ export const DownloadAction = (props: { href?: any, download?: any, onClick?: () return letter !== '/'; }); - filteredFileUrls - .map((href: string) => { - axios.get(href).then(response => response).then(({ data }: any) => { - const splittedByDot = href.split('.'); - if (splittedByDot[splittedByDot.length - 1] !== 'json') { - if (filteredFileUrls.length === id) { - zip.file(download[id - 1], data); - zip.generateAsync({ type: 'blob' }).then((content) => { - FileSaver.saveAs(content, `download-${props.currentCollectionUuid}.zip`); - }); - } else { - zip.file(download[id - 1], data); - zip.generateAsync({ type: 'blob' }); - } + filteredFileUrls.forEach((href: string) => { + axios.get(href).then(response => response).then(({ data }: any) => { + const splittedByDot = href.split('.'); + if (splittedByDot[splittedByDot.length - 1] !== 'json') { + if (filteredFileUrls.length === id) { + zip.file(download[id - 1], data); + zip.generateAsync({ type: 'blob' }).then((content) => { + FileSaver.saveAs(content, `download-${props.currentCollectionUuid}.zip`); + }); } else { - zip.file(download[id - 1], JSON.stringify(data)); + zip.file(download[id - 1], data); zip.generateAsync({ type: 'blob' }); } - id++; - }); + } else { + zip.file(download[id - 1], JSON.stringify(data)); + zip.generateAsync({ type: 'blob' }); + } + id++; }); + }); }; return props.href || props.kind === 'files'