2019-02-26 12:26:26 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module BoardsActions
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
include BoardsResponses
|
|
|
|
|
2021-05-04 20:10:41 -04:00
|
|
|
before_action :authorize_read_board!, only: [:index, :show]
|
2022-09-28 11:09:17 -04:00
|
|
|
before_action :redirect_to_recent_board, only: [:index]
|
|
|
|
before_action :board, only: [:index, :show]
|
2020-09-21 17:09:27 -04:00
|
|
|
before_action :push_licensed_features, only: [:index, :show]
|
2019-02-26 12:26:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
2022-09-28 11:09:17 -04:00
|
|
|
# if no board exists, create one
|
|
|
|
@board = board_create_service.execute.payload unless board # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2019-02-26 12:26:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2022-09-28 11:09:17 -04:00
|
|
|
return render_404 unless board
|
2019-02-26 12:26:26 -05:00
|
|
|
|
2022-09-28 11:09:17 -04:00
|
|
|
# Add / update the board in the recent visits table
|
|
|
|
board_visit_service.new(parent, current_user).execute(board)
|
2019-02-26 12:26:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2022-09-28 11:09:17 -04:00
|
|
|
def redirect_to_recent_board
|
|
|
|
return if !parent.multiple_issue_boards_available? || !latest_visited_board
|
|
|
|
|
|
|
|
redirect_to board_path(latest_visited_board.board)
|
2019-11-21 01:06:32 -05:00
|
|
|
end
|
|
|
|
|
2022-09-28 11:09:17 -04:00
|
|
|
def latest_visited_board
|
|
|
|
@latest_visited_board ||= Boards::VisitsFinder.new(parent, current_user).latest
|
|
|
|
end
|
|
|
|
|
|
|
|
# Noop on FOSS
|
|
|
|
def push_licensed_features
|
2019-02-26 12:26:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def board
|
|
|
|
strong_memoize(:board) do
|
2021-02-12 04:08:48 -05:00
|
|
|
board_finder.execute.first
|
2019-02-26 12:26:26 -05:00
|
|
|
end
|
|
|
|
end
|
2019-06-06 04:13:18 -04:00
|
|
|
|
2021-05-11 11:10:20 -04:00
|
|
|
def board_visit_service
|
|
|
|
Boards::Visits::CreateService
|
|
|
|
end
|
2019-02-26 12:26:26 -05:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
BoardsActions.prepend_mod_with('BoardsActions')
|