2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-12 07:50:47 -04:00
|
|
|
module BoardsHelper
|
2017-08-28 17:56:49 -04:00
|
|
|
def board
|
|
|
|
@board ||= @board || @boards.first
|
|
|
|
end
|
2016-10-12 07:50:47 -04:00
|
|
|
|
2017-08-28 17:56:49 -04:00
|
|
|
def board_data
|
2016-10-12 07:50:47 -04:00
|
|
|
{
|
2017-08-28 17:56:49 -04:00
|
|
|
boards_endpoint: @boards_endpoint,
|
2017-12-03 13:46:07 -05:00
|
|
|
lists_endpoint: board_lists_path(board),
|
2016-10-12 07:50:47 -04:00
|
|
|
board_id: board.id,
|
2021-05-17 14:10:42 -04:00
|
|
|
disabled: board.disabled_for?(current_user).to_s,
|
2017-01-31 05:39:44 -05:00
|
|
|
root_path: root_path,
|
2020-03-10 05:08:10 -04:00
|
|
|
full_path: full_path,
|
2017-08-28 17:56:49 -04:00
|
|
|
bulk_update_path: @bulk_issues_path,
|
2021-04-05 20:09:06 -04:00
|
|
|
can_update: can_update?.to_s,
|
|
|
|
can_admin_list: can_admin_list?.to_s,
|
2019-06-17 08:58:48 -04:00
|
|
|
time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s,
|
2020-04-30 05:09:39 -04:00
|
|
|
recent_boards_endpoint: recent_boards_path,
|
2020-09-17 05:09:32 -04:00
|
|
|
parent: current_board_parent.model_name.param_key,
|
2021-03-12 13:09:23 -05:00
|
|
|
group_id: group_id,
|
2020-10-15 14:08:43 -04:00
|
|
|
labels_filter_base_path: build_issue_link_base,
|
|
|
|
labels_fetch_path: labels_fetch_path,
|
2021-02-12 04:08:48 -05:00
|
|
|
labels_manage_path: labels_manage_path,
|
|
|
|
board_type: board.to_type
|
2016-10-12 07:50:47 -04:00
|
|
|
}
|
|
|
|
end
|
2017-08-28 17:56:49 -04:00
|
|
|
|
2021-03-12 13:09:23 -05:00
|
|
|
def group_id
|
|
|
|
return @group.id if board.group_board?
|
|
|
|
|
|
|
|
@project&.group&.id
|
|
|
|
end
|
|
|
|
|
2020-03-10 05:08:10 -04:00
|
|
|
def full_path
|
|
|
|
if board.group_board?
|
|
|
|
@group.full_path
|
|
|
|
else
|
|
|
|
@project.full_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-28 17:56:49 -04:00
|
|
|
def build_issue_link_base
|
2018-02-19 14:06:16 -05:00
|
|
|
if board.group_board?
|
|
|
|
"#{group_path(@board.group)}/:project_path/issues"
|
|
|
|
else
|
|
|
|
project_issues_path(@project)
|
|
|
|
end
|
2017-08-28 17:56:49 -04:00
|
|
|
end
|
|
|
|
|
2020-10-15 14:08:43 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
def labels_manage_path
|
|
|
|
if board.group_board?
|
|
|
|
group_labels_path(@group)
|
|
|
|
else
|
|
|
|
project_labels_path(@project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-28 17:56:49 -04:00
|
|
|
def board_base_url
|
2018-02-19 14:06:16 -05:00
|
|
|
if board.group_board?
|
|
|
|
group_boards_url(@group)
|
|
|
|
else
|
|
|
|
project_boards_path(@project)
|
|
|
|
end
|
2017-08-28 17:56:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def multiple_boards_available?
|
2018-02-19 14:06:16 -05:00
|
|
|
current_board_parent.multiple_issue_boards_available?
|
2017-08-28 17:56:49 -04:00
|
|
|
end
|
|
|
|
|
2017-09-04 17:36:31 -04:00
|
|
|
def current_board_path(board)
|
2018-03-05 09:39:24 -05:00
|
|
|
@current_board_path ||= if board.group_board?
|
|
|
|
group_board_path(current_board_parent, board)
|
|
|
|
else
|
|
|
|
project_board_path(current_board_parent, board)
|
|
|
|
end
|
2017-08-28 17:56:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def current_board_parent
|
2018-02-19 14:06:16 -05:00
|
|
|
@current_board_parent ||= @group || @project
|
2017-08-28 17:56:49 -04:00
|
|
|
end
|
|
|
|
|
2021-05-14 05:10:24 -04:00
|
|
|
def current_board_namespace
|
|
|
|
@current_board_namespace = board.group_board? ? @group : @project.namespace
|
|
|
|
end
|
|
|
|
|
2021-04-05 20:09:06 -04:00
|
|
|
def can_update?
|
|
|
|
can?(current_user, :admin_issue, board)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_admin_list?
|
|
|
|
can?(current_user, :admin_issue_board_list, current_board_parent)
|
|
|
|
end
|
|
|
|
|
2017-08-28 17:56:49 -04:00
|
|
|
def can_admin_issue?
|
|
|
|
can?(current_user, :admin_issue, current_board_parent)
|
|
|
|
end
|
|
|
|
|
|
|
|
def board_list_data
|
2018-04-04 11:40:29 -04:00
|
|
|
include_descendant_groups = @group&.present?
|
|
|
|
|
2017-08-28 17:56:49 -04:00
|
|
|
{
|
|
|
|
toggle: "dropdown",
|
2018-10-03 06:36:35 -04:00
|
|
|
list_labels_path: labels_filter_path_with_defaults(only_group_labels: true, include_ancestor_groups: true),
|
|
|
|
labels: labels_filter_path_with_defaults(only_group_labels: true, include_descendant_groups: include_descendant_groups),
|
2017-08-28 17:56:49 -04:00
|
|
|
labels_endpoint: @labels_endpoint,
|
|
|
|
namespace_path: @namespace_path,
|
2018-02-19 14:06:16 -05:00
|
|
|
project_path: @project&.path,
|
|
|
|
group_path: @group&.path
|
2017-08-28 17:56:49 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2019-06-17 08:58:48 -04:00
|
|
|
def recent_boards_path
|
|
|
|
recent_project_boards_path(@project) if current_board_parent.is_a?(Project)
|
|
|
|
end
|
|
|
|
|
2019-07-12 02:31:17 -04:00
|
|
|
def serializer
|
|
|
|
CurrentBoardSerializer.new
|
|
|
|
end
|
|
|
|
|
2019-06-17 08:58:48 -04:00
|
|
|
def current_board_json
|
2019-07-12 02:31:17 -04:00
|
|
|
serializer.represent(board).as_json
|
2017-09-13 06:08:48 -04:00
|
|
|
end
|
2016-10-12 07:50:47 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
BoardsHelper.prepend_mod_with('BoardsHelper')
|