mirror of
https://github.com/nextcloud/server.git
synced 2026-03-12 13:44:53 -04:00
fix(files): make sure drag-and-drop and the upload menu behaves the same
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
3dadf60104
commit
ceb6eb9d21
2 changed files with 16 additions and 8 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 []
|
||||
|
|
|
|||
Loading…
Reference in a new issue