Guard the Allocate action behind the allocate_user_resources permission

This commit is contained in:
Klaus Zanders
2026-06-09 16:22:28 +02:00
parent 4020444b64
commit 121fe536d8
2 changed files with 16 additions and 8 deletions
@@ -49,13 +49,15 @@ See COPYRIGHT and LICENSE files for more details.
"aria-label": t("resource_management.work_package_list.subheader.add")
}
) do |menu|
menu.with_item(
label: t("resource_management.work_package_list.subheader.allocate"),
tag: :a,
href: new_project_resource_allocation_path(@project),
content_arguments: { data: { controller: "async-dialog" } }
) do |item|
item.with_leading_visual_icon(icon: :people)
if allowed_to_allocate?
menu.with_item(
label: t("resource_management.work_package_list.subheader.allocate"),
tag: :a,
href: new_project_resource_allocation_path(@project),
content_arguments: { data: { controller: "async-dialog" } }
) do |item|
item.with_leading_visual_icon(icon: :people)
end
end
menu.with_item(
@@ -67,7 +69,7 @@ See COPYRIGHT and LICENSE files for more details.
item.with_leading_visual_icon(icon: :"op-relations")
end
end
else
elsif allowed_to_allocate?
subheader.with_action_button(
leading_icon: :plus,
scheme: :primary,
@@ -38,5 +38,11 @@ module ResourcePlannerViews::WorkPackageList
@resource_planner = resource_planner
@view = view
end
private
def allowed_to_allocate?
User.current.allowed_in_project?(:allocate_user_resources, @project)
end
end
end