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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(files): add batch support to copy-move #42124

Merged
merged 2 commits into from Dec 14, 2023
Merged

Conversation

skjnldsv
Copy link
Member

@skjnldsv skjnldsv commented Dec 8, 2023

Fix #41661

Later

  • There are room for improvements, especially on how we handle promises-chaining 馃
  • Also, we should either refresh the view, or, if the destination is within the current displayed dir, refresh its content.

@skjnldsv skjnldsv added this to the Nextcloud 28.0.1 milestone Dec 8, 2023
@skjnldsv skjnldsv requested review from susnux, artonge and a team December 8, 2023 15:48
@skjnldsv skjnldsv self-assigned this Dec 8, 2023
@skjnldsv skjnldsv requested review from emoral435 and removed request for a team December 8, 2023 15:48
emoral435
emoral435 previously approved these changes Dec 11, 2023
Copy link
Contributor

@emoral435 emoral435 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this on my local dev setup and it works 馃憣 Only thing I would change is the redundant if statements with using the MOVE_OR_COPY in this file, but that's more of a nitpick than anything

@emoral435 emoral435 dismissed their stale review December 11, 2023 16:43

minor changes needed

Copy link
Contributor

@emoral435 emoral435 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this works on my dev setup, just needs the changes requested 馃憣

apps/files/src/actions/moveOrCopyAction.ts Outdated Show resolved Hide resolved
Comment on lines +253 to +270
async execBatch(nodes: Node[], view: View, dir: string) {
const action = getActionForNodes(nodes)
const result = await openFilePickerForAction(action, dir, nodes)
const promises = nodes.map(async node => {
try {
await handleCopyMoveNodeTo(node, result.destination, result.action)
return true
} catch (error) {
logger.error(`Failed to ${result.action} node`, { node, error })
return false
}
})

// We need to keep the selection on error!
// So we do not return null, and for batch action
// we let the front handle the error.
return await Promise.all(promises)
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muuuuuuuuuch cleaner!
Now we don't mix picking the folder AND executing the action :)

Copy link
Contributor

@emoral435 emoral435 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Really nice changes : D

})
.setMimeTypeFilter([])
.setMultiSelect(false)
.startAt(dir)

return new Promise((resolve, reject) => {
filePicker.setButtonFactory((nodes: Node[], path: string) => {
filePicker.setButtonFactory((_selection, path: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why removing the typing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because unused :)

@emoral435
Copy link
Contributor

/compile /

@skjnldsv skjnldsv added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Dec 13, 2023
@skjnldsv
Copy link
Member Author

/backport to stable28

Signed-off-by: John Molakvo忙 <skjnldsv@protonmail.com>
Signed-off-by: John Molakvo忙 <skjnldsv@protonmail.com>
@skjnldsv skjnldsv merged commit 842a3d7 into master Dec 14, 2023
40 of 41 checks passed
@skjnldsv skjnldsv deleted the feat/files/batch-copy-move branch December 14, 2023 09:13
@skjnldsv
Copy link
Member Author

/backport to stable28

@skjnldsv
Copy link
Member Author

Backport in #42279

@blizzz blizzz mentioned this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish feature: files regression
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Bug]: Multiselect menu missing "Move or copy"
4 participants