Skip to content

Commit

Permalink
Merge pull request #43418 from nextcloud/backport/43267/stable28
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv committed Feb 7, 2024
2 parents 5dc2200 + 8b12b16 commit 7d9c4cf
Show file tree
Hide file tree
Showing 11 changed files with 480 additions and 664 deletions.
50 changes: 30 additions & 20 deletions apps/files/src/components/DragAndDropNotice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
}
Expand All @@ -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
},
Expand Down

0 comments on commit 7d9c4cf

Please sign in to comment.