summaryrefslogtreecommitdiff
path: root/app/services/work_items/parent_links/destroy_service.rb
blob: 55870d44db920d11c6674ba3c48c9131311f01c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

module WorkItems
  module ParentLinks
    class DestroyService < IssuableLinks::DestroyService
      attr_reader :link, :current_user, :parent, :child

      def initialize(link, user)
        @link = link
        @current_user = user
        @parent = link.work_item_parent
        @child = link.work_item
      end

      private

      # TODO: Create system notes when work item's parent or children are removed
      # See https://gitlab.com/gitlab-org/gitlab/-/issues/362213
      def create_notes
        # no-op
      end

      def not_found_message
        _('No Work Item Link found')
      end

      def permission_to_remove_relation?
        can?(current_user, :admin_parent_link, child) && can?(current_user, :admin_parent_link, parent)
      end
    end
  end
end