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

Allow copy action for agenda items always

Mir Bhatia98019caf7be6
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
index d9bad5eb8cd..b6f30ae04e7 100644
--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
@@ -56,44 +56,42 @@
end
grid.with_area(:actions, tag: :div, justify_self: :end, classes: "hide-when-print") do
- if edit_enabled?
- render(Primer::Alpha::ActionMenu.new) do |menu|
- menu.with_show_button(
- icon: "kebab-horizontal",
- "aria-label": I18n.t(:label_agenda_item_actions),
- scheme: :invisible,
- ml: 2,
- test_selector: "op-meeting-agenda-actions"
- )
-
- edit_action_item(menu) if @meeting_agenda_item.editable?
- if !in_backlog?
- copy_action_item(menu)
- end
+ render(Primer::Alpha::ActionMenu.new) do |menu|
+ menu.with_show_button(
+ icon: "kebab-horizontal",
+ "aria-label": I18n.t(:label_agenda_item_actions),
+ scheme: :invisible,
+ ml: 2,
+ test_selector: "op-meeting-agenda-actions"
+ )
- menu.with_divider if note_or_outcome_action_added?
+ edit_action_item(menu)
+ if !in_backlog?
+ copy_action_item(menu)
+ end
- add_note_action_item(menu) if add_note_action?
- add_outcome_action_item(menu) if add_outcome_action?
+ menu.with_divider if note_or_outcome_action_added? && editable?
- unless first? && last?
- menu.with_divider
- move_actions(menu)
- end
+ add_note_action_item(menu) if add_note_action?
+ add_outcome_action_item(menu) if add_outcome_action?
- menu.with_divider if move_to_different_section_or_meeting_action_added?
+ unless first? && last?
+ menu.with_divider if editable?
+ move_actions(menu)
+ end
- if !in_template? || in_backlog?
- move_to_current_meeting_action_item(menu) if in_backlog?
- move_to_backlog_action_item(menu) if !in_backlog?
- end
- if move_to_next_meeting_enabled?
- move_to_next_meeting_action_item(menu)
- end
+ menu.with_divider if move_to_different_section_or_meeting_action_added?
- menu.with_divider
- delete_action_item(menu)
+ if !in_template? || in_backlog?
+ move_to_current_meeting_action_item(menu) if in_backlog?
+ move_to_backlog_action_item(menu) if !in_backlog?
end
+ if move_to_next_meeting_enabled?
+ move_to_next_meeting_action_item(menu)
+ end
+
+ menu.with_divider if editable?
+ delete_action_item(menu)
end
end
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
index 63a28a98370..81536db65fe 100644
--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
@@ -55,12 +55,12 @@ module MeetingAgendaItems
[email protected]? && User.current.allowed_in_project?(:manage_agendas, @meeting.project)
end
- def edit_enabled?
- [email protected]? && User.current.allowed_in_project?(:manage_agendas, @meeting.project)
+ def can_manage_agendas?
+ User.current.allowed_in_project?(:manage_agendas, @meeting.project)
end
def add_outcome_action?
- @meeting_agenda_item.editable? &&
+ editable? &&
@meeting.in_progress? &&
!@meeting_agenda_item.outcomes.exists? &&
!@meeting_agenda_item.in_backlog? &&
@@ -68,7 +68,7 @@ module MeetingAgendaItems
end
def add_note_action?
- @meeting_agenda_item.editable? && @meeting_agenda_item.notes.blank?
+ editable? && @meeting_agenda_item.notes.blank?
end
def first?
@@ -98,6 +98,8 @@ module MeetingAgendaItems
end
def edit_action_item(menu)
+ return unless editable?
+
menu.with_item(label: t("label_edit"),
href: edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),
content_arguments: {
@@ -139,6 +141,7 @@ module MeetingAgendaItems
end
def move_to_next_meeting_action_item(menu)
+ return unless editable?
return if in_template?
return if @series.nil?
@@ -165,6 +168,8 @@ module MeetingAgendaItems
end
def move_actions(menu)
+ return unless editable?
+
move_action_item(menu, :highest, t("label_agenda_item_move_to_top"), "move-to-top") unless first?
move_action_item(menu, :higher, t("label_agenda_item_move_up"), "chevron-up") unless first?
move_action_item(menu, :lower, t("label_agenda_item_move_down"), "chevron-down") unless last?
@@ -172,6 +177,8 @@ module MeetingAgendaItems
end
def delete_action_item(menu)
+ return unless editable?
+
label = @meeting_agenda_item.work_package_id.present? ? wp_agenda_item_delete_label : t(:text_destroy)
menu.with_item(label:,
scheme: :danger,
@@ -199,6 +206,8 @@ module MeetingAgendaItems
end
def move_to_backlog_action_item(menu)
+ return unless editable?
+
menu.with_item(label: I18n.t(:label_agenda_item_move_to_backlog),
tag: :button,
content_arguments: { data: {
@@ -210,6 +219,8 @@ module MeetingAgendaItems
end
def move_to_current_meeting_action_item(menu)
+ return unless editable?
+
menu.with_item(label: I18n.t(:label_agenda_item_move_to_current_meeting),
tag: :button,
content_arguments: { data: {
@@ -237,7 +248,9 @@ module MeetingAgendaItems
end
def move_to_next_meeting_enabled?
- edit_enabled? && @meeting.recurring? && @meeting.recurring_meeting&.next_occurrence.present? && !in_template?
+ return false unless editable?
+
+ @meeting.recurring? && @meeting.recurring_meeting&.next_occurrence.present? && !in_template?
end
def in_backlog?
@@ -253,7 +266,13 @@ module MeetingAgendaItems
end
def move_to_different_section_or_meeting_action_added?
+ return false unless editable?
+
!in_template? || in_backlog? || move_to_next_meeting_enabled?
end
+
+ def editable?
+ @editable ||= @meeting_agenda_item.editable? && can_manage_agendas?
+ end
end
end
diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb
index ed6c4d75acb..91876bca162 100644
--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb
@@ -13,20 +13,18 @@
end
grid.with_area(:actions, tag: :div, justify_self: :end, classes: "hide-when-print") do
- if edit_enabled?
- render(Primer::Alpha::ActionMenu.new) do |menu|
- menu.with_show_button(
- icon: "kebab-horizontal",
- "aria-label": t(:label_agenda_outcome_actions),
- scheme: :invisible,
- ml: 2,
- test_selector: "op-meeting-outcome-actions"
- )
- edit_action_item(menu)
- copy_action_item(menu)
- menu.with_divider
- delete_action_item(menu)
- end
+ render(Primer::Alpha::ActionMenu.new) do |menu|
+ menu.with_show_button(
+ icon: "kebab-horizontal",
+ "aria-label": t(:label_agenda_outcome_actions),
+ scheme: :invisible,
+ ml: 2,
+ test_selector: "op-meeting-outcome-actions"
+ )
+ edit_action_item(menu)
+ copy_action_item(menu)
+ menu.with_divider if edit_enabled?
+ delete_action_item(menu)
end
end
end
diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.rb b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.rb
index 0ae8ed49010..be8f415a586 100644
--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.rb
@@ -50,7 +50,13 @@ module MeetingAgendaItems
!@agenda_item.in_backlog?
end
+ def in_backlog?
+ @agenda_item.meeting_section.backlog?
+ end
+
def edit_action_item(menu)
+ return unless edit_enabled?
+
menu.with_item(label: t("label_agenda_outcome_edit"),
href: edit_meeting_outcome_path(@meeting, @meeting_outcome),
content_arguments: {
@@ -61,6 +67,8 @@ module MeetingAgendaItems
end
def copy_action_item(menu)
+ return if in_backlog?
+
url = meeting_url(@meeting, anchor: "outcome-#{@meeting_outcome.id}")
menu.with_item(label: t("button_copy_link_to_clipboard"),
tag: :"clipboard-copy",
@@ -70,6 +78,8 @@ module MeetingAgendaItems
end
def delete_action_item(menu)
+ return unless edit_enabled?
+
menu.with_item(label: t("label_agenda_outcome_delete"),
scheme: :danger,
href: meeting_outcome_path(@meeting, @meeting_outcome),
diff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb
index 80e4c362586..1ffe5dae530 100644
--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb
+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb
@@ -128,7 +128,11 @@ RSpec.describe "Recurring meetings move to next meeting", :js do
it "does not show the move to next meeting option" do
meeting_page.expect_agenda_item(title: "Test notes")
- meeting_page.expect_no_agenda_action_menu(agenda_item)
+
+ meeting_page.open_menu(agenda_item) do
+ expect(page).to have_no_css(".ActionListItem-label", text: "Move to next meeting")
+ expect(page).to have_css(".ActionListItem-label", count: 1)
+ end
end
end
end
diff --git a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
index 02be677f193..a2c48c14dbc 100644
--- a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
+++ b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
@@ -202,12 +202,17 @@ RSpec.describe "Meetings CRUD",
expect(page).to have_css("#meeting-agenda-items-new-button-component")
expect(page).to have_test_selector("op-meeting-agenda-actions", count: 3)
- # other_use can view, but not edit
+ # other_use can view and copy links, but not edit
login_as other_user
show_page.visit!
expect(page).to have_no_css("#meeting-agenda-items-new-button-component")
- expect(page).not_to have_test_selector("op-meeting-agenda-actions")
+ expect(page).to have_test_selector("op-meeting-agenda-actions", count: 3)
+
+ show_page.open_menu(second) do
+ expect(page).to have_css(".ActionListItem-label", text: "Copy to clipboard")
+ expect(page).to have_css(".ActionListItem-label", count: 1)
+ end
end
it "can delete a meeting and get back to the index page" do