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

Hide non-project members in members list

Klaus Zanders2629ab50b41e
diff --git a/app/components/members/user_filter_component.rb b/app/components/members/user_filter_component.rb
index 386c4abd69f..894018f6830 100644
--- a/app/components/members/user_filter_component.rb
+++ b/app/components/members/user_filter_component.rb
@@ -52,8 +52,10 @@ module Members
end
def status_members_query(status)
- params = { project_id: project.id,
- status: }
+ params = {
+ project_id: project.id,
+ status:
+ }
self.class.filter(params)
end
@@ -62,8 +64,19 @@ module Members
project_members_path(project)
end
- def self.base_query
- Queries::Members::MemberQuery
+ class << self
+ def base_query
+ Queries::Members::MemberQuery
+ end
+
+ protected
+
+ def apply_filters(params, query)
+ super(params, query)
+ query.where(:only_project_member, '=', 't')
+
+ query
+ end
end
end
end
diff --git a/app/models/queries/members.rb b/app/models/queries/members.rb
index 47ddbce0410..b3ece3032a8 100644
--- a/app/models/queries/members.rb
+++ b/app/models/queries/members.rb
@@ -42,6 +42,7 @@ module Queries::Members
filter Filters::EntityIdFilter
filter Filters::EntityTypeFilter
filter Filters::AlsoProjectMemberFilter
+ filter Filters::OnlyProjectMemberFilter
order Orders::DefaultOrder
order Orders::NameOrder
diff --git a/app/models/queries/members/filters/only_project_member_filter.rb b/app/models/queries/members/filters/only_project_member_filter.rb
new file mode 100644
index 00000000000..e7448392e84
--- /dev/null
+++ b/app/models/queries/members/filters/only_project_member_filter.rb
@@ -0,0 +1,48 @@
+#-- 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.
+#++
+
+class Queries::Members::Filters::OnlyProjectMemberFilter < Queries::Members::Filters::MemberFilter
+ include Queries::Filters::Shared::BooleanFilter
+
+ def where
+ pp({ allowed_values:, values: })
+ if allowed_values.first.intersect?(values)
+ "members.entity_type IS NULL AND members.entity_id IS NULL"
+ else
+ "1=1"
+ end
+ end
+
+ def available_operators
+ [::Queries::Operators::BooleanEquals]
+ end
+
+ def type_strategy
+ @type_strategy ||= ::Queries::Filters::Strategies::BooleanListStrict.new self
+ end
+end