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

Add permission check for backlog header actions

Mir Bhatia82140bdce327
diff --git a/modules/meeting/app/components/meeting_sections/backlogs/header_component.html.erb b/modules/meeting/app/components/meeting_sections/backlogs/header_component.html.erb
index 3ea531312c5..049fc7e30f7 100644
--- a/modules/meeting/app/components/meeting_sections/backlogs/header_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/backlogs/header_component.html.erb
@@ -13,13 +13,15 @@
end
end
- flex.with_column(classes: "hide-when-print") do
- render(Primer::Alpha::ActionMenu.new(data: { test_selector: "meeting-section-action-menu" })) do |menu|
- menu.with_show_button(icon: "kebab-horizontal", "aria-label": t("settings.project_attributes.label_section_actions"), scheme: :invisible)
- add_agenda_item_action(menu)
- add_work_package_action(menu)
- menu.with_divider
- clear_action_item(menu)
+ if edit_enabled?
+ flex.with_column(classes: "hide-when-print") do
+ render(Primer::Alpha::ActionMenu.new(data: { test_selector: "meeting-section-action-menu" })) do |menu|
+ menu.with_show_button(icon: "kebab-horizontal", "aria-label": t("settings.project_attributes.label_section_actions"), scheme: :invisible)
+ add_agenda_item_action(menu)
+ add_work_package_action(menu)
+ menu.with_divider
+ clear_action_item(menu)
+ end
end
end
end
diff --git a/modules/meeting/app/components/meeting_sections/backlogs/header_component.rb b/modules/meeting/app/components/meeting_sections/backlogs/header_component.rb
index fa250597adc..0f2107d9c6f 100644
--- a/modules/meeting/app/components/meeting_sections/backlogs/header_component.rb
+++ b/modules/meeting/app/components/meeting_sections/backlogs/header_component.rb
@@ -75,6 +75,10 @@ module MeetingSections
end
end
+ def edit_enabled?
+ [email protected]? && User.current.allowed_in_project?(:manage_agendas, @meeting.project)
+ end
+
def clear_action_item(menu)
menu.with_item(
label: I18n.t(:label_backlog_clear),
diff --git a/modules/meeting/spec/features/meeting_backlogs_spec.rb b/modules/meeting/spec/features/meeting_backlogs_spec.rb
index 957196aa738..b13f41707cc 100644
--- a/modules/meeting/spec/features/meeting_backlogs_spec.rb
+++ b/modules/meeting/spec/features/meeting_backlogs_spec.rb
@@ -41,6 +41,12 @@ RSpec.describe "Meeting Backlogs", :js, with_flag: { meeting_backlogs: true } do
preferences: { time_zone: "Etc/UTC" },
member_with_permissions: { project => %i[view_meetings manage_agendas close_meeting_agendas create_meeting_minutes] }
end
+ shared_let(:reader) do
+ create :user,
+ lastname: "Reader",
+ preferences: { time_zone: "Etc/UTC" },
+ member_with_permissions: { project => %i[view_meetings] }
+ end
shared_let(:meeting) do
create :meeting,
project:,
@@ -468,4 +474,16 @@ RSpec.describe "Meeting Backlogs", :js, with_flag: { meeting_backlogs: true } do
end
end
end
+
+ describe "a user without permissions" do
+ before do
+ login_as reader
+ end
+
+ it "cannot see the backlog header actions" do
+ show_page.visit!
+
+ show_page.expect_no_backlog_header_actions
+ end
+ end
end
diff --git a/modules/meeting/spec/support/pages/meetings/show.rb b/modules/meeting/spec/support/pages/meetings/show.rb
index 5c29bb61b74..50d2667809e 100644
--- a/modules/meeting/spec/support/pages/meetings/show.rb
+++ b/modules/meeting/spec/support/pages/meetings/show.rb
@@ -578,6 +578,12 @@ module Pages::Meetings
end
end
+ def expect_no_backlog_header_actions
+ within_backlog do
+ expect { page.find_test_selector("meeting-section-action-menu") }.to raise_error(Capybara::ElementNotFound)
+ end
+ end
+
def expect_blankslate
expect(page).to have_test_selector("meeting-blankslate")
end