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 @@ ...@@ -2,7 +2,7 @@
module Resolvers module Resolvers
class BoardListIssuesResolver < BaseResolver class BoardListIssuesResolver < BaseResolver
include BoardIssueFilterable include BoardItemFilterable
argument :filters, Types::Boards::BoardIssueInputType, argument :filters, Types::Boards::BoardIssueInputType,
required: false, required: false,
...@@ -13,7 +13,7 @@ module Resolvers ...@@ -13,7 +13,7 @@ module Resolvers
alias_method :list, :object alias_method :list, :object
def resolve(**args) 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) service = ::Boards::Issues::ListService.new(list.board.resource_parent, context[:current_user], filter_params)
offset_pagination(service.execute) offset_pagination(service.execute)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module Resolvers module Resolvers
class BoardListsResolver < BaseResolver class BoardListsResolver < BaseResolver
include BoardIssueFilterable include BoardItemFilterable
include Gitlab::Graphql::Authorize::AuthorizeResource include Gitlab::Graphql::Authorize::AuthorizeResource
include LooksAhead include LooksAhead
...@@ -22,7 +22,7 @@ module Resolvers ...@@ -22,7 +22,7 @@ module Resolvers
def resolve_with_lookahead(id: nil, issue_filters: {}) def resolve_with_lookahead(id: nil, issue_filters: {})
lists = board_lists(id) 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? List.preload_preferences_for_user(lists, current_user) if load_preferences?
......
# frozen_string_literal: true # frozen_string_literal: true
module BoardIssueFilterable module BoardItemFilterable
extend ActiveSupport::Concern extend ActiveSupport::Concern
private private
def issue_filters(args) def item_filters(args)
filters = args.to_h filters = args.to_h
set_filter_values(filters) set_filter_values(filters)
...@@ -32,4 +32,4 @@ module BoardIssueFilterable ...@@ -32,4 +32,4 @@ module BoardIssueFilterable
end end
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): ...@@ -8570,6 +8570,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| Name | Type | Description | | 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. | | <a id="epicboardlistsid"></a>`id` | [`BoardsEpicListID`](#boardsepiclistid) | Find an epic board list by ID. |
### `EpicDescendantCount` ### `EpicDescendantCount`
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module EE module EE
module Resolvers module Resolvers
module BoardIssueFilterable module BoardItemFilterable
extend ActiveSupport::Concern extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Resolvers module Resolvers
module BoardGroupings module BoardGroupings
class EpicsResolver < BaseResolver class EpicsResolver < BaseResolver
include ::BoardIssueFilterable include ::BoardItemFilterable
alias_method :board, :object alias_method :board, :object
...@@ -25,7 +25,7 @@ module Resolvers ...@@ -25,7 +25,7 @@ module Resolvers
private private
def board_epic_ids(issue_params) 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( list_service = ::Boards::Issues::ListService.new(
board.resource_parent, board.resource_parent,
......
...@@ -5,6 +5,7 @@ module Resolvers ...@@ -5,6 +5,7 @@ module Resolvers
class EpicListsResolver < BaseResolver class EpicListsResolver < BaseResolver
include Gitlab::Graphql::Authorize::AuthorizeResource include Gitlab::Graphql::Authorize::AuthorizeResource
include LooksAhead include LooksAhead
include ::BoardItemFilterable
type Types::Boards::EpicListType.connection_type, null: true type Types::Boards::EpicListType.connection_type, null: true
...@@ -12,12 +13,17 @@ module Resolvers ...@@ -12,12 +13,17 @@ module Resolvers
required: false, required: false,
description: 'Find an epic board list by ID.' 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 alias_method :epic_board, :object
def resolve_with_lookahead(id: nil) def resolve_with_lookahead(id: nil, epic_filters: {})
authorize! authorize!
lists = board_lists(id) lists = board_lists(id)
context.scoped_set!(:epic_filters, item_filters(epic_filters))
if load_preferences?(lookahead) if load_preferences?(lookahead)
::Boards::EpicList.preload_preferences_for_user(lists, current_user) ::Boards::EpicList.preload_preferences_for_user(lists, current_user)
......
...@@ -48,8 +48,10 @@ module Types ...@@ -48,8 +48,10 @@ module Types
def metadata def metadata
strong_memoize(:metadata) do strong_memoize(:metadata) do
params = (context[:epic_filters] || {}).merge(board_id: list.epic_board_id, id: list.id)
::Boards::Epics::ListService ::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 .metadata
end end
end end
......
...@@ -80,11 +80,17 @@ RSpec.describe 'get list of epic boards' do ...@@ -80,11 +80,17 @@ RSpec.describe 'get list of epic boards' do
end end
it 'returns the correct values for count' do 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 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