diff --git a/src/bundles/files/actions.js b/src/bundles/files/actions.js index c8e8d5520..2626a3f89 100644 --- a/src/bundles/files/actions.js +++ b/src/bundles/files/actions.js @@ -406,6 +406,7 @@ const actions = () => ({ */ doFilesAddBulkCid: (source, root) => spawn(ACTIONS.ADD_BY_PATH, async function * (ipfs, { store }) { ensureMFS(store) + console.log('doFilesAddBulkCid source', source) if (source.length !== 1) { throw new Error('Please provide exactly one text file') diff --git a/src/files/file-input/FileInput.js b/src/files/file-input/FileInput.js index 7b6cf6650..e73aeca9b 100644 --- a/src/files/file-input/FileInput.js +++ b/src/files/file-input/FileInput.js @@ -50,8 +50,10 @@ class FileInput extends React.Component { input.value = null } + // Old implementation that worked onBulkCidInputChange = (input) => async () => { console.log('onBulkCidInputChange', input) + console.log('onBulkCidInputChange files', input.files) this.props.onBulkCidImport(normalizeFiles(input.files)) input.value = null } @@ -139,6 +141,7 @@ class FileInput extends React.Component { ref={el => { this.folderInput = el }} onChange={this.onInputChange(this.folderInput)} /> + {/* Old implementation that worked */} { - console.log('File select triggered', event) - const file = event.target.files[0] - this.setState({ selectedFile: file }) - } - - onBulkCidInputChange = (event) => async () => { - console.log('event', event) - console.log('event.files', event.files) - // const input = event.target - // console.log('Input element:', input) - // console.log('Input files:', input?.files) - // if (!input || !input.files) { - // console.error('Input or files not available') - // return - // } - this.props.onBulkCidImport(normalizeFiles(event)) - // input.value = null + onBulkCidInputChange = (input) => async () => { + console.log('input: ', input) + this.setState({ selectedFile: input.files }) } onSubmit = () => { - console.log('submit') + console.log('Files to import:', this.state.selectedFile) + this.props.onBulkCidImport(normalizeFiles(this.state.selectedFile)) + // input.value = null } - // onSubmit = () => { - // let { path, name } = this.state - // if (this.validatePath(path)) { - // // avoid issues with paths by forcing a flat filename without leading/trailing spaces - // name = name.replaceAll('/', '_').trim() - // this.props.onSubmit(path, name) - // } - // } - - // onKeyPress = (event) => { - // if (event.key === 'Enter') { - // this.onSubmit() - // } - // } - get inputClass () { if (this.state.path === '') { return '' @@ -118,36 +90,18 @@ class BulkImportModal extends React.Component { className='dn' multiple accept='.txt' - onChange={this.handleFileSelect} + onChange={this.onBulkCidInputChange(this.bulkCidInput)} // className='input-reset' - id='bulk-import' + // id='bulk-import' ref={el => { console.log('Setting ref:', el) this.bulkCidInput = el }} - // onChange={this.onBulkCidInputChange(this.bulkCidInput)} - // onChange={(e) => { - // console.log('onChange triggered, current ref:', this.bulkCidInput) - // console.log('onChange event:', e) - // console.log('onChange target:', e.target) - // console.log('onChange files:', e.target.files) - // this.onBulkCidInputChange(this.bulkCidInput) - // }} - // onChange={() => { - // // Make sure we're using the current ref - // console.log('onChange triggered, current ref:', this.bulkCidInput) - // this.onBulkCidInputChange(this.bulkCidInput)() - // }} /> - + )