OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#45938] Provide meaningful help when upload to Nextcloud fails due to file size
Eric Schubert24688ecc0fa0
diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.ts b/frontend/src/app/shared/components/storages/storage/storage.component.tsindex 8e511575c5c..2f28c40dded 100644--- a/frontend/src/app/shared/components/storages/storage/storage.component.ts+++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts@@ -36,7 +36,12 @@ import {OnInit,ViewChild,} from '@angular/core';-import { HttpClient, HttpEventType, HttpResponse } from '@angular/common/http';+import {+ HttpClient,+ HttpErrorResponse,+ HttpEventType,+ HttpResponse,+} from '@angular/common/http';import { BehaviorSubject, Observable, throwError } from 'rxjs';import {catchError,@@ -132,7 +137,10 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD},toast: {successFileLinksCreated: (count:number):string => this.i18n.t('js.storages.file_links.success_create', { count }),- uploadFailed: (fileName:string):string => this.i18n.t('js.storages.file_links.upload_error', { fileName }),+ uploadFailed: (fileName:string):string => this.i18n.t('js.storages.file_links.upload_error.default', { fileName }),+ uploadFailedForbidden: (fileName:string):string => this.i18n.t('js.storages.file_links.upload_error.403', { fileName }),+ uploadFailedSizeLimit: (fileName:string):string => this.i18n.t('js.storages.file_links.upload_error.413', { fileName }),+ uploadFailedQuota: (fileName:string):string => this.i18n.t('js.storages.file_links.upload_error.507', { fileName }),linkingAfterUploadFailed: (fileName:string, workPackageId:string):string =>this.i18n.t('js.storages.file_links.link_uploaded_file_error', { fileName, workPackageId }),draggingManyFiles: (storageType:string):string => this.i18n.t('js.storages.files.dragging_many_files', { storageType }),@@ -300,7 +308,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD},(error) => {if (isUploadError) {- this.toastService.addError(this.text.toast.uploadFailed(file.name));+ this.handleUploadError(error as HttpErrorResponse, file.name);} else {this.toastService.addError(this.text.toast.linkingAfterUploadFailed(file.name, this.resource.id as string));}@@ -310,6 +318,22 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD);}+ private handleUploadError(error:HttpErrorResponse, fileName:string):void {+ switch (error.status) {+ case 403:+ this.toastService.addError(this.text.toast.uploadFailedForbidden(fileName));+ break;+ case 413:+ this.toastService.addError(this.text.toast.uploadFailedSizeLimit(fileName));+ break;+ case 507:+ this.toastService.addError(this.text.toast.uploadFailedQuota(fileName));+ break;+ default:+ this.toastService.addError(this.text.toast.uploadFailed(fileName));+ }+ }+private uploadAndNotify(link:IUploadLink, file:UploadFile):Observable<IFileLinkOriginData> {const { method, href } = link._links.destination;diff --git a/modules/storages/config/locales/js-en.yml b/modules/storages/config/locales/js-en.ymlindex 99299e758f5..aa830034d3b 100644--- a/modules/storages/config/locales/js-en.yml+++ b/modules/storages/config/locales/js-en.yml@@ -57,7 +57,13 @@ en:success_create:one: "Successfully created 1 file link."other: "Successfully created %{count} file links."- upload_error: "An error occurred uploading the file '%{fileName}'."+ upload_error:+ default: "An error occurred uploading the file '%{fileName}'."+ 403: "Uploading '%{fileName}' is forbidden."+ 413: >+ '%{fileName}' exceeds storage upload file size limits. To upload large files use the UI of the storage+ itself and create the file link afterwards.+ 507: "Uploading '%{fileName}' would exceed storage quota."link_uploaded_file_error: >An error occurred linking the recently uploaded file '%{fileName}' to the work package %{workPackageId}.not_allowed_tooltip: "Please log in to Nextcloud to access this file"