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

Extract NewButtonComponent view into erb

Oliver Günther1eae660a0275
diff --git a/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb
new file mode 100644
index 00000000000..98216da4f96
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb
@@ -0,0 +1,26 @@
+<%=
+ component_wrapper(class: "mt-3") do
+ render(Primer::Alpha::ActionMenu.new) do |component|
+ component.with_show_button(scheme: :primary, disabled: @disabled) do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ t("button_add")
+ end
+ component.with_item(
+ label: t("activerecord.models.meeting_agenda_item", count: 1),
+ tag: :a,
+ content_arguments: {
+ href: new_meeting_agenda_item_path(@meeting, type: "simple"),
+ data: { 'turbo-stream': true }
+ }
+ )
+ component.with_item(
+ label: t("activerecord.models.work_package", count: 1),
+ tag: :a,
+ content_arguments: {
+ href: new_meeting_agenda_item_path(@meeting, type: "work_package"),
+ data: { 'turbo-stream': true }
+ }
+ )
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb b/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb
index d40be4f2262..fad828af3c2 100644
--- a/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb
@@ -40,41 +40,8 @@ module MeetingAgendaItems
@disabled = @meeting.closed? || disabled
end
- def call
- component_wrapper(class: "mt-3") do
- menu_content_partial
- end
- end
-
def render?
User.current.allowed_to?(:edit_meetings, @meeting.project)
end
-
- private
-
- def menu_content_partial
- render(Primer::Alpha::ActionMenu.new) do |component|
- component.with_show_button(scheme: :primary, disabled: @disabled) do |button|
- button.with_leading_visual_icon(icon: :plus)
- t("button_add")
- end
- component.with_item(
- label: t("activerecord.models.meeting_agenda_item", count: 1),
- tag: :a,
- content_arguments: {
- href: new_meeting_agenda_item_path(@meeting, type: "simple"),
- data: { 'turbo-stream': true }
- }
- )
- component.with_item(
- label: t("activerecord.models.work_package", count: 1),
- tag: :a,
- content_arguments: {
- href: new_meeting_agenda_item_path(@meeting, type: "work_package"),
- data: { 'turbo-stream': true }
- }
- )
- end
- end
end
end