From 0722a404e832db0f8a1d70b281ee3efebe2d429d Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Fri, 29 Apr 2022 11:34:53 +0200 Subject: [PATCH] Fix root folder links in the upload overlay --- .../src/components/AppBar/CreateAndUpload.vue | 2 ++ packages/web-app-files/src/views/FilesDrop.vue | 6 ++++++ .../web-runtime/src/components/UploadInfo.vue | 18 +++++------------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue index 794ad4992d4..ba8f6186792 100644 --- a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue +++ b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue @@ -281,6 +281,8 @@ export default defineComponent({ resource = buildResource(resource) + this.$uppyService.$emit('uploadedFileFetched', file, resource) + // Update table only if the file was uploaded to the current directory if (fileIsInCurrentPath) { this.UPSERT_RESOURCE(resource) diff --git a/packages/web-app-files/src/views/FilesDrop.vue b/packages/web-app-files/src/views/FilesDrop.vue index b47abc8fbf4..1b1071ac866 100644 --- a/packages/web-app-files/src/views/FilesDrop.vue +++ b/packages/web-app-files/src/views/FilesDrop.vue @@ -57,6 +57,7 @@ export default { onMounted(() => { uppyService.$on('filesSelected', instance.onFilesSelected) + uppyService.$on('uploadSuccess', instance.onFileSuccess) uppyService.$on('uploadError', instance.onFileError) uppyService.useDropTarget({ @@ -67,6 +68,7 @@ export default { onUnmounted(() => { uppyService.$off('filesSelected', instance.onFilesSelected) + uppyService.$off('uploadSuccess', instance.onFileSuccess) uppyService.$off('uploadError', instance.onFileError) }) @@ -165,6 +167,10 @@ export default { this.$uppyService.uploadFiles(uppyResources) }, + onFileSuccess(uppyResource) { + this.$uppyService.$emit('uploadedFileFetched', uppyResource, { name: uppyResource.name }) + }, + onFileError(error) { console.error(error) this.showMessage({ diff --git a/packages/web-runtime/src/components/UploadInfo.vue b/packages/web-runtime/src/components/UploadInfo.vue index cacda7e9af6..c777b45a7f4 100644 --- a/packages/web-runtime/src/components/UploadInfo.vue +++ b/packages/web-runtime/src/components/UploadInfo.vue @@ -120,19 +120,10 @@ export default { this.closeInfo() } }) - this.$uppyService.$on('uploadSuccess', (file) => { - // @TODO we need the storage ID here... maybe fetch the file via DAV and call buildResources()? - - let path = file.meta.currentFolder - if (file.meta.relativePath) { - path += file.meta.relativePath - } - path += file.name - + this.$uppyService.$on('uploadedFileFetched', (uppyResource, fetchedFile) => { this.successfulUploads.push({ - ...file, - path, - targetRoute: file.meta.route + ...fetchedFile, + targetRoute: uppyResource.meta.route }) }) }, @@ -169,7 +160,8 @@ export default { name: targetRoute.name, query: targetRoute.query, params: { - ...(storageId && path && { storageId }) + ...(storageId && path && { storageId }), + storage: targetRoute.params?.storage } }