debian-mirror-gitlab/app/graphql/resolvers/board_lists_resolver.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.4 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module Resolvers
class BoardListsResolver < BaseResolver
2021-09-04 01:27:46 +05:30
include BoardItemFilterable
2020-05-24 23:13:21 +05:30
include Gitlab::Graphql::Authorize::AuthorizeResource
2021-04-29 21:17:54 +05:30
include LooksAhead
2020-05-24 23:13:21 +05:30
type Types::BoardListType, null: true
2021-04-17 20:07:23 +05:30
authorize :read_issue_board_list
2021-04-29 21:17:54 +05:30
authorizes_object!
2020-05-24 23:13:21 +05:30
2021-01-29 00:20:46 +05:30
argument :id, Types::GlobalIDType[List],
2020-10-24 23:57:45 +05:30
required: false,
2021-03-08 18:12:59 +05:30
description: 'Find a list by its global ID.'
2020-10-24 23:57:45 +05:30
2021-01-03 14:25:43 +05:30
argument :issue_filters, Types::Boards::BoardIssueInputType,
required: false,
2021-03-08 18:12:59 +05:30
description: 'Filters applied when getting issue metadata in the board list.'
2021-01-03 14:25:43 +05:30
2020-05-24 23:13:21 +05:30
alias_method :board, :object
2021-04-29 21:17:54 +05:30
def resolve_with_lookahead(id: nil, issue_filters: {})
2020-10-24 23:57:45 +05:30
lists = board_lists(id)
2023-04-23 21:23:45 +05:30
context.scoped_set!(:issue_filters, item_filters(issue_filters, board.resource_parent))
2020-05-24 23:13:21 +05:30
2021-04-29 21:17:54 +05:30
List.preload_preferences_for_user(lists, current_user) if load_preferences?
2020-05-24 23:13:21 +05:30
2021-02-22 17:27:13 +05:30
offset_pagination(lists)
2020-05-24 23:13:21 +05:30
end
private
2020-10-24 23:57:45 +05:30
def board_lists(id)
2021-01-03 14:25:43 +05:30
service = ::Boards::Lists::ListService.new(
2020-10-24 23:57:45 +05:30
board.resource_parent,
2021-03-11 19:13:27 +05:30
current_user,
2020-10-24 23:57:45 +05:30
list_id: extract_list_id(id)
)
2020-05-24 23:13:21 +05:30
service.execute(board, create_default_lists: false)
end
2021-04-29 21:17:54 +05:30
def load_preferences?
node_selection&.selects?(:collapsed)
2020-05-24 23:13:21 +05:30
end
2020-10-24 23:57:45 +05:30
def extract_list_id(gid)
return unless gid.present?
GitlabSchema.parse_gid(gid, expected_type: ::List).model_id
end
2020-05-24 23:13:21 +05:30
end
end