2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module BoardsActions
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
include BoardsResponses
|
|
|
|
|
|
|
|
before_action :boards, only: :index
|
|
|
|
before_action :board, only: :show
|
2021-01-03 14:25:43 +05:30
|
|
|
before_action :push_licensed_features, only: [:index, :show]
|
2020-05-24 23:13:21 +05:30
|
|
|
before_action do
|
|
|
|
push_frontend_feature_flag(:not_issuable_queries, parent, default_enabled: true)
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
|
|
|
respond_with_boards
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
# Add / update the board in the recent visits table
|
|
|
|
Boards::Visits::CreateService.new(parent, current_user).execute(board) if request.format.html?
|
|
|
|
|
|
|
|
respond_with_board
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
# Noop on FOSS
|
2021-01-03 14:25:43 +05:30
|
|
|
def push_licensed_features
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
def boards
|
|
|
|
strong_memoize(:boards) do
|
2021-03-11 19:13:27 +05:30
|
|
|
existing_boards = boards_finder.execute
|
|
|
|
if existing_boards.any?
|
|
|
|
existing_boards
|
|
|
|
else
|
|
|
|
# if no board exists, create one
|
|
|
|
[board_create_service.execute.payload]
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def board
|
|
|
|
strong_memoize(:board) do
|
2021-03-11 19:13:27 +05:30
|
|
|
board_finder.execute.first
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|
2019-09-04 21:01:54 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
def board_type
|
|
|
|
board_klass.to_type
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
def serializer
|
|
|
|
BoardSerializer.new(current_user: current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def serialize_as_json(resource)
|
|
|
|
serializer.represent(resource, serializer: 'board', include_full_project_path: board.group_board?)
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
BoardsActions.prepend_if_ee('EE::BoardsActions')
|