blob: 42bf6c68aa71616f6163dd3315f5d3690370f125 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# frozen_string_literal: true
module BoardsActions
include Gitlab::Utils::StrongMemoize
extend ActiveSupport::Concern
included do
before_action :authorize_read_board!, only: [:index, :show]
before_action :redirect_to_recent_board, only: [:index]
before_action :board, only: [:index, :show]
before_action :push_licensed_features, only: [:index, :show]
end
def index
# if no board exists, create one
@board = board_create_service.execute.payload unless board # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
def show
return render_404 unless board
# Add / update the board in the recent visits table
board_visit_service.new(parent, current_user).execute(board)
end
private
def redirect_to_recent_board
return if !parent.multiple_issue_boards_available? || !latest_visited_board
redirect_to board_path(latest_visited_board.board)
end
def latest_visited_board
@latest_visited_board ||= Boards::VisitsFinder.new(parent, current_user).latest
end
# Noop on FOSS
def push_licensed_features
end
def board
strong_memoize(:board) do
board_finder.execute.first
end
end
def board_visit_service
Boards::Visits::CreateService
end
def parent
strong_memoize(:parent) do
group? ? group : project
end
end
def board_path(board)
if group?
group_board_path(parent, board)
else
project_board_path(parent, board)
end
end
def group?
instance_variable_defined?(:@group)
end
end
BoardsActions.prepend_mod_with('BoardsActions')
|