diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 15:19:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 15:19:05 +0300 |
commit | 10adf63c4b76e665a706a81fba9405de0e27120a (patch) | |
tree | 4b89dc39d6f41dabe94438dbe713831c79bb6b82 /app/graphql/mutations/work_items | |
parent | 720d75f7f9897d7deace636e3fa74aa8dde02333 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/mutations/work_items')
-rw-r--r-- | app/graphql/mutations/work_items/linked_items/add.rb | 3 | ||||
-rw-r--r-- | app/graphql/mutations/work_items/linked_items/base.rb | 7 | ||||
-rw-r--r-- | app/graphql/mutations/work_items/linked_items/remove.rb | 28 |
3 files changed, 33 insertions, 5 deletions
diff --git a/app/graphql/mutations/work_items/linked_items/add.rb b/app/graphql/mutations/work_items/linked_items/add.rb index b346b074e85..e0c17a61205 100644 --- a/app/graphql/mutations/work_items/linked_items/add.rb +++ b/app/graphql/mutations/work_items/linked_items/add.rb @@ -9,6 +9,9 @@ module Mutations argument :link_type, ::Types::WorkItems::RelatedLinkTypeEnum, required: false, description: 'Type of link. Defaults to `RELATED`.' + argument :work_items_ids, [::Types::GlobalIDType[::WorkItem]], + required: true, + description: "Global IDs of the items to link. Maximum number of IDs you can provide: #{MAX_WORK_ITEMS}." private diff --git a/app/graphql/mutations/work_items/linked_items/base.rb b/app/graphql/mutations/work_items/linked_items/base.rb index 1d8d74b02ac..a1d9bced930 100644 --- a/app/graphql/mutations/work_items/linked_items/base.rb +++ b/app/graphql/mutations/work_items/linked_items/base.rb @@ -10,9 +10,6 @@ module Mutations argument :id, ::Types::GlobalIDType[::WorkItem], required: true, description: 'Global ID of the work item.' - argument :work_items_ids, [::Types::GlobalIDType[::WorkItem]], - required: true, - description: "Global IDs of the items to link. Maximum number of IDs you can provide: #{MAX_WORK_ITEMS}." field :work_item, Types::WorkItemType, null: true, description: 'Updated work item.' @@ -26,7 +23,7 @@ module Mutations if args[:work_items_ids].size > MAX_WORK_ITEMS raise Gitlab::Graphql::Errors::ArgumentError, format( - _('No more than %{max_work_items} work items can be linked at the same time.'), + _('No more than %{max_work_items} work items can be modified at the same time.'), max_work_items: MAX_WORK_ITEMS ) end @@ -50,7 +47,7 @@ module Mutations private def update_links(work_item, params) - raise NotImplementedError + raise NotImplementedError, "#{self.class} does not implement #{__method__}" end end end diff --git a/app/graphql/mutations/work_items/linked_items/remove.rb b/app/graphql/mutations/work_items/linked_items/remove.rb new file mode 100644 index 00000000000..078f05d2025 --- /dev/null +++ b/app/graphql/mutations/work_items/linked_items/remove.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Mutations + module WorkItems + module LinkedItems + class Remove < Base + graphql_name 'WorkItemRemoveLinkedItems' + description 'Remove items linked to the work item.' + + argument :work_items_ids, [::Types::GlobalIDType[::WorkItem]], + required: true, + description: "Global IDs of the items to unlink. Maximum number of IDs you can provide: #{MAX_WORK_ITEMS}." + + private + + def update_links(work_item, params) + gids = params.delete(:work_items_ids) + raise Gitlab::Graphql::Errors::ArgumentError, "workItemsIds cannot be empty" if gids.empty? + + work_item_ids = gids.filter_map { |gid| gid.model_id.to_i } + ::WorkItems::RelatedWorkItemLinks::DestroyService + .new(work_item, current_user, { item_ids: work_item_ids }) + .execute + end + end + end + end +end |