Welcome to mirror list, hosted at ThFree Co, Russian Federation.

boards_actions.rb « concerns « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 79e6f027c2ff633df5ffc7e514e879dca127909f (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
# 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
    before_action :push_licensed_features, only: [:index, :show]
    before_action do
      push_frontend_feature_flag(:not_issuable_queries, parent, default_enabled: true)
    end
  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

  # Noop on FOSS
  def push_licensed_features
  end

  def boards
    strong_memoize(:boards) do
      existing_boards = boards_finder.execute
      if existing_boards.any?
        existing_boards
      else
        # if no board exists, create one
        [board_create_service.execute.payload]
      end
    end
  end

  def board
    strong_memoize(:board) do
      board_finder.execute.first
    end
  end

  def board_type
    board_klass.to_type
  end

  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
end

BoardsActions.prepend_if_ee('EE::BoardsActions')