From 481e7a986366e4d78b9fe6af5cd4a0e89604b461 Mon Sep 17 00:00:00 2001 From: MattWong-ca Date: Fri, 6 Dec 2024 23:39:49 -0500 Subject: [PATCH] Modal UX working, need to clean up code --- src/bundles/files/actions.js | 27 +++++++++++--- src/files/FilesPage.js | 2 + src/files/file-input/FileInput.js | 2 +- src/files/modals/Modals.js | 4 +- .../bulk-import-modal/BulkImportModal.js | 37 +++++++++++-------- 5 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/bundles/files/actions.js b/src/bundles/files/actions.js index 2626a3f89..bc8fb7716 100644 --- a/src/bundles/files/actions.js +++ b/src/bundles/files/actions.js @@ -405,15 +405,32 @@ const actions = () => ({ * @param {string} root - Destination directory in IPFS */ doFilesAddBulkCid: (source, root) => spawn(ACTIONS.ADD_BY_PATH, async function * (ipfs, { store }) { + console.log('Action parameters:', { source, root }) + console.log('Arguments:', arguments) + ensureMFS(store) - console.log('doFilesAddBulkCid source', source) - if (source.length !== 1) { - throw new Error('Please provide exactly one text file') + // Ensure source is properly passed + if (!source) { + throw new Error('Source is required') + } + + // If source is passed as first argument of spawn callback + const actualSource = Array.isArray(source) ? source : arguments[0] + console.log('Actual source:', actualSource) + + if (!Array.isArray(actualSource)) { + throw new Error('Source must be an array') + } + + const fileStream = actualSource[0] + console.log('fileStream:', fileStream) + + if (!fileStream || !fileStream.content) { + throw new Error('Invalid file format') } - // Read the text file content - const file = source[0] + const file = fileStream const content = await new Response(file.content).text() const lines = content.split('\n').map(line => line.trim()).filter(Boolean) diff --git a/src/files/FilesPage.js b/src/files/FilesPage.js index e36cf8406..7f3e7b29e 100644 --- a/src/files/FilesPage.js +++ b/src/files/FilesPage.js @@ -73,7 +73,9 @@ const FilesPage = ({ } const onBulkCidImport = (raw, root = '') => { + console.log('FilesPage onBulkCidImport:', { raw, root, filesPath: files.path }) if (root === '') root = files.path + console.log('Calling doFilesAddBulkCid with:', { raw, root }) doFilesAddBulkCid(raw, root) } diff --git a/src/files/file-input/FileInput.js b/src/files/file-input/FileInput.js index e73aeca9b..332b605e4 100644 --- a/src/files/file-input/FileInput.js +++ b/src/files/file-input/FileInput.js @@ -111,7 +111,7 @@ class FileInput extends React.Component { {t('newFolder')}