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
[#47010] Replace Members Cells by ViewComponent
Dombi Attila1d541f823731
diff --git a/app/cells/members/role_form_cell.rb b/app/cells/members/role_form_cell.rbdeleted file mode 100644index e5ac43b1aef..00000000000--- a/app/cells/members/role_form_cell.rb+++ /dev/null@@ -1,38 +0,0 @@-module Members- class RoleFormCell < ::RailsCell- include RemovedJsHelpersHelper-- options :row, :params, :roles-- def member- model- end-- def form_url- url_for form_url_hash- end-- def form_url_hash- {- controller: '/members',- action: 'update',- id: member.id,- page: params[:page],- per_page: params[:per_page]- }- end-- def role_checkbox(role)- check_box_tag 'member[role_ids][]',- role.id,- member.roles.include?(role),- disabled: role_disabled?(role)- end-- def role_disabled?(role)- member- .member_roles- .detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? }- end- end-enddiff --git a/app/cells/members/user_filter_cell.rb b/app/cells/members/user_filter_cell.rbdeleted file mode 100644index 6dfea227bea..00000000000--- a/app/cells/members/user_filter_cell.rb+++ /dev/null@@ -1,39 +0,0 @@-module Members- class UserFilterCell < ::UserFilterCell- def initially_visible?- false- end-- def has_close_icon?- true- end-- ##- # Adapts the user filter counts to count members as opposed to users.- def extra_user_status_options- {- all: status_members_query('all').count,- blocked: status_members_query('blocked').count,- active: status_members_query('active').count,- invited: status_members_query('invited').count,- registered: status_members_query('registered').count,- locked: status_members_query('locked').count- }- end-- def status_members_query(status)- params = { project_id: project.id,- status: }-- self.class.filter(params)- end-- def filter_path- project_members_path(project)- end-- def self.base_query- Queries::Members::MemberQuery- end- end-enddiff --git a/app/cells/views/members/role_form/show.erb b/app/cells/views/members/role_form/show.erbdeleted file mode 100644index 59e9ba43fc9..00000000000--- a/app/cells/views/members/role_form/show.erb+++ /dev/null@@ -1,27 +0,0 @@-<%# We're not using the rails form helper here on purpose.- # It simply doesn't mix at all with cells views.- #%>-<form action="<%= form_url %>"- method="post"- id="<%= row.roles_css_id %>-form"- class="<%= row.toggle_item_class_name %>"- style="display:none"- accept-charset="UTF-8"->- <input name="utf8" type="hidden" value="✓">- <input type="hidden" name="_method" value="put">- <input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>">- <p>- <% roles.each do |role| %>- <label><%= role_checkbox(role) %> <%= h role %></label>- <% end %>- </p>- <%= hidden_field_tag "member[role_ids][]", "" %>- <p>- <%= submit_tag t(:button_change), class: "button -highlight -small" %>- <%= link_to t(:button_cancel),- '#',- data: { 'toggle-target': ".#{row.toggle_item_class_name}" },- class: 'button -small toggle-membership-button' %>- </p>-</form>diff --git a/app/components/activities/days_component.html.erb b/app/components/activities/days_component.html.erbindex 3e55eedb82d..b9af3266dff 100644--- a/app/components/activities/days_component.html.erb+++ b/app/components/activities/days_component.html.erb@@ -1,3 +1,32 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-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.++++#%>+<div class="op-activity-days"><% events_by_day_sorted_by_newest_first.each do |day, events| %><%= content_tag(@header_tag, helpers.format_activity_day(day), class: 'op-activity-days--header') %>diff --git a/app/components/activities/item_component.html.erb b/app/components/activities/item_component.html.erbindex 77553bd761d..74d18e17dbd 100644--- a/app/components/activities/item_component.html.erb+++ b/app/components/activities/item_component.html.erb@@ -1,3 +1,32 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-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.++++#%>+<li class="op-activity-list--item"><div class="op-activity-list--item-title"><%= link_to @event.event_title.squish, @event.event_path %>diff --git a/app/components/activities/item_subtitle_component.html.erb b/app/components/activities/item_subtitle_component.html.erbindex c01dbdfecd1..50b43e3490f 100644--- a/app/components/activities/item_subtitle_component.html.erb+++ b/app/components/activities/item_subtitle_component.html.erb@@ -1,3 +1,32 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-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.++++#%>+<div class="op-activity-list--item-subtitle"><%=I18n.t(i18n_key,diff --git a/app/components/individual_principal_base_filter_component.html.erb b/app/components/individual_principal_base_filter_component.html.erbnew file mode 100644index 00000000000..362bd968e20--- /dev/null+++ b/app/components/individual_principal_base_filter_component.html.erb@@ -0,0 +1,91 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-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.++++#%>++<%= form_tag(filter_path, method: :get) do %>+ <% collapsed_class = initially_visible? ? '' : 'collapsed' %>+ <fieldset class="simple-filters--container <%= collapsed_class %>">+ <legend><%= t(:label_filter_plural) %></legend>+ <% if has_close_icon? %>+ <a title="<%= t('js.close_form_title') %>"+ class="toggle-member-filter-link simple-filters--close icon-context icon-close">+ </a>+ <% end %>+ <ul class="simple-filters--filters">+ <% if has_statuses? %>+ <li class="simple-filters--filter">+ <label class='simple-filters--filter-name' for='status'><%= User.human_attribute_name(:status) %>:</label>+ <%= select_tag 'status', user_status_options, class: 'simple-filters--filter-value' %>+ </li>+ <% end %>+ <% if has_groups? %>+ <li class="simple-filters--filter">+ <label class='simple-filters--filter-name' for='group_id'><%= Group.model_name.human %>:</label>+ <%= collection_select :group,+ :id,+ groups,+ :id,+ :name,+ { include_blank: true,+ selected: params[:group_id].to_i },+ { name: "group_id",+ class: 'simple-filters--filter-value' } %>+ </li>+ <% end %>+ <% if roles.present? %>+ <li class="simple-filters--filter">+ <label class='simple-filters--filter-name' for='role_id'><%= Role.model_name.human %>:</label>+ <%=+ collection_select(+ :role,+ :id,+ roles,+ :id,+ :name,+ {+ include_blank: true,+ selected: params[:role_id].to_i+ },+ {+ name: "role_id",+ class: 'simple-filters--filter-value'+ })+ %>+ </li>+ <% end %>+ <li class="simple-filters--filter">+ <label class='simple-filters--filter-name' for='name'><%= User.human_attribute_name :name %>:</label>+ <%= text_field_tag 'name', params[:name], class: 'simple-filters--filter-value' %>+ </li>+ <li class="simple-filters--controls">+ <%= submit_tag t(:button_apply), class: 'button -highlight -small', name: nil %>+ <%= link_to t(:button_clear), clear_url, class: 'button -small -with-icon icon-undo' %>+ </li>+ </ul>+ </fieldset>+<% end %>diff --git a/app/components/individual_principal_base_filter_component.rb b/app/components/individual_principal_base_filter_component.rbnew file mode 100644index 00000000000..5e1eb9bd369--- /dev/null+++ b/app/components/individual_principal_base_filter_component.rb@@ -0,0 +1,115 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-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-2017 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 IndividualPrincipalBaseFilterComponent < RailsComponent+ include UsersHelper+ include ActionView::Helpers::FormOptionsHelper++ class << self+ def query(params)+ q = base_query.new++ apply_filters(params, q)++ q+ end++ def filter(params)+ query(params).results+ end++ def filtered?(params)+ %i(name status group_id role_id).any? { |name| params[name].present? }+ end++ def filter_name(query, name)+ if name.present?+ query.where(:any_name_attribute, '~', name)+ end+ end++ def filter_group(query, group_id)+ if group_id.present?+ query.where(:group, '=', group_id)+ end+ end++ def filter_role(query, role_id)+ if role_id.present?+ query.where(:role_id, '=', role_id)+ end+ end++ def filter_project(query, project_id)+ if project_id.present?+ query.where(:project_id, '=', project_id)+ end+ end++ def base_query+ raise NotImplementedError+ end++ protected++ def apply_filters(params, query)+ filter_project query, params[:project_id]+ filter_name query, params[:name]+ filter_group query, params[:group_id]+ filter_role query, params[:role_id]++ query+ end+ end++ # INSTANCE METHODS:++ def filter_path+ raise NotImplementedError+ end++ def initially_visible?+ true+ end++ def has_close_icon?+ false+ end++ def has_statuses?+ defined?(status)+ end++ def has_groups?+ defined?(groups) && groups.present?+ end++ def params+ model+ end+enddiff --git a/app/components/members/role_form_component.html.erb b/app/components/members/role_form_component.html.erbnew file mode 100644index 00000000000..175edcd9eed--- /dev/null+++ b/app/components/members/role_form_component.html.erb@@ -0,0 +1,55 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-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.++++#%>++<%= form_with model: member, builder: TabularFormBuilder, html: form_html_options do |f| %>+ <%= hidden_field_tag :page, params[:page].to_i %>+ <%= hidden_field_tag :per_page, params[:per_page].to_i %>++ <p>+ <% roles.each do |role| %>+ <label class="form--label-with-check-box">+ <%= f.collection_check_box :role_ids,+ role.id,+ member.roles.include?(role),+ role.name,+ no_label: true+ %>+ <%= role %>+ </label>+ <% end %>+ </p>++ <p>+ <%= f.submit t(:button_change), class: "button -highlight -small" %>+ <%= link_to t(:button_cancel),+ '#',+ data: { 'toggle-target': ".#{row.toggle_item_class_name}" },+ class: 'button -small toggle-membership-button' %>+ </p>+<% end %>diff --git a/app/components/members/role_form_component.rb b/app/components/members/role_form_component.rbnew file mode 100644index 00000000000..88044aa0272--- /dev/null+++ b/app/components/members/role_form_component.rb@@ -0,0 +1,53 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-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 Members+ class RoleFormComponent < ::RailsComponent+ include RemovedJsHelpersHelper++ options :row, :params, :roles++ def member+ model+ end++ def form_html_options+ { id: "#{row.roles_css_id}-form",+ class: row.toggle_item_class_name,+ style: "display:none" }+ end++ def role_disabled?(role)+ member+ .member_roles+ .detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? }+ end+ end+enddiff --git a/app/components/members/row_component.rb b/app/components/members/row_component.rbindex 01f47f6523f..80bd6c0007e 100644--- a/app/components/members/row_component.rb+++ b/app/components/members/row_component.rb@@ -72,7 +72,7 @@ module Membersspan = content_tag "span", roles_label, id: "member-#{member.id}-roles"if may_update?- span + role_form_cell.call+ span + role_formelsespanend@@ -89,13 +89,12 @@ module Memberslabelend- def role_form_cell- Members::RoleFormCell.new(+ def role_form+ render Members::RoleFormComponent.new(member,row: self,params: controller.params,- roles: table.available_roles,- context: { controller: }+ roles: table.available_roles)enddiff --git a/app/components/members/table_component.rb b/app/components/members/table_component.rbindex b809f339961..32d4a84a154 100644--- a/app/components/members/table_component.rb+++ b/app/components/members/table_component.rb@@ -56,7 +56,7 @@ module Membersenddef join_users(query)- query.joins(:principal).references(:principal)+ query.joins(:principal)enddef empty_row_messagediff --git a/app/components/members/user_filter_component.rb b/app/components/members/user_filter_component.rbnew file mode 100644index 00000000000..386c4abd69f--- /dev/null+++ b/app/components/members/user_filter_component.rb@@ -0,0 +1,69 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-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 Members+ class UserFilterComponent < ::UserFilterComponent+ def initially_visible?+ false+ end++ def has_close_icon?+ true+ end++ ##+ # Adapts the user filter counts to count members as opposed to users.+ def extra_user_status_options+ {+ all: status_members_query('all').count,+ blocked: status_members_query('blocked').count,+ active: status_members_query('active').count,+ invited: status_members_query('invited').count,+ registered: status_members_query('registered').count,+ locked: status_members_query('locked').count+ }+ end++ def status_members_query(status)+ params = { project_id: project.id,+ status: }++ self.class.filter(params)+ end++ def filter_path+ project_members_path(project)+ end++ def self.base_query+ Queries::Members::MemberQuery+ end+ end+enddiff --git a/app/components/rails_component.rb b/app/components/rails_component.rbindex 0fbe8450db2..22238f91922 100644--- a/app/components/rails_component.rb+++ b/app/components/rails_component.rb@@ -31,10 +31,11 @@class RailsComponent < ViewComponent::Baseinclude ApplicationHelper- attr_reader :options+ attr_reader :model, :options- def initialize(**options)+ def initialize(model = nil, **options)super+ @model = model if model@options = optionsenddiff --git a/app/components/row_component.rb b/app/components/row_component.rbindex 72851e1af55..af30516b38d 100644--- a/app/components/row_component.rb+++ b/app/components/row_component.rb@@ -31,11 +31,10 @@### Abstract view component. Subclass this for a concrete table row.class RowComponent < RailsComponent- attr_reader :model, :table+ attr_reader :tabledef initialize(row:, table:, **options)- super(**options)- @model = row+ super(row, **options)@table = tableenddiff --git a/app/components/table_component.html.erb b/app/components/table_component.html.erbindex 76ab5672efd..8a26cb3b25d 100644--- a/app/components/table_component.html.erb+++ b/app/components/table_component.html.erb@@ -65,9 +65,7 @@ See COPYRIGHT and LICENSE files for more details.<td colspan="<%= headers.length + 1 %>"><%= empty_row_message %></td></tr><% end %>- <% for row in rows do -%>- <%= render_row row %>- <% end -%>+ <%= render_collection rows %></tbody></table><% if inline_create_link %>diff --git a/app/components/table_component.rb b/app/components/table_component.rbindex e5766cd6c96..e646bd7b3ec 100644--- a/app/components/table_component.rb+++ b/app/components/table_component.rb@@ -34,11 +34,8 @@ class TableComponent < RailsComponentinclude SortHelperinclude PaginationHelper- attr_reader :model-def initialize(rows:, **options)- super(**options)- @model = rows+ super(rows, **options)endclass << self@@ -148,8 +145,8 @@ class TableComponent < RailsComponentself.class.sortable_columnsend- def render_row(row)- render(row_class.new(row:, table: self))+ def render_collection(rows)+ render(row_class.with_collection(rows, table: self))enddef initial_sortdiff --git a/app/components/user_filter_component.rb b/app/components/user_filter_component.rbnew file mode 100644index 00000000000..ad1b06cb400--- /dev/null+++ b/app/components/user_filter_component.rb@@ -0,0 +1,82 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-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-2017 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 UserFilterComponent < IndividualPrincipalBaseFilterComponent+ options :groups, :status, :roles, :clear_url, :project++ class << self+ ##+ # Returns the selected status from the parameters+ # or the default status to be filtered by (all)+ # if no status is given.+ def status_param(params)+ params[:status].presence || 'all'+ end++ def filter_status(query, status)+ return unless status && status != 'all'++ case status+ when 'blocked'+ query.where(:blocked, '=', :blocked)+ when 'active'+ query.where(:status, '=', status.to_sym)+ query.where(:blocked, '!', :blocked)+ else+ query.where(:status, '=', status.to_sym)+ end+ end++ def base_query+ Queries::Users::UserQuery+ end++ protected++ def apply_filters(params, query)+ super(params, query)+ filter_status query, status_param(params)++ query+ end+ end++ # INSTANCE METHODS:++ def filter_path+ users_path+ end++ def user_status_options+ users_status_options_for_select status, extra: extra_user_status_options+ end++ def extra_user_status_options+ {}+ end+enddiff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rbindex cdce6bca41c..0e422ff267f 100644--- a/app/controllers/members_controller.rb+++ b/app/controllers/members_controller.rb@@ -131,13 +131,13 @@ class MembersController < ApplicationControllerproject: @project,available_roles: roles,authorize_update: authorize_for('members', 'update'),- is_filtered: Members::UserFilterCell.filtered?(params)+ is_filtered: Members::UserFilterComponent.filtered?(params)}enddef members_filter_options(roles)groups = Group.all.sort- status = Members::UserFilterCell.status_param(params)+ status = Members::UserFilterComponent.status_param(params){groups:,@@ -184,7 +184,7 @@ class MembersController < ApplicationControllerfilters = params.slice(:name, :group_id, :role_id, :status)filters[:project_id] = @project.id.to_s- @members_query = Members::UserFilterCell.query(filters)+ @members_query = Members::UserFilterComponent.query(filters)enddef create_membersdiff --git a/app/views/members/index.html.erb b/app/views/members/index.html.erbindex 18deaff9011..77e77e291a6 100644--- a/app/views/members/index.html.erb+++ b/app/views/members/index.html.erb@@ -70,6 +70,6 @@ See COPYRIGHT and LICENSE files for more details.</div><div>- <%= rails_cell Members::UserFilterCell, params, **@members_filter_options %>+ <%= render ::Members::UserFilterComponent.new(params, **@members_filter_options) %><%= render ::Members::TableComponent.new(rows: @members, **@members_table_options) %></div>