aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/components/DragAndDropNotice.vue
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2024-02-01 18:59:58 +0100
committernextcloud-command <nextcloud-command@users.noreply.github.com>2024-02-07 07:57:23 +0000
commit9e1efe0538da54f6a57ed2516f135b957bd7e28b (patch)
tree65b675c88c2324281e2cbd1695c09291bcb8eabb /apps/files/src/components/DragAndDropNotice.vue
parent52d0b9a6f66e6de197526f95fdb29cbf2f434cee (diff)
downloadnextcloud-server-9e1efe0538da54f6a57ed2516f135b957bd7e28b.tar.gz
nextcloud-server-9e1efe0538da54f6a57ed2516f135b957bd7e28b.zip
fix(files): drop to folder path and user feedback
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/src/components/DragAndDropNotice.vue')
-rw-r--r--apps/files/src/components/DragAndDropNotice.vue50
1 files changed, 30 insertions, 20 deletions
diff --git a/apps/files/src/components/DragAndDropNotice.vue b/apps/files/src/components/DragAndDropNotice.vue
index 3f7126fac67..a9c1d8e99ad 100644
--- a/apps/files/src/components/DragAndDropNotice.vue
+++ b/apps/files/src/components/DragAndDropNotice.vue
@@ -47,6 +47,7 @@ import { defineComponent } from 'vue'
import { Folder, Permission } from '@nextcloud/files'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
+import { UploadStatus } from '@nextcloud/upload'
import TrayArrowDownIcon from 'vue-material-design-icons/TrayArrowDown.vue'
@@ -143,10 +144,11 @@ export default defineComponent({
}
},
- onDrop(event: DragEvent) {
- logger.debug('Dropped on DragAndDropNotice', { event, error: this.cantUploadLabel })
+ async onDrop(event: DragEvent) {
+ logger.debug('Dropped on DragAndDropNotice', { event })
- if (!this.canUpload || this.isQuotaExceeded) {
+ // cantUploadLabel is null if we can upload
+ if (this.cantUploadLabel) {
showError(this.cantUploadLabel)
return
}
@@ -162,23 +164,31 @@ export default defineComponent({
// Start upload
logger.debug(`Uploading files to ${this.currentFolder.path}`)
// Process finished uploads
- handleDrop(event.dataTransfer).then((uploads) => {
- logger.debug('Upload terminated', { uploads })
- showSuccess(t('files', 'Upload successful'))
-
- // Scroll to last upload in current directory if terminated
- const lastUpload = uploads.findLast((upload) => !upload.file.webkitRelativePath.includes('/') && upload.response?.headers?.['oc-fileid'])
- if (lastUpload !== undefined) {
- this.$router.push({
- ...this.$route,
- params: {
- view: this.$route.params?.view ?? 'files',
- // Remove instanceid from header response
- fileid: parseInt(lastUpload.response!.headers['oc-fileid']),
- },
- })
- }
- })
+ const uploads = await handleDrop(event.dataTransfer)
+ logger.debug('Upload terminated', { uploads })
+
+ if (uploads.some((upload) => upload.status === UploadStatus.FAILED)) {
+ showError(t('files', 'Some files could not be uploaded'))
+ const failedUploads = uploads.filter((upload) => upload.status === UploadStatus.FAILED)
+ logger.debug('Some files could not be uploaded', { failedUploads })
+ } else {
+ showSuccess(t('files', 'Files uploaded successfully'))
+ }
+
+ // Scroll to last successful upload in current directory if terminated
+ const lastUpload = uploads.findLast((upload) => upload.status !== UploadStatus.FAILED
+ && !upload.file.webkitRelativePath.includes('/')
+ && upload.response?.headers?.['oc-fileid'])
+
+ if (lastUpload !== undefined) {
+ this.$router.push({
+ ...this.$route,
+ params: {
+ view: this.$route.params?.view ?? 'files',
+ fileid: parseInt(lastUpload.response!.headers['oc-fileid']),
+ },
+ })
+ }
}
this.dragover = false
},