Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#50264] Allow Edit/Comment shared with users to be mentionable #14214

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/queries/principals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module Queries::Principals
::Queries::Register.register(PrincipalQuery) do
filter Filters::TypeFilter
filter Filters::MemberFilter
filter Filters::MentionableOnWorkPackageFilter
filter Filters::StatusFilter
filter Filters::NameFilter
filter Filters::AnyNameAttributeFilter
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# frozen_string_literal: true

# -- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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::Principals::Filters::MentionableOnWorkPackageFilter <
Queries::Principals::Filters::PrincipalFilter
def allowed_values
# We don't care for the first value as we do not display the values visibly
@allowed_values ||= ::WorkPackage.visible.pluck(:id).map { |id| [id, id.to_s] }
end

def type
:list_optional
end

def key
:mentionable_on_work_package
end

def scope
case operator
when '='
principals_with_a_membership
when '!'
visible_scope.where.not(id: principals_with_a_membership.select(:id))
end
end

def where
'1=1'
end

private

def principals_with_a_membership
visible_scope.where(id: work_package_members.select(:user_id))
.or(visible_scope.where(id: project_members.select(:user_id)))
end

def visible_scope
Principal.visible(User.current)
.includes(members: :roles)
.references(members: :roles)
end

def work_package_members
Member.joins(:member_roles)
.of_work_package(values)
.where(member_roles: { role_id: mentionable_work_package_role_ids })
end

def mentionable_work_package_role_ids
Role.where(builtin: [Role::BUILTIN_WORK_PACKAGE_EDITOR,
Role::BUILTIN_WORK_PACKAGE_COMMENTER])
.select(:id)
end

def project_members
Member.of(projects)
.where(entity: nil)
end

def work_packages
WorkPackage.where(id: values)
end

def projects
Project.where(id: work_packages.select(:project_id))
end
end
4 changes: 2 additions & 2 deletions frontend/src/app/core/path-helper/apiv3-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export class ApiV3Paths {
* https://github.com/opf/commonmark-ckeditor-build/
*
*/
public principals(projectId:string|number, term:string|null) {
public principals(workPackageId:string|number, term:string|null) {
const filters:ApiV3FilterBuilder = new ApiV3FilterBuilder();
// Only real and activated users:
filters.add('status', '!', ['3']);
// that are members of that project:
filters.add('member', '=', [projectId.toString()]);
filters.add('mentionable_on_work_package', '=', [workPackageId.toString()]);
// That are users:
filters.add('type', '=', ['User', 'Group']);

Expand Down
142,324 changes: 142,322 additions & 2 deletions frontend/src/vendor/ckeditor/ckeditor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/vendor/ckeditor/ckeditor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/vendor/ckeditor/translations/af.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/src/vendor/ckeditor/translations/ar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/vendor/ckeditor/translations/ast.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading