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

Fix create button permissions

Oliver Günther5652abfee23f
diff --git a/frontend/src/app/components/wp-buttons/wp-create-button/wp-create-button.component.ts b/frontend/src/app/components/wp-buttons/wp-create-button/wp-create-button.component.ts
index decc46743b2..7a79cea8a18 100644
--- a/frontend/src/app/components/wp-buttons/wp-create-button/wp-create-button.component.ts
+++ b/frontend/src/app/components/wp-buttons/wp-create-button/wp-create-button.component.ts
@@ -62,14 +62,16 @@ export class WorkPackageCreateButtonComponent implements OnInit, OnDestroy {
this.projectIdentifier = this.currentProject.identifier;
// Created for interface compliance
-
+ // Find the first permission that is allowed
this.authorisationService
.observeUntil(componentDestroyed(this))
.subscribe(() => {
- this.allowed = this
+ this.allowed = !!this
.allowedWhen
- .filter(value => this.authorisationService.can('work_packages', value))
- .length === this.allowedWhen.length;
+ .find(combined => {
+ let [module, permission] = combined.split('.');
+ return this.authorisationService.can(module, permission);
+ });
});
}
diff --git a/frontend/src/app/modules/work_packages/routing/wp-full-view/wp-full-view.html b/frontend/src/app/modules/work_packages/routing/wp-full-view/wp-full-view.html
index 60d9c41b3ac..fb60ed108e0 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-full-view/wp-full-view.html
+++ b/frontend/src/app/modules/work_packages/routing/wp-full-view/wp-full-view.html
@@ -25,7 +25,7 @@
<ul id="toolbar-items" class="toolbar-items hide-when-print">
<li class="toolbar-item hidden-for-mobile">
<wp-create-button
- [allowed]="['addChild', 'copy']"
+ [allowed]="['work_package.addChild', 'work_package.copy']"
stateName="work-packages.new">
</wp-create-button>
</li>
diff --git a/frontend/src/app/modules/work_packages/routing/wp-view-page/wp-view-page.component.ts b/frontend/src/app/modules/work_packages/routing/wp-view-page/wp-view-page.component.ts
index 9b79e25bf06..56d6ec237f5 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-view-page/wp-view-page.component.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-view-page/wp-view-page.component.ts
@@ -71,7 +71,7 @@ export class WorkPackageViewPageComponent extends PartitionedQuerySpacePageCompo
component: WorkPackageCreateButtonComponent,
inputs: {
stateName: "work-packages.partitioned.list.new",
- allowed: ['createWorkPackage']
+ allowed: ['work_packages.createWorkPackage']
}
},
{