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 new Primer::OpenProject::SubHeader component in Meetings and ProjectList and replace the outdated FilterComponent with that

Henriette Dargebbfd40025e79
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb
index 37faffb8bee..2bc845af85b 100644
--- a/app/views/projects/index.html.erb
+++ b/app/views/projects/index.html.erb
@@ -38,28 +38,35 @@ See COPYRIGHT and LICENSE files for more details.
)
)
%>
-
<%=
disable_extra_controls = state == :rename
- render(Projects::ProjectsFiltersComponent.new(query:, disabled: disable_extra_controls)) do |component|
- if current_user.allowed_globally?(:add_project)
- component.with_button(
- tag: :a,
- href: new_project_path,
- scheme: :primary,
- disabled: disable_extra_controls,
- 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
+ render(Primer::OpenProject::SubHeader.new(data: {
+ controller: "filters",
+ "application-target": "dynamic",
+ "filters-display-filters-value": true, # TODO: show_filters_section?,
+ })) do |subheader|
+ subheader.with_filter_component do
+ render(Filter::FilterButtonComponent.new(query:))
+ end
+
+ subheader.with_action_button(tag: :a,
+ href: new_project_path,
+ scheme: :primary,
+ disabled: disable_extra_controls,
+ 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 if current_user.allowed_globally?(:add_project)
+
+ subheader.with_bottom_pane_component(mt: 0) do
+ render(Projects::ProjectsFiltersComponent.new(query:, disabled: disable_extra_controls))
end
end
%>
-
<%= render Projects::TableComponent.new(
query:,
current_user: current_user,
diff --git a/modules/meeting/app/components/meetings/index_page_header_component.html.erb b/modules/meeting/app/components/meetings/index_page_header_component.html.erb
index 7c1db02b469..9b6787bd672 100644
--- a/modules/meeting/app/components/meetings/index_page_header_component.html.erb
+++ b/modules/meeting/app/components/meetings/index_page_header_component.html.erb
@@ -1,18 +1,4 @@
<%= render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { page_title }
header.with_breadcrumbs(breadcrumb_items)
- if render_create_button?
- header.with_action_button(tag: :a,
- href: dynamic_path,
- scheme: :primary,
- mobile_icon: :plus,
- mobile_label: label_text,
- aria: { label: accessibility_label_text },
- title: accessibility_label_text,
- id: id,
- test_selector: "add-meeting-button") do |button|
- button.with_leading_visual_icon(icon: :plus)
- label_text
- end
- end
end %>
diff --git a/modules/meeting/app/components/meetings/index_page_header_component.rb b/modules/meeting/app/components/meetings/index_page_header_component.rb
index e17a3ca8f37..6cd8a338a6f 100644
--- a/modules/meeting/app/components/meetings/index_page_header_component.rb
+++ b/modules/meeting/app/components/meetings/index_page_header_component.rb
@@ -30,7 +30,6 @@
module Meetings
class IndexPageHeaderComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
include ApplicationHelper
def initialize(project: nil)
@@ -38,30 +37,6 @@ module Meetings
@project = project
end
- def render_create_button?
- if @project
- User.current.allowed_in_project?(:create_meetings, @project)
- else
- User.current.allowed_in_any_project?(:create_meetings)
- end
- end
-
- def dynamic_path
- polymorphic_path([:new, @project, :meeting])
- end
-
- def id
- "add-meeting-button"
- end
-
- def accessibility_label_text
- I18n.t(:label_meeting_new)
- end
-
- def label_text
- I18n.t(:label_meeting)
- end
-
def page_title
I18n.t(:label_meeting_plural)
end
diff --git a/modules/meeting/app/components/meetings/index_sub_header_component.html.erb b/modules/meeting/app/components/meetings/index_sub_header_component.html.erb
new file mode 100644
index 00000000000..2f8a63a3c77
--- /dev/null
+++ b/modules/meeting/app/components/meetings/index_sub_header_component.html.erb
@@ -0,0 +1,27 @@
+<%= render(Primer::OpenProject::SubHeader.new(data: {
+ controller: "filters",
+ "application-target": "dynamic",
+ "filters-display-filters-value": false, # TODO: show_filters_section?,
+ "filters-output-format-value": "json",
+})) do |subheader|
+ subheader.with_filter_component do
+ render(Meetings::MeetingFilterButtonComponent.new(query: @query, project: @project))
+ end
+
+ subheader.with_action_button(tag: :a,
+ href: dynamic_path,
+ scheme: :primary,
+ mobile_icon: :plus,
+ mobile_label: label_text,
+ aria: { label: accessibility_label_text },
+ title: accessibility_label_text,
+ id: id,
+ test_selector: "add-meeting-button") do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ label_text
+ end if render_create_button?
+
+ subheader.with_bottom_pane_component(mt: 0) do
+ render(Meetings::MeetingFiltersComponent.new(query: @query, project: @project))
+ end
+end %>
diff --git a/modules/meeting/app/components/meetings/index_sub_header_component.rb b/modules/meeting/app/components/meetings/index_sub_header_component.rb
new file mode 100644
index 00000000000..21c17659f10
--- /dev/null
+++ b/modules/meeting/app/components/meetings/index_sub_header_component.rb
@@ -0,0 +1,67 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2010-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+# ++
+
+module Meetings
+ # rubocop:disable OpenProject/AddPreviewForViewComponent
+ class IndexSubHeaderComponent < ApplicationComponent
+ # rubocop:enable OpenProject/AddPreviewForViewComponent
+ include ApplicationHelper
+
+ def initialize(query:, project: nil)
+ super
+ @query = query
+ @project = project
+ end
+
+ def render_create_button?
+ if @project
+ User.current.allowed_in_project?(:create_meetings, @project)
+ else
+ User.current.allowed_in_any_project?(:create_meetings)
+ end
+ end
+
+ def dynamic_path
+ polymorphic_path([:new, @project, :meeting])
+ end
+
+ def id
+ "add-meeting-button"
+ end
+
+ def accessibility_label_text
+ I18n.t(:label_meeting_new)
+ end
+
+ def label_text
+ I18n.t(:label_meeting)
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/meeting_filter_button_component.rb b/modules/meeting/app/components/meetings/meeting_filter_button_component.rb
new file mode 100644
index 00000000000..954d482d97e
--- /dev/null
+++ b/modules/meeting/app/components/meetings/meeting_filter_button_component.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2010-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+# ++
+module Meetings
+ # rubocop:disable OpenProject/AddPreviewForViewComponent
+ class MeetingFilterButtonComponent < Filter::FilterButtonComponent
+ # rubocop:enable OpenProject/AddPreviewForViewComponent
+ options :project
+ def filters_count
+ @filters_count ||= begin
+ count = super
+ count -= 1 if project.present?
+
+ count
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/meeting_filters_component.rb b/modules/meeting/app/components/meetings/meeting_filters_component.rb
index 03cef407932..8c333aa7cb5 100644
--- a/modules/meeting/app/components/meetings/meeting_filters_component.rb
+++ b/modules/meeting/app/components/meetings/meeting_filters_component.rb
@@ -39,15 +39,6 @@ module Meetings
.sort_by(&:human_name)
end
- def filters_count
- @filters_count ||= begin
- count = super
- count -= 1 if project.present?
-
- count
- end
- end
-
protected
def additional_filter_attributes(filter)
diff --git a/modules/meeting/app/views/meetings/index.html.erb b/modules/meeting/app/views/meetings/index.html.erb
index cde9cfb053f..1f1e9233458 100644
--- a/modules/meeting/app/views/meetings/index.html.erb
+++ b/modules/meeting/app/views/meetings/index.html.erb
@@ -29,8 +29,7 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_meeting_plural) %>
<%= render(Meetings::IndexPageHeaderComponent.new(project: @project)) %>
-
-<%= render(Meetings::MeetingFiltersComponent.new(query: @query, project: @project, output_format: 'json')) %>
+<%= render(Meetings::IndexSubHeaderComponent.new(query: @query, project: @project)) %>
<% if @meetings.empty? -%>
<%= no_results_box %>