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
[chore] update file link data after updating ...
Eric Schubert1883f413a665
diff --git a/frontend/src/app/core/state/file-links/file-links.service.ts b/frontend/src/app/core/state/file-links/file-links.service.tsindex 86048aa2382..0c0d58af23c 100644--- a/frontend/src/app/core/state/file-links/file-links.service.ts+++ b/frontend/src/app/core/state/file-links/file-links.service.ts@@ -29,7 +29,7 @@import { applyTransaction } from '@datorama/akita';import { Injectable } from '@angular/core';import { HttpHeaders } from '@angular/common/http';-import { from, Observable } from 'rxjs';+import { from, Observable, of } from 'rxjs';import {groupBy,mergeMap,@@ -40,17 +40,21 @@ import {import { IFileLink, IFileLinkOriginData } from 'core-app/core/state/file-links/file-link.model';import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';-import { ToastService } from 'core-app/shared/components/toaster/toast.service';import { FileLinksStore } from 'core-app/core/state/file-links/file-links.store';import { insertCollectionIntoState, removeEntityFromCollectionAndState } from 'core-app/core/state/collection-store';import { CollectionStore, ResourceCollectionService } from 'core-app/core/state/resource-collection.service';import { IHalResourceLink } from 'core-app/core/state/hal-resource';-import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';import idFromLink from 'core-app/features/hal/helpers/id-from-link';@Injectable()export class FileLinksResourceService extends ResourceCollectionService<IFileLink> {- @InjectField() toastService:ToastService;+ protected createStore():CollectionStore<IFileLink> {+ return new FileLinksStore();+ }++ protected basePath():string {+ return this.apiV3Service.file_links.path;+ }updateCollectionsForWorkPackage(fileLinksSelfLink:string):Observable<IFileLink[]> {return this.http@@ -79,21 +83,24 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLin);}- protected createStore():CollectionStore<IFileLink> {- return new FileLinksStore();+ updateCollection(href:string):Observable<IHALCollection<IFileLink>> {+ return this.http+ .get<IHALCollection<IFileLink>>(href)+ .pipe(+ tap((collection) => insertCollectionIntoState(this.store, collection, href)),+ );}- remove(collectionKey:string, fileLink:IFileLink):void {+ remove(collectionKey:string, fileLink:IFileLink):Observable<void> {if (!fileLink._links.delete) {- return;+ return of();}const headers = new HttpHeaders({ 'Content-Type': 'application/json' });- this.http+ return this.http.delete<void>(fileLink._links.delete.href, { withCredentials: true, headers })- .subscribe(- () => removeEntityFromCollectionAndState(this.store, fileLink.id, collectionKey),- this.toastAndThrow.bind(this),+ .pipe(+ tap(() => removeEntityFromCollectionAndState(this.store, fileLink.id, collectionKey)),);}@@ -132,14 +139,4 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLin}),);}-- protected basePath():string {- return this.apiV3Service.file_links.path;- }-- // eslint-disable-next-line @typescript-eslint/no-explicit-any- private toastAndThrow(error:any):void {- this.toastService.addError(error);- throw error;- }}diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.ts b/frontend/src/app/shared/components/storages/storage/storage.component.tsindex 84a05359139..81a77cd8a2d 100644--- a/frontend/src/app/shared/components/storages/storage/storage.component.ts+++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts@@ -54,6 +54,7 @@ import {map,switchMap,take,+ tap,} from 'rxjs/operators';import { CookieService } from 'ngx-cookie-service';import { v4 as uuidv4 } from 'uuid';@@ -265,7 +266,11 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD}public removeFileLink(fileLink:IFileLink):void {- this.fileLinkResourceService.remove(this.collectionKey, fileLink);+ this.fileLinkResourceService.remove(this.collectionKey, fileLink)+ .subscribe(+ () => { /* Do nothing */ },+ (error:HttpErrorResponse) => this.toastService.addError(error),+ );}public openLinkFilesDialog():void {@@ -350,6 +355,12 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnDreturn throwError(error);}),switchMap((uploadResponse) => this.createFileLinkData(data.file, uploadResponse)),+ tap((fileLinkCreationData) => {+ // Update the file link list of this storage only in case of a linked file got updated+ if (fileLinkCreationData === null) {+ this.fileLinkResourceService.updateCollection(this.fileLinkSelfLink).subscribe();+ }+ }),filter(isNotNull),switchMap((file) => this.fileLinkResourceService.addFileLinks(this.collectionKey,@@ -393,7 +404,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnDprivate uploadAndNotify(link:IUploadLink, file:File, overwrite:boolean|null):Observable<FileUploadResponse> {const { href } = link._links.destination;const uploadFiles:NextcloudUploadFile[] = [{ file, overwrite }];- const observable = this.uploadService.upload(href, uploadFiles)[0];+ const observable = this.uploadService.upload<FileUploadResponse>(href, uploadFiles)[0];this.toastService.addUpload(this.text.toast.uploadingLabel, [[file, observable]]);return observable