Module: BoardsHelper

Defined in:
app/helpers/boards_helper.rb

Instance Method Summary collapse

Instance Method Details

#boardObject


4
5
6
# File 'app/helpers/boards_helper.rb', line 4

def board
  @board ||= @board || @boards.first
end

#board_base_urlObject


80
81
82
83
84
85
86
# File 'app/helpers/boards_helper.rb', line 80

def board_base_url
  if board.group_board?
    group_boards_url(@group)
  else
    project_boards_path(@project)
  end
end

#board_dataObject


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
# File 'app/helpers/boards_helper.rb', line 8

def board_data
  {
    boards_endpoint: @boards_endpoint,
    lists_endpoint: board_lists_path(board),
    board_id: board.id,
    disabled: board.disabled_for?(current_user).to_s,
    root_path: root_path,
    full_path: full_path,
    bulk_update_path: @bulk_issues_path,
    can_update: can_update?.to_s,
    can_admin_list: can_admin_list?.to_s,
    can_admin_board: can_admin_board?.to_s,
    time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s,
    parent: current_board_parent.model_name.param_key,
    group_id: group_id,
    labels_filter_base_path: build_issue_link_base,
    labels_fetch_path: labels_fetch_path,
    labels_manage_path: labels_manage_path,
    releases_fetch_path: releases_fetch_path,
    board_type: board.to_type,
    has_missing_boards: has_missing_boards?.to_s,
    multiple_boards_available: multiple_boards_available?.to_s,
    board_base_url: board_base_url
  }
end

48
49
50
51
52
53
54
# File 'app/helpers/boards_helper.rb', line 48

def build_issue_link_base
  if board.group_board?
    "/:project_path/-/issues"
  else
    project_issues_path(@project)
  end
end

#can_admin_board?Boolean

Returns:

  • (Boolean)

121
122
123
# File 'app/helpers/boards_helper.rb', line 121

def can_admin_board?
  can?(current_user, :admin_issue_board, current_board_parent)
end

#can_admin_issue?Boolean

Returns:

  • (Boolean)

125
126
127
# File 'app/helpers/boards_helper.rb', line 125

def can_admin_issue?
  can?(current_user, :admin_issue, current_board_parent)
end

#can_admin_list?Boolean

Returns:

  • (Boolean)

117
118
119
# File 'app/helpers/boards_helper.rb', line 117

def can_admin_list?
  can?(current_user, :admin_issue_board_list, current_board_parent)
end

#can_update?Boolean

Returns:

  • (Boolean)

113
114
115
# File 'app/helpers/boards_helper.rb', line 113

def can_update?
  can?(current_user, :admin_issue, board)
end

#current_board_jsonObject


133
134
135
# File 'app/helpers/boards_helper.rb', line 133

def current_board_json
  serializer.represent(board).as_json
end

#current_board_namespaceObject


109
110
111
# File 'app/helpers/boards_helper.rb', line 109

def current_board_namespace
  @current_board_namespace = board.group_board? ? @group : @project.namespace
end

#current_board_parentObject


105
106
107
# File 'app/helpers/boards_helper.rb', line 105

def current_board_parent
  @current_board_parent ||= @group || @project
end

#current_board_path(board) ⇒ Object


97
98
99
100
101
102
103
# File 'app/helpers/boards_helper.rb', line 97

def current_board_path(board)
  @current_board_path ||= if board.group_board?
                            group_board_path(current_board_parent, board)
                          else
                            project_board_path(current_board_parent, board)
                          end
end

#full_pathObject


40
41
42
43
44
45
46
# File 'app/helpers/boards_helper.rb', line 40

def full_path
  if board.group_board?
    @group.full_path
  else
    @project.full_path
  end
end

#group_idObject


34
35
36
37
38
# File 'app/helpers/boards_helper.rb', line 34

def group_id
  return @group.id if board.group_board?

  @project&.group&.id
end

#has_missing_boards?Boolean

Boards are hidden when extra boards were created but the license does not allow multiple boards

Returns:

  • (Boolean)

93
94
95
# File 'app/helpers/boards_helper.rb', line 93

def has_missing_boards?
  !multiple_boards_available? && current_board_parent.boards.size > 1
end

#labels_fetch_pathObject


56
57
58
59
60
61
62
# File 'app/helpers/boards_helper.rb', line 56

def labels_fetch_path
  if board.group_board?
    group_labels_path(@group, format: :json, only_group_labels: true, include_ancestor_groups: true)
  else
    project_labels_path(@project, format: :json, include_ancestor_groups: true)
  end
end

#labels_manage_pathObject


64
65
66
67
68
69
70
# File 'app/helpers/boards_helper.rb', line 64

def labels_manage_path
  if board.group_board?
    group_labels_path(@group)
  else
    project_labels_path(@project)
  end
end

#multiple_boards_available?Boolean

Returns:

  • (Boolean)

88
89
90
# File 'app/helpers/boards_helper.rb', line 88

def multiple_boards_available?
  current_board_parent.multiple_issue_boards_available?
end

#releases_fetch_pathObject


72
73
74
75
76
77
78
# File 'app/helpers/boards_helper.rb', line 72

def releases_fetch_path
  if board.group_board?
    group_releases_path(@group)
  else
    project_releases_path(@project)
  end
end

#serializerObject


129
130
131
# File 'app/helpers/boards_helper.rb', line 129

def serializer
  CurrentBoardSerializer.new
end