Commit ec1f831a authored by Etienne Baqué's avatar Etienne Baqué

Merge branch 'eboard_filters' into 'master'

Add epics filters to epic board lists

See merge request gitlab-org/gitlab!63302
parents a6460069 e44e71cf
......@@ -2,7 +2,7 @@
module Resolvers
class BoardListIssuesResolver < BaseResolver
include BoardIssueFilterable
include BoardItemFilterable
argument :filters, Types::Boards::BoardIssueInputType,
required: false,
......@@ -13,7 +13,7 @@ module Resolvers
alias_method :list, :object
def resolve(**args)
filter_params = issue_filters(args[:filters]).merge(board_id: list.board.id, id: list.id)
filter_params = item_filters(args[:filters]).merge(board_id: list.board.id, id: list.id)
service = ::Boards::Issues::ListService.new(list.board.resource_parent, context[:current_user], filter_params)
offset_pagination(service.execute)
......
......@@ -2,7 +2,7 @@
module Resolvers
class BoardListsResolver < BaseResolver
include BoardIssueFilterable
include BoardItemFilterable
include Gitlab::Graphql::Authorize::AuthorizeResource
include LooksAhead
......@@ -22,7 +22,7 @@ module Resolvers
def resolve_with_lookahead(id: nil, issue_filters: {})
lists = board_lists(id)
context.scoped_set!(:issue_filters, issue_filters(issue_filters))
context.scoped_set!(:issue_filters, item_filters(issue_filters))
List.preload_preferences_for_user(lists, current_user) if load_preferences?
......
# frozen_string_literal: true
module BoardIssueFilterable
module BoardItemFilterable
extend ActiveSupport::Concern
private
def issue_filters(args)
def item_filters(args)
filters = args.to_h
set_filter_values(filters)
......@@ -32,4 +32,4 @@ module BoardIssueFilterable
end
end
::BoardIssueFilterable.prepend_mod_with('Resolvers::BoardIssueFilterable')
::BoardItemFilterable.prepend_mod_with('Resolvers::BoardItemFilterable')
......@@ -8570,6 +8570,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="epicboardlistsepicfilters"></a>`epicFilters` | [`EpicFilters`](#epicfilters) | Filters applied when getting epic metadata in the epic board list. |
| <a id="epicboardlistsid"></a>`id` | [`BoardsEpicListID`](#boardsepiclistid) | Find an epic board list by ID. |
### `EpicDescendantCount`
......
......@@ -2,7 +2,7 @@
module EE
module Resolvers
module BoardIssueFilterable
module BoardItemFilterable
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
......
......@@ -3,7 +3,7 @@
module Resolvers
module BoardGroupings
class EpicsResolver < BaseResolver
include ::BoardIssueFilterable
include ::BoardItemFilterable
alias_method :board, :object
......@@ -25,7 +25,7 @@ module Resolvers
private
def board_epic_ids(issue_params)
params = issue_filters(issue_params).merge(all_lists: true, board_id: board.id)
params = item_filters(issue_params).merge(all_lists: true, board_id: board.id)
list_service = ::Boards::Issues::ListService.new(
board.resource_parent,
......
......@@ -5,6 +5,7 @@ module Resolvers
class EpicListsResolver < BaseResolver
include Gitlab::Graphql::Authorize::AuthorizeResource
include LooksAhead
include ::BoardItemFilterable
type Types::Boards::EpicListType.connection_type, null: true
......@@ -12,12 +13,17 @@ module Resolvers
required: false,
description: 'Find an epic board list by ID.'
argument :epic_filters, Types::Boards::BoardEpicInputType,
required: false,
description: 'Filters applied when getting epic metadata in the epic board list.'
alias_method :epic_board, :object
def resolve_with_lookahead(id: nil)
def resolve_with_lookahead(id: nil, epic_filters: {})
authorize!
lists = board_lists(id)
context.scoped_set!(:epic_filters, item_filters(epic_filters))
if load_preferences?(lookahead)
::Boards::EpicList.preload_preferences_for_user(lists, current_user)
......
......@@ -48,8 +48,10 @@ module Types
def metadata
strong_memoize(:metadata) do
params = (context[:epic_filters] || {}).merge(board_id: list.epic_board_id, id: list.id)
::Boards::Epics::ListService
.new(list.epic_board.resource_parent, current_user, { board_id: list.epic_board_id, id: list.id })
.new(list.epic_board.resource_parent, current_user, params)
.metadata
end
end
......
......@@ -80,11 +80,17 @@ RSpec.describe 'get list of epic boards' do
end
it 'returns the correct values for count' do
create_list(:epic, 2, group: group) # epics in backlog, the list which is returned first
label = create(:group_label, group: group)
# Epics in backlog, the list which is returned first. The first epic
# should be ignored because it doesn't have the label by which we are
# filtering.
create(:labeled_epic, group: group)
create(:labeled_epic, group: group, labels: [label])
post_graphql(pagination_query, current_user: current_user)
params = { epicFilters: { labelName: label.title } }
post_graphql(pagination_query(params), current_user: current_user)
assert_field_value('epicsCount', [2, 0, 0])
assert_field_value('epicsCount', [1, 0, 0])
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment