Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/linked_project_issue_entity.rb')
-rw-r--r--app/serializers/linked_project_issue_entity.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/serializers/linked_project_issue_entity.rb b/app/serializers/linked_project_issue_entity.rb
new file mode 100644
index 00000000000..c95f68f58a3
--- /dev/null
+++ b/app/serializers/linked_project_issue_entity.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class LinkedProjectIssueEntity < LinkedIssueEntity
+ include Gitlab::Utils::StrongMemoize
+
+ expose :relation_path, override: true do |issue|
+ # Make sure the user can admin both the current issue AND the
+ # referenced issue projects in order to return the removal link.
+ if can_admin_issue_link_on_current_project? && can_admin_issue_link?(issue.project)
+ project_issue_link_path(issuable.project, issuable.iid, issue.issue_link_id)
+ end
+ end
+
+ expose :link_type do |issue|
+ issue.issue_link_type
+ end
+
+ private
+
+ def can_admin_issue_link_on_current_project?
+ strong_memoize(:can_admin_on_current_project) do
+ can_admin_issue_link?(issuable.project)
+ end
+ end
+
+ def can_admin_issue_link?(project)
+ Ability.allowed?(current_user, :admin_issue_link, project)
+ end
+end