Skip to content

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

Added context for querying capabilities in files tab

Andreas Pfohl29faa0e0f286
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.ts
index 8a0a3502cf9..07005124e40 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
@@ -26,19 +26,25 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { ChangeDetectionStrategy, Component } from '@angular/core';
+import {
+ ChangeDetectionStrategy,
+ Component,
+ OnDestroy,
+ OnInit,
+} from '@angular/core';
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 { Observable } from 'rxjs';
+import { Subscription } from 'rxjs';
import { CurrentUserService } from 'core-app/core/current-user/current-user.service';
+import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
@Component({
selector: 'op-files-tab',
templateUrl: './op-files-tab.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
-export class WorkPackageFilesTabComponent {
+export class WorkPackageFilesTabComponent implements OnInit, OnDestroy {
public workPackage:WorkPackageResource;
public text = {
@@ -50,13 +56,27 @@ export class WorkPackageFilesTabComponent {
},
};
- $can_view_file_links:Observable<boolean> = this
- .currentUserService
- .hasCapabilities$('file_links/view');
+ public canViewFileLinks = true;
+
+ private subscription:Subscription;
constructor(
readonly I18n:I18nService,
protected hook:HookService,
private currentUserService:CurrentUserService,
+ private currentProjectService:CurrentProjectService,
) { }
+
+ ngOnInit():void {
+ this.subscription = this
+ .currentUserService
+ .hasCapabilities$('file_links/view', this.currentProjectService.id as string)
+ .subscribe((value) => {
+ this.canViewFileLinks = value;
+ });
+ }
+
+ ngOnDestroy():void {
+ this.subscription.unsubscribe();
+ }
}
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.html
index f70a9a48b9e..acb7b149370 100644
--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.html
+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.html
@@ -1,6 +1,6 @@
<div class="op-tab-content--container">
<section data-qa-selector="op-tab-content--tab-section">
- <div *ngIf="($can_view_file_links | async) === false" class="op-tab-content--header">
+ <div *ngIf="!canViewFileLinks" class="op-tab-content--header">
<h3 class="op-tab-content--header-text" [textContent]="text.attachments.label"></h3>
</div>
@@ -9,7 +9,7 @@
<op-attachments-upload [resource]="workPackage"></op-attachments-upload>
</section>
- <section *ngIf="$can_view_file_links | async" data-qa-selector="op-tab-content--tab-section">
+ <section *ngIf="canViewFileLinks" data-qa-selector="op-tab-content--tab-section">
<div class=op-tab-content--header>
<op-icon icon-classes="icon3 icon-nextcloud-circle op-files-tab--color-blue-deep"></op-icon>
<h3 class="op-tab-content--header-text" [textContent]="text.file_links.label"></h3>