Merge pull request #56066 from nextcloud/backport/55575/stable32

[stable32] fix(files): make sure drag-and-drop and the upload menu behaves the same
pull/56071/head
Andy Scherzinger 2025-10-28 21:05:49 +07:00 committed by GitHub
commit 2f960a295f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 11 deletions

@ -89,15 +89,24 @@ export const dataTransferToFileTree = async (items: DataTransferItem[]): Promise
return fileTree
}
export const onDropExternalFiles = async (root: RootDirectory, destination: Folder, contents: Node[]): Promise<Upload[]> => {
/**
* Handle dropping external files
*
* @param root - The root directory which should be uploaded
* @param destination - The destination folder
* @param contents - The contents of the destination folder
*/
export async function onDropExternalFiles(root: RootDirectory, destination: Folder, contents: Node[]): Promise<Upload[]> {
const uploader = getUploader()
// Check for conflicts on root elements
if (await hasConflict(root.contents, contents)) {
root.contents = await resolveConflict(root.contents, destination, contents)
}
if (root.contents.length === 0) {
if (root.contents.length === 0) {
// user cancelled the upload
return []
}
} else if (root.contents.length === 0) {
logger.info('No files to upload', { root })
showInfo(t('files', 'No files to upload'))
return []

@ -4,10 +4,10 @@
*/
import type { FileStat, ResponseDataDetailed } from 'webdav'
import { showWarning, showInfo } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { Folder, Node, davGetClient, davGetDefaultPropfind, davResultToNode } from '@nextcloud/files'
import { openConflictPicker } from '@nextcloud/upload'
import { showError, showInfo } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import logger from '../logger.ts'
@ -168,10 +168,9 @@ export const resolveConflict = async <T extends ((Directory|File)|Node)>(files:
// Update the list of files to upload
return [...uploads, ...selected, ...renamed] as (typeof files)
} catch (error) {
console.error(error)
// User cancelled
showError(t('files', 'Upload cancelled'))
logger.error('User cancelled the upload')
logger.warn('User cancelled the upload', { error })
showWarning(t('files', 'Upload cancelled'))
}
return []

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long