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

use renders_many to make it possible adding more button in the future

Behrokh Satarnejad60a471d5caec
diff --git a/app/components/projects/filters_component.html.erb b/app/components/projects/filters_component.html.erb
index e2e851f2ca0..6b5827185f7 100644
--- a/app/components/projects/filters_component.html.erb
+++ b/app/components/projects/filters_component.html.erb
@@ -15,21 +15,10 @@
<%= render(Primer::Beta::Counter.new(count: query.filters.count, round: true, hide_if_zero: false, scheme: :default)) %>
<% end %>
- <% if helpers.current_user.allowed_globally?(:add_project) %>
- <%= render(
- Primer::Beta::Button.new(
- tag: :a,
- href: new_project_path,
- scheme: :primary,
- size: :medium,
- aria: { label: I18n.t(:label_project_new) },
- data: { 'test-selector': 'project-new-button' }
- )
- ) do |button|
- button.with_leading_visual_icon(icon: :plus)
- Project.model_name.human
- end
- %>
+ <% buttons.each do |button| %>
+ <div>
+ <%= button %>
+ </div>
<% end %>
</div>
<%= form_tag({},
diff --git a/app/components/projects/filters_component.rb b/app/components/projects/filters_component.rb
index c25894c717b..4815a91c1c0 100644
--- a/app/components/projects/filters_component.rb
+++ b/app/components/projects/filters_component.rb
@@ -30,7 +30,11 @@
class Projects::FiltersComponent < ApplicationComponent
options :query
-
+
+ renders_many :buttons, lambda { |**system_arguments|
+ Primer::Beta::Button.new(**system_arguments)
+ }
+
def allowed_filters
query
.available_filters
diff --git a/app/components/projects/index_page_header_component.html.erb b/app/components/projects/index_page_header_component.html.erb
index 8dd54f25d31..db4df08905b 100644
--- a/app/components/projects/index_page_header_component.html.erb
+++ b/app/components/projects/index_page_header_component.html.erb
@@ -2,8 +2,6 @@
<% header.with_title(variant: :large) { t(:label_project_plural) } %>
<% header.with_actions do %>
-
-
<%= render(
Primer::Beta::Button.new(
tag: :a,
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb
index e23c06a01ac..c0d966ca951 100644
--- a/app/views/projects/index.html.erb
+++ b/app/views/projects/index.html.erb
@@ -37,9 +37,24 @@ See COPYRIGHT and LICENSE files for more details.
current_user:
) %>
- <%= render Projects::FiltersComponent.new(
+ <%= render (Projects::FiltersComponent.new(
query: @query,
- ) %>
+ ) ) do |component|
+
+ if current_user.allowed_globally?(:add_project)
+ component.with_button(
+ tag: :a,
+ href: new_project_path,
+ scheme: :primary,
+ size: :medium,
+ aria: { label: I18n.t(:label_project_new) },
+ data: { 'test-selector': 'project-new-button' }) do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ Project.model_name.human
+ end
+ end
+ end
+ %>
<%= render Projects::TableComponent.new(
rows: @projects,