Skip to content

Commit 4e45614

Browse files
Merge pull request #56065 from nextcloud/backport/55575/stable31
[stable31] fix(files): make sure drag-and-drop and the upload menu behaves the same
2 parents 3dadf60 + 93ebd8b commit 4e45614

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

apps/files/src/services/DropService.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,24 @@ export const dataTransferToFileTree = async (items: DataTransferItem[]): Promise
8989
return fileTree
9090
}
9191

92-
export const onDropExternalFiles = async (root: RootDirectory, destination: Folder, contents: Node[]): Promise<Upload[]> => {
92+
/**
93+
* Handle dropping external files
94+
*
95+
* @param root - The root directory which should be uploaded
96+
* @param destination - The destination folder
97+
* @param contents - The contents of the destination folder
98+
*/
99+
export async function onDropExternalFiles(root: RootDirectory, destination: Folder, contents: Node[]): Promise<Upload[]> {
93100
const uploader = getUploader()
94101

95102
// Check for conflicts on root elements
96103
if (await hasConflict(root.contents, contents)) {
97104
root.contents = await resolveConflict(root.contents, destination, contents)
98-
}
99-
100-
if (root.contents.length === 0) {
105+
if (root.contents.length === 0) {
106+
// user cancelled the upload
107+
return []
108+
}
109+
} else if (root.contents.length === 0) {
101110
logger.info('No files to upload', { root })
102111
showInfo(t('files', 'No files to upload'))
103112
return []

apps/files/src/services/DropServiceUtils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*/
55
import type { FileStat, ResponseDataDetailed } from 'webdav'
66

7+
import { showWarning, showInfo } from '@nextcloud/dialogs'
78
import { emit } from '@nextcloud/event-bus'
89
import { Folder, Node, davGetClient, davGetDefaultPropfind, davResultToNode } from '@nextcloud/files'
910
import { openConflictPicker } from '@nextcloud/upload'
10-
import { showError, showInfo } from '@nextcloud/dialogs'
1111
import { translate as t } from '@nextcloud/l10n'
1212

1313
import logger from '../logger.ts'
@@ -168,10 +168,9 @@ export const resolveConflict = async <T extends ((Directory|File)|Node)>(files:
168168
// Update the list of files to upload
169169
return [...uploads, ...selected, ...renamed] as (typeof files)
170170
} catch (error) {
171-
console.error(error)
172171
// User cancelled
173-
showError(t('files', 'Upload cancelled'))
174-
logger.error('User cancelled the upload')
172+
logger.warn('User cancelled the upload', { error })
173+
showWarning(t('files', 'Upload cancelled'))
175174
}
176175

177176
return []

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)