Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bulk CIDs import #2307

Merged
merged 49 commits into from
Feb 27, 2025
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
16c9c92
Start bulk CID import
MattWong-ca Nov 30, 2024
8240607
Merge remote-tracking branch 'upstream/main' into feat/bulk-cids-import
MattWong-ca Nov 30, 2024
31a6cd0
Get functional MVP working with csv file
MattWong-ca Nov 30, 2024
35e392d
Get it working with txt file
MattWong-ca Dec 1, 2024
31ea252
WIP: bulk import modal UX
MattWong-ca Dec 6, 2024
a85432f
WIP, need to debug modal UX
MattWong-ca Dec 7, 2024
481e7a9
Modal UX working, need to clean up code
MattWong-ca Dec 7, 2024
c47e403
Remove comments
MattWong-ca Dec 7, 2024
2d2157d
Clean code
MattWong-ca Dec 7, 2024
fa54900
Add validation to file select
MattWong-ca Dec 8, 2024
274bc37
Use localization
MattWong-ca Dec 8, 2024
85a9328
Add correct type, remove progress tracking
MattWong-ca Dec 8, 2024
d343c88
Refactor code
MattWong-ca Dec 9, 2024
7b80a5d
Add storybook file
MattWong-ca Dec 9, 2024
88e7876
Remove comments
MattWong-ca Dec 9, 2024
8af56b7
Update Add menu test
MattWong-ca Dec 9, 2024
c3271fe
Merge remote-tracking branch 'upstream/main' into feat/bulk-cids-import
MattWong-ca Dec 9, 2024
8b56df3
Remove prop-types
MattWong-ca Dec 13, 2024
542ac1b
Use functional component
MattWong-ca Dec 13, 2024
90a6487
Use useTranslation
MattWong-ca Dec 13, 2024
45eaacb
Update to TS file
MattWong-ca Dec 13, 2024
fb30c30
Update import path
MattWong-ca Dec 13, 2024
0e00a85
fix(explore): browsing chunked files and inspecting via context menu …
lidel Nov 29, 2024
48b55fd
chore(ci): set cluster pin timeout to 30m
lidel Nov 29, 2024
7177f71
chore(ci): use repo in offline mode
lidel Nov 30, 2024
991f019
Get functional MVP working with csv file
MattWong-ca Nov 30, 2024
21b0aa1
Get it working with txt file
MattWong-ca Dec 1, 2024
febbc95
WIP: bulk import modal UX
MattWong-ca Dec 6, 2024
dbf6bda
WIP, need to debug modal UX
MattWong-ca Dec 7, 2024
7bd6081
Modal UX working, need to clean up code
MattWong-ca Dec 7, 2024
c701fb7
Remove comments
MattWong-ca Dec 7, 2024
108068a
Clean code
MattWong-ca Dec 7, 2024
6fa7da6
Add validation to file select
MattWong-ca Dec 8, 2024
5c82550
Use localization
MattWong-ca Dec 8, 2024
28e3725
Add correct type, remove progress tracking
MattWong-ca Dec 8, 2024
38ef8df
Refactor code
MattWong-ca Dec 9, 2024
0b4b84a
Add storybook file
MattWong-ca Dec 9, 2024
2752634
Remove comments
MattWong-ca Dec 9, 2024
44cd9f8
Update Add menu test
MattWong-ca Dec 9, 2024
2ea51b1
chore(release): 4.4.1 [skip ci]
semantic-release-bot Nov 30, 2024
ff3f8c1
chore: pull new translations (#2308)
github-actions[bot] Dec 4, 2024
d74bf52
Remove prop-types
MattWong-ca Dec 13, 2024
e9b4d85
Use functional component
MattWong-ca Dec 13, 2024
4d52a3c
Use useTranslation
MattWong-ca Dec 13, 2024
eafec89
Update to TS file
MattWong-ca Dec 13, 2024
fdef1f4
Update import path
MattWong-ca Dec 13, 2024
7f95020
Merge branch 'feat/bulk-cids-import' of https://github.com/MattWong-c…
MattWong-ca Dec 14, 2024
fb064df
Merge remote-tracking branch 'upstream/main' into feat/bulk-cids-import
MattWong-ca Dec 14, 2024
23f229a
Merge branch 'main' into feat/bulk-cids-import
SgtPooki Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP, need to debug modal UX
MattWong-ca committed Dec 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a85432f2c032b0c7114ac58b17d5956a8c4c548c
1 change: 1 addition & 0 deletions src/bundles/files/actions.js
Original file line number Diff line number Diff line change
@@ -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')
3 changes: 3 additions & 0 deletions src/files/file-input/FileInput.js
Original file line number Diff line number Diff line change
@@ -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 */}
<input
// TO-DO id='file-input'
type='file'
68 changes: 11 additions & 57 deletions src/files/modals/bulk-import-modal/BulkImportModal.js
Original file line number Diff line number Diff line change
@@ -39,45 +39,17 @@ class BulkImportModal extends React.Component {
this.setState({ [name]: value })
}

handleFileSelect = (event) => {
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)()
// }}
/>
<Button
// onClick={() => {
// if (this.bulkCidInput) {
// this.bulkCidInput.click()
// }
// }}
onClick={(e) => {
onClick={() => {
console.log('clicked')
document.getElementById('bulk-import').click()
this.bulkCidInput.click()
}}
className='ma2 tc'
bg='bg-teal'
@@ -175,7 +129,7 @@ class BulkImportModal extends React.Component {

<ModalActions>
<Button className='ma2 tc' bg='bg-gray' onClick={onCancel}>{t('actions.cancel')}</Button>
<Button className='ma2 tc' bg='bg-teal' /* disabled={this.isDisabled} */ onClick={this.onBulkCidInputChange(this.bulkCidInput)}>{t('app:actions.import')}</Button>
<Button className='ma2 tc' bg='bg-teal' /* disabled={this.isDisabled} */ onClick={this.onSubmit}>{t('app:actions.import')}</Button>
</ModalActions>
</Modal>
)