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

Do not add owner when we show groups

Klaus Zandersae1654d5eb7b
diff --git a/app/controllers/shares_controller.rb b/app/controllers/shares_controller.rb
index 9d4eb154f68..dbc6a505fae 100644
--- a/app/controllers/shares_controller.rb
+++ b/app/controllers/shares_controller.rb
@@ -54,7 +54,7 @@ class SharesController < ApplicationController
overall_result = []
@errors = ActiveModel::Errors.new(self)
- had_shares_before_adding = sharing_strategy.shares.present?
+ visible_shares_before_adding = sharing_strategy.shares.present?
find_or_create_users(send_notification: false) do |member_params|
user = User.find_by(id: member_params[:user_id])
@@ -71,7 +71,7 @@ class SharesController < ApplicationController
if overall_result.present?
# In case we did not have shares before we have to replace the modal to get rid of the blankstate,
# otherwise we can prepend the new shares
- if had_shares_before_adding
+ if visible_shares_before_adding
respond_with_prepend_shares(new_shares)
else
respond_with_replace_modal
diff --git a/app/models/sharing_strategies/project_query_strategy.rb b/app/models/sharing_strategies/project_query_strategy.rb
index 0280d917a24..19d7ec62348 100644
--- a/app/models/sharing_strategies/project_query_strategy.rb
+++ b/app/models/sharing_strategies/project_query_strategy.rb
@@ -79,6 +79,7 @@ module SharingStrategies
def shares(reload: false)
results = super
+ return results if filter_for_groups?
if (!filtered_by_role? && results.present?) || owner_matches_role_filter?
(results + [virtual_owner_share]).sort_by { |share| share.principal.name }
@@ -118,5 +119,12 @@ module SharingStrategies
role_filter.values.include?(owner_role.id.to_s) # rubocop:disable Performance/InefficientHashSearch
end
+
+ def filter_for_groups?
+ principal_filter = query.filters.find { |filter| filter.is_a?(Queries::Members::Filters::PrincipalTypeFilter) }
+ return false if principal_filter.nil?
+
+ principal_filter.values.count == 1 && principal_filter.values.include?("Group") # rubocop:disable Performance/InefficientHashSearch
+ end
end
end