diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-26 00:08:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-26 00:08:43 +0300 |
commit | 3e2ef953d9a22cb3139e7b395a1173604c563007 (patch) | |
tree | 3e22e05affc55017866fca8ff1269b777c52595c /app | |
parent | 35487a1e925f7b4ec72a3d0cdde94f92582d2087 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/graphql/resolvers/boards_resolver.rb | 18 | ||||
-rw-r--r-- | app/graphql/types/board_type.rb | 17 | ||||
-rw-r--r-- | app/services/boards/list_service.rb | 4 |
3 files changed, 37 insertions, 2 deletions
diff --git a/app/graphql/resolvers/boards_resolver.rb b/app/graphql/resolvers/boards_resolver.rb new file mode 100644 index 00000000000..45c03bf0bef --- /dev/null +++ b/app/graphql/resolvers/boards_resolver.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Resolvers + class BoardsResolver < BaseResolver + type Types::BoardType, null: true + + def resolve(**args) + # The project or group could have been loaded in batch by `BatchLoader`. + # At this point we need the `id` of the project/group to query for boards, so + # make sure it's loaded and not `nil` before continuing. + parent = object.respond_to?(:sync) ? object.sync : object + + return Board.none unless parent + + Boards::ListService.new(parent, context[:current_user]).execute(create_default_board: false) + end + end +end diff --git a/app/graphql/types/board_type.rb b/app/graphql/types/board_type.rb new file mode 100644 index 00000000000..9c95a987fe4 --- /dev/null +++ b/app/graphql/types/board_type.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Types + class BoardType < BaseObject + graphql_name 'Board' + description 'Represents a project or group board' + + authorize :read_board + + field :id, type: GraphQL::ID_TYPE, null: false, + description: 'ID (global ID) of the board' + field :name, type: GraphQL::STRING_TYPE, null: true, + description: 'Name of the board' + end +end + +Types::BoardType.prepend_if_ee('::EE::Types::BoardType') diff --git a/app/services/boards/list_service.rb b/app/services/boards/list_service.rb index 8258d5d07d3..c6dfd62804f 100644 --- a/app/services/boards/list_service.rb +++ b/app/services/boards/list_service.rb @@ -2,8 +2,8 @@ module Boards class ListService < Boards::BaseService - def execute - create_board! if parent.boards.empty? + def execute(create_default_board: true) + create_board! if create_default_board && parent.boards.empty? if parent.multiple_issue_boards_available? boards |