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

Add the owner as a share

Klaus Zandersff54ba18de98
diff --git a/app/models/sharing_strategies/project_query_strategy.rb b/app/models/sharing_strategies/project_query_strategy.rb
index 574a41ec392..3eafc855865 100644
--- a/app/models/sharing_strategies/project_query_strategy.rb
+++ b/app/models/sharing_strategies/project_query_strategy.rb
@@ -76,5 +76,33 @@ module SharingStrategies
def empty_state_component
Shares::ProjectQueries::EmptyStateComponent
end
+
+ def shares(reload: false)
+ results = super
+
+ if results.present?
+ (results + [virtual_owner_share]).sort_by { |share| share.principal.name }
+ else
+ []
+ end
+ end
+
+ private
+
+ def virtual_owner_share
+ @virtual_owner_share ||= Member.new(
+ entity:,
+ principal: entity.user,
+ roles: [ProjectQueryRole.find_by(builtin: owner_role_identifier)]
+ )
+ end
+
+ def owner_role_identifier
+ if !entity.public? || entity.user.allowed_globally?(:manage_public_project_queries)
+ Role::BUILTIN_PROJECT_QUERY_EDIT
+ else
+ Role::BUILTIN_PROJECT_QUERY_VIEW
+ end
+ end
end
end