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