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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Use Primer::OpenProject::PageHeader for the members page
Henriette Darge97a415b93b70
diff --git a/app/components/members/index_page_header_component.html.erb b/app/components/members/index_page_header_component.html.erbnew file mode 100644index 00000000000..d4ef90b5aa2--- /dev/null+++ b/app/components/members/index_page_header_component.html.erb@@ -0,0 +1,40 @@+<%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title(variant: :large) { t(:label_member_plural) }++ header.with_actions do+ flex_layout do |actions|+ if User.current.allowed_in_project?(:manage_members, @project)+ actions.with_column(mr: BUTTON_MARGIN_RIGHT) do+ render(+ Primer::Beta::Button.new(+ tag: :a,+ scheme: :primary,+ size: :medium,+ aria: { label: I18n.t(:button_add_member) },+ title: I18n.t(:button_add_member),+ id: 'add-member-button',+ data: add_button_data_attributes+ )+ ) do |button|+ button.with_leading_visual_icon(icon: :plus)+ t('activerecord.models.member')+ end+ end+ end++ actions.with_column do+ render(+ Primer::Beta::IconButton.new(+ icon: 'filter',+ id: 'filter-member-button',+ aria: { label: I18n.t(:description_filter) },+ class: 'toggle-member-filter-link',+ data: filter_button_data_attributes+ )+ )+ end+ end+ end+ end+%>diff --git a/app/components/members/index_page_header_component.rb b/app/components/members/index_page_header_component.rbnew file mode 100644index 00000000000..689eb40daab--- /dev/null+++ b/app/components/members/index_page_header_component.rb@@ -0,0 +1,60 @@+# 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.+# ++++class Members::IndexPageHeaderComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers+ include ApplicationHelper++ BUTTON_MARGIN_RIGHT = 2++ def initialize(project: nil)+ super+ @project = project+ end++ def add_button_data_attributes+ attributes = {+ 'members-form-target': 'addMemberButton',+ action: 'members-form#showAddMemberForm',+ 'test-selector': 'member-add-button'+ }++ attributes['trigger-initially'] = "true" if params[:show_add_members]++ attributes+ end++ def filter_button_data_attributes+ {+ 'members-form-target': 'filterMemberButton',+ action: 'members-form#toggleMemberFilter'+ }+ end+enddiff --git a/app/views/members/index.html.erb b/app/views/members/index.html.erbindex 74581ed6e5a..a7845472b29 100644--- a/app/views/members/index.html.erb+++ b/app/views/members/index.html.erb@@ -28,35 +28,12 @@ See COPYRIGHT and LICENSE files for more details.++#%><% html_title t(:label_member_plural) -%>++<div data-controller="members-form"- data-application-target="dynamic">+ data-application-target="dynamic">- <%= toolbar title: t(:label_member_plural) do %>- <% if authorize_for(:members, :new) %>- <li class="toolbar-item">- <button id="add-member-button"- data-members-form-target="addMemberButton"- data-action="members-form#showAddMemberForm"- aria-label="<%= I18n.t(:button_add_member) %>"- title="<%= I18n.t(:button_add_member) %>"- class="button -alt-highlight"- <%= params[:show_add_members] ? 'data-trigger-initially="true"' : '' %> >- <%= op_icon('button--icon icon-add') %>- <span class="button--text"><%= t('activerecord.models.member') %></span>- </button>- </li>- <% end %>- <li class="toolbar-item">- <button id="filter-member-button"- data-members-form-target="filterMemberButton"- data-action="members-form#toggleMemberFilter"- focus- title="<%= I18n.t(:description_filter) %>"- class="toggle-member-filter-link button">- <%= op_icon('button--icon icon-filter') %>- </button>- </li>- <% end %>+ <%= render ::Members::IndexPageHeaderComponent.new(project: @project) %><%= error_messages_for 'member' %>diff --git a/spec/features/members/invitation_spec.rb b/spec/features/members/invitation_spec.rbindex 53629341fb9..8a6ac7c17b2 100644--- a/spec/features/members/invitation_spec.rb+++ b/spec/features/members/invitation_spec.rb@@ -53,7 +53,7 @@ RSpec.describe 'invite user via email', :js doit 'adds the invited user to the project' domembers_page.visit!- click_on 'Add member'+ members_page.open_new_member!members_page.search_and_select_principal! '[email protected]','Send invite to [email protected]'@@ -81,7 +81,7 @@ RSpec.describe 'invite user via email', :js doit 'shows a warning when the limit is reached' domembers_page.visit!- click_button 'Add member'+ members_page.open_new_member!members_page.search_and_select_principal! '[email protected]','Send invite to [email protected]'@@ -110,7 +110,7 @@ RSpec.describe 'invite user via email', :js domembers_page.visit!retry_block do- click_on 'Add member'+ members_page.open_new_member!find_by_id('members_add_form')end@@ -128,7 +128,7 @@ RSpec.describe 'invite user via email', :js doshared_examples 'no user to invite is found' doit 'no matches found' domembers_page.visit!- click_on 'Add member'+ members_page.open_new_member!members_page.search_principal! '[email protected]'expect(members_page).to have_no_search_resultsdiff --git a/spec/support/pages/members.rb b/spec/support/pages/members.rbindex 227aee8d712..32a757092c2 100644--- a/spec/support/pages/members.rb+++ b/spec/support/pages/members.rb@@ -51,7 +51,7 @@ module Pagesenddef open_new_member!- click_on 'Add member'+ page.find('[data-test-selector="member-add-button"]').clickenddef open_filters!@@ -84,7 +84,7 @@ module Pages# @param as [String] The role as which the user should be added.def add_user!(user_name, as:)retry_block do- click_on 'Add member'+ open_new_member!select_principal! user_name if user_nameselect_role! as if as