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
Merge branch 'dev' into implementation/44856-add-submit-action-and-upload-functionality
Eric Schubert2cc34cca402d
diff --cc frontend/src/app/shared/components/storages/storage/storage.component.htmlindex d5e2f50c920,3d4d351e446..fd1b9ab8bed--- a/frontend/src/app/shared/components/storages/storage/storage.component.html+++ b/frontend/src/app/shared/components/storages/storage/storage.component.html@@@ -22,55 -24,90 +24,100 @@@[content]="infoBox"></op-storage-information>- <ul- class="spot-list spot-list_compact op-file-list"- data-qa-selector="file-list"- >- <li- *ngFor="let fileLink of fileLinks$ | async; let i = index;"- class="spot-list--item op-file-list--item"- data-qa-selector="file-list--item"- op-file-link-list-item- [fileLink]="fileLink"- [disabled]="disabled"- [allowEditing]="allowEditing$ | async"- (removeFileLink)="removeFileLink(fileLink)"- ></li>- </ul>+ <div class="op-file-section">+ <ul+ *ngIf="(fileLinks$ | async).length > 0"+ class="spot-list spot-list_compact op-file-list"+ [ngClass]="{+ 'op-file-section': true,+ 'op-file-section--list_dragging': dragging+ }"+ data-qa-selector="file-list"+ >+ <li+ *ngFor="let fileLink of fileLinks$ | async; let i = index;"+ class="spot-list--item op-file-list--item"+ data-qa-selector="file-list--item"+ op-file-link-list-item+ [fileLink]="fileLink"+ [disabled]="disabled"+ [allowEditing]="allowEditing$ | async"+ (removeFileLink)="removeFileLink(fileLink)"+ ></li>+ </ul>- <input- *ngIf="storageFileUploadEnabled"- #hiddenFileInput- type="file"- id="upload_files"- name="upload_files"- (change)="onFilePickerChanged()"- hidden- />+ <span+ *ngIf="!allowUploading && (storageErrors | async).length === 0 && (fileLinks$ | async).length === 0"+ class="op-file-section--empty-list-hint"+ [textContent]="text.emptyList()"+ ></span>+++ <input++ *ngIf="allowUploading"++ #hiddenFileInput++ type="file"++ id="upload_files"++ name="upload_files"++ (change)="onFilePickerChanged()"++ hidden++ />+- <p- *ngIf="(showLinkFilesAction | async) && (allowEditing$ | async)"- class="spot-body-small op-file-list--actions"- >- <button- *ngIf="storageFileLinkingEnabled"- type="button"- class="spot-link op-file-list--action-button"- data-qa-selector="op-file-list--link-existing-file-button"- (click)="openLinkFilesDialog()"- >- <span class="spot-icon spot-icon_add-link"></span>- <span [textContent]="text.actions.linkExisting"></span>- </button><button- *ngIf="storageFileUploadEnabled"+ *ngIf="allowUploading && (storageErrors | async).length === 0"+ [attr.aria-label]="text.dropBox.uploadLabel"+ data-qa-selector="op-storage--drop-box"+ [ngClass]="{+ 'hide-when-print': true,+ 'op-file-section--drop-box': true,+ 'op-file-section--drop-box_dragging': dragging,+ 'op-file-section--drop-box_dragging-over': draggingOverDropZone,+ 'op-file-section--drop-box_float': (fileLinks$ | async).length+ }"type="button"- class="spot-link op-file-list--action-button"- data-qa-selector="op-file-list--upload-file-button"+ (dragover)="onDragOver($event)"+ (dragleave)="onDragLeave($event)"+ (drop)="onDropFiles($event)"- (click)="openSelectLocationDialog()"+ (click)="triggerFileInput()">- <span class="spot-icon spot-icon_upload-arrow"></span>- <span [textContent]="text.actions.uploadFile"></span>+ <span+ class="spot-icon spot-icon_upload-arrow op-file-section--drop-box-icon"+ ></span>+ <span+ *ngIf="(fileLinks$ | async).length > 0"+ class="op-file-section--drop-box-text"+ [textContent]="text.dropBox.dropFiles()"+ ></span>+ <span+ *ngIf="(fileLinks$ | async).length === 0"+ class="op-file-section--drop-box-text"+ [textContent]="text.dropBox.dropClickFiles()"+ ></span></button>- </p>++ <div+ *ngIf="(allowEditing$ | async) && (storageErrors | async).length === 0"+ class="op-file-section--actions"+ >+ <button+ *ngIf="allowUploading"+ type="button"+ class="spot-link"+ data-qa-selector="op-storage--upload-file-button"- (click)="openSelectLocationDialog()"++ (click)="triggerFileInput()"+ >+ <span class="spot-icon spot-icon_upload-arrow"></span>+ <span [textContent]="text.actions.uploadFile"></span>+ </button>+ <button+ *ngIf="allowLinking"+ type="button"+ class="spot-link"+ data-qa-selector="op-storage--link-existing-file-button"+ (click)="openLinkFilesDialog()"+ >+ <span class="spot-icon spot-icon_add-link"></span>+ <span [textContent]="text.actions.linkExisting"></span>+ </button>+ </div>+ </div></ng-container>diff --cc frontend/src/app/shared/components/storages/storage/storage.component.tsindex a6f09c08ab9,96c5c8dae2a..bed8895cd40--- a/frontend/src/app/shared/components/storages/storage/storage.component.ts+++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts@@@ -28,11 -28,11 +28,13 @@@import {ChangeDetectionStrategy,+ ChangeDetectorRef,Component,+ ElementRef,Input,+ OnDestroy,OnInit,+ ViewChild,} from '@angular/core';import {BehaviorSubject,@@@ -86,8 -81,10 +88,12 @@@ export class StorageComponent extends U@Input() public storage:IStorage;+ @Input() public allowUploading = true;++ @Input() public allowLinking = true;++ @ViewChild('hiddenFileInput') public filePicker:ElementRef<HTMLInputElement>;+fileLinks$:Observable<IFileLink[]>;allowEditing$:Observable<boolean>;@@@ -121,12 -117,12 +126,18 @@@linkExisting: this.i18n.t('js.storages.link_existing_files'),uploadFile: this.i18n.t('js.storages.upload_files'),},+ 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 }),+ linkingAfterUploadFailed: (fileName:string, workPackageId:string):string =>+ this.i18n.t('js.storages.file_links.link_uploaded_file_error', { fileName, workPackageId }),+ },+ dropBox: {+ uploadLabel: this.i18n.t('js.storages.upload_files'),+ dropFiles: ():string => this.i18n.t('js.storages.drop_files', { name: this.storage.name }),+ dropClickFiles: ():string => this.i18n.t('js.storages.drop_or_click_files', { name: this.storage.name }),+ },+ emptyList: ():string => this.i18n.t('js.storages.file_links.empty', { storageType: this.storageType }),openStorage: ():string => this.i18n.t('js.storages.open_storage', { storageType: this.storageType }),};@@@ -142,13 -130,9 +145,14 @@@return this.storage._links.open.href;}+ private get addFileLinksHref() {+ return (this.resource.$links as unknown&{ addFileLink:IHalResourceLink }).addFileLink.href;+ }+constructor(private readonly i18n:I18nService,+ private readonly cdRef:ChangeDetectorRef,+ private readonly toastService:ToastService,private readonly cookieService:CookieService,private readonly opModalService:OpModalService,private readonly currentUserService:CurrentUserService,@@@ -230,62 -210,10 +243,62 @@@storageLocation: this.storageFilesLocation,storageLink: this.storage._links.self,};- this.opModalService.show<LocationPickerModalComponent>(LocationPickerModalComponent, 'global', locals);+ this.opModalService.show<LocationPickerModalComponent>(LocationPickerModalComponent, 'global', locals)+ .subscribe((m) => {+ m.closingEvent.subscribe((modal) => {+ if (modal.submitted && files !== null) {+ this.uploadFile(files[0], modal.location);+ }+ });+ });+ }++ private uploadFile(file:UploadFile, location:string):void {+ let isUploadError = false;++ this.storageFilesResourceService+ .uploadLink(+ this.UploadResourceLink(this.storage._links.self),+ file.name,+ location,+ )+ .pipe(+ switchMap((link) => this.uploadStorageFilesService.uploadFile(link, file)),+ catchError((error) => {+ isUploadError = true;+ return throwError(error);+ }),+ switchMap((f) => this.fileLinkResourceService.addFileLinks(+ this.collectionKey,+ this.addFileLinksHref,+ this.storage._links.self,+ [f],+ )),+ )+ .subscribe(+ (collection) => {+ this.toastService.addSuccess(this.text.toast.successFileLinksCreated(collection.count));+ },+ (error) => {+ if (isUploadError) {+ this.toastService.addError(this.text.toast.uploadFailed(file.name));+ } else {+ this.toastService.addError(this.text.toast.linkingAfterUploadFailed(file.name, this.resource.id as string));+ }++ console.error(error);+ },+ );+ }++ private UploadResourceLink(storageLink:IHalResourceLink):IHalResourceLink {+ return {+ href: `${storageLink.href}/files/prepare_upload`,+ title: 'Upload resource link',+ };}- private instantiateStorageInformation(fileLinks:IFileLink[]):StorageInformationBox[] {+ private getStorageErrors(fileLinks:IFileLink[]):StorageInformationBox[] {if (!this.isLoggedIn) {return [];}