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
Added factory method for fetching live-links
Andreas Pfohl036823a635d0
diff --git a/frontend/src/app/core/state/projects/projects.service.ts b/frontend/src/app/core/state/projects/projects.service.tsindex 8488b9212ec..e87026e6190 100644--- a/frontend/src/app/core/state/projects/projects.service.ts+++ b/frontend/src/app/core/state/projects/projects.service.ts@@ -53,7 +53,7 @@ export class ProjectsResourceService {);}- lookup(id:ID):Observable<IProject | undefined> {+ lookup(id:ID):Observable<IProject|undefined> {return this.query.selectEntity(id);}diff --git a/frontend/src/app/core/state/storages/storages.service.ts b/frontend/src/app/core/state/storages/storages.service.tsindex c13ee5bc011..df8310a5c2f 100644--- a/frontend/src/app/core/state/storages/storages.service.ts+++ b/frontend/src/app/core/state/storages/storages.service.ts@@ -31,6 +31,9 @@ import { HttpClient } from '@angular/common/http';import { IHalResourceLink } from 'core-app/core/state/hal-resource';import { Observable } from 'rxjs';import { IStorage } from 'core-app/core/state/storages/storage.model';+import {+ ILiveFileLinkCollection,+} from 'core-app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component';@Injectable()export class StoragesResourceService {@@ -39,4 +42,11 @@ export class StoragesResourceService {lookup(storageLink:IHalResourceLink):Observable<IStorage> {return this.httpClient.get<IStorage>(storageLink.href);}++ liveLinks(storage:IStorage):(containerType:string, containerId:string) => Observable<ILiveFileLinkCollection> {+ return (containerType:string, containerId:string):Observable<ILiveFileLinkCollection> => {+ const url = `${storage._links?.self.href || ''}/live_file_links?container_type=${containerType}&container_id=${containerId}`;+ return this.httpClient.get<ILiveFileLinkCollection>(url);+ };+ }}diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.tsindex e6378bdd7a8..37dd6dd2530 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts@@ -34,13 +34,25 @@ import {import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { I18nService } from 'core-app/core/i18n/i18n.service';import { HookService } from 'core-app/features/plugins/hook-service';-import { forkJoin, Observable, of } from 'rxjs';+import { forkJoin, Observable } from 'rxjs';import { CurrentUserService } from 'core-app/core/current-user/current-user.service';-import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';-import { ProjectsResourceService } from 'core-app/core/state/projects/projects.service';import { StoragesResourceService } from 'core-app/core/state/storages/storages.service';+import { IProject } from 'core-app/core/state/projects/project.model';+import { IHalResourceLink, IHalResourceLinks } from 'core-app/core/state/hal-resource';import { switchMap } from 'rxjs/operators';-import { IStorage } from 'core-app/core/state/storages/storage.model';++export interface ILiveFileLinkCollectionsLinks extends IHalResourceLinks {+ self:IHalResourceLink+}++export interface ILiveFileLinkCollectionEmbeddings {++}++export interface ILiveFileLinkCollection {+ _links:ILiveFileLinkCollectionsLinks;+ _embedded:ILiveFileLinkCollectionEmbeddings;+}@Component({selector: 'op-files-tab',@@ -61,33 +73,32 @@ export class WorkPackageFilesTabComponent implements OnInit {canViewFileLinks$:Observable<boolean>;- storages$:Observable<IStorage[]>;+ fileLinkCollections$:Observable<ILiveFileLinkCollection[]>;constructor(readonly I18n:I18nService,protected hook:HookService,private currentUserService:CurrentUserService,- private currentProjectService:CurrentProjectService,- private projectsResourceService:ProjectsResourceService,private storagesResourceService:StoragesResourceService,) { }ngOnInit():void {- const projectId = this.currentProjectService.id as string;+ const project = this.workPackage.$embedded.project as IProject;this.canViewFileLinks$ = this.currentUserService- .hasCapabilities$('file_links/view', projectId);-- this.storages$ = this.projectsResourceService.lookup(projectId)- .pipe(- switchMap((project) => {- if (project === undefined) {- return of([]);- }+ .hasCapabilities$('file_links/view', project.id as string);- return forkJoin(project._links.storages.map((link) => this.storagesResourceService.lookup(link)));- }),- );+ const storageLinks = project._links.storages;+ this.fileLinkCollections$ = forkJoin(+ storageLinks.map((link) => this+ .storagesResourceService+ .lookup(link)+ .pipe(+ switchMap((storage) => this+ .storagesResourceService+ .liveLinks(storage)('WorkPackage', this.workPackage.id as string)),+ )),+ );}}diff --git a/lib/api/v3/projects/project_representer.rb b/lib/api/v3/projects/project_representer.rbindex 83429a65180..61ecdccc21c 100644--- a/lib/api/v3/projects/project_representer.rb+++ b/lib/api/v3/projects/project_representer.rb@@ -88,10 +88,10 @@ module API{ href: api_v3_paths.work_packages_by_project(represented.id) }end- links :storages,- cache_if: -> {- current_user_allowed_to(:view_file_links, context: represented)- } do+ link :storages,+ cache_if: -> {+ current_user_allowed_to(:view_file_links, context: represented)+ } dorepresented.storages.map do |storage|{href: api_v3_paths.storage(storage.id),