From 3e1e6f71648714f72213d1f89d6d49a6346e41a1 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sun, 29 Nov 2020 21:43:31 +0100 Subject: [PATCH] import download fixes --- packages/web/src/impexp/ImportExportConfigurator.js | 9 ++++++--- packages/web/src/impexp/createImpExpScript.js | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/web/src/impexp/ImportExportConfigurator.js b/packages/web/src/impexp/ImportExportConfigurator.js index 6ab301b1..a8e4c299 100644 --- a/packages/web/src/impexp/ImportExportConfigurator.js +++ b/packages/web/src/impexp/ImportExportConfigurator.js @@ -109,11 +109,12 @@ function getFileFilters(extensions, storageType) { return res; } -async function addFileToSourceListDefault({ fileName, shortName }, newSources, newValues) { +async function addFileToSourceListDefault({ fileName, shortName, isDownload }, newSources, newValues) { const sourceName = shortName; newSources.push(sourceName); newValues[`sourceFile_${sourceName}`] = { fileName, + isDownload, }; } @@ -385,7 +386,7 @@ function SourceName({ name }) { ); }; const doChangeUrl = (url) => { - setFieldValue(`sourceFile_${name}`, { fileName: url }); + setFieldValue(`sourceFile_${name}`, { fileName: url, isDownload: true }); }; const handleChangeUrl = () => { showModal((modalState) => ( @@ -455,6 +456,8 @@ export default function ImportExportConfigurator({ uploadedFile = undefined, onC }, []); const supportsPreview = !!findFileFormat(extensions, values.sourceStorageType); + const previewFileName = + previewSource && values[`sourceFile_${previewSource}`] && values[`sourceFile_${previewSource}`].fileName; const handleChangePreviewSource = async () => { if (previewSource && supportsPreview) { @@ -467,7 +470,7 @@ export default function ImportExportConfigurator({ uploadedFile = undefined, onC React.useEffect(() => { handleChangePreviewSource(); - }, [previewSource, supportsPreview]); + }, [previewSource, supportsPreview, previewFileName]); const oldValues = React.useRef({}); React.useEffect(() => { diff --git a/packages/web/src/impexp/createImpExpScript.js b/packages/web/src/impexp/createImpExpScript.js index 1df26395..47d40474 100644 --- a/packages/web/src/impexp/createImpExpScript.js +++ b/packages/web/src/impexp/createImpExpScript.js @@ -68,7 +68,7 @@ function getSourceExpr(extensions, sourceName, values, sourceConnection, sourceD return [ format.readerFunc, { - ...sourceFile, + ..._.omit(sourceFile, ['isDownload']), ...extractApiParameters(values, 'source', format), }, ];