Commit a21fda3f authored by Felipe Artur's avatar Felipe Artur

Allow to manage group boards and lists

parent 951fbe6d
......@@ -34,7 +34,7 @@ module Boards
def destroy
list = board.lists.destroyable.find(params[:id])
service = Boards::Lists::DestroyService.new(project, current_user)
service = Boards::Lists::DestroyService.new(board_parent, current_user)
if service.execute(list)
head :ok
......
......@@ -9,7 +9,7 @@ module EE
end
def create
board = ::Boards::CreateService.new(project, current_user, board_params).execute
board = ::Boards::CreateService.new(parent, current_user, board_params).execute
respond_to do |format|
format.json do
......@@ -23,7 +23,7 @@ module EE
end
def update
service = ::Boards::UpdateService.new(project, current_user, board_params)
service = ::Boards::UpdateService.new(parent, current_user, board_params)
service.execute(@board)
......@@ -39,18 +39,18 @@ module EE
end
def destroy
service = ::Boards::DestroyService.new(project, current_user)
service = ::Boards::DestroyService.new(parent, current_user)
service.execute(@board)
respond_to do |format|
format.html { redirect_to project_boards_path(@project), status: 302 }
format.html { redirect_to boards_path, status: 302 }
end
end
private
def authorize_admin_board!
return render_404 unless can?(current_user, :admin_board, project)
return render_404 unless can?(current_user, :admin_board, parent)
end
def board_params
......@@ -58,7 +58,19 @@ module EE
end
def find_board
@board = project.boards.find(params[:id])
@board = parent.boards.find(params[:id])
end
def parent
@parent ||= @project || @group
end
def boards_path
if parent.is_a?(Group)
group_boards_path(parent)
else
project_boards_path(parent)
end
end
def serialize_as_json(resource)
......
......@@ -15,6 +15,17 @@ class Groups::BoardsController < Groups::ApplicationController
end
end
def show
@board = group.boards.find(params[:id])
respond_to do |format|
format.html
format.json do
render json: serialize_as_json(@board)
end
end
end
def assign_endpoint_vars
@boards_endpoint = group_boards_path(group)
@issues_path = issues_group_path(group)
......
......@@ -14,7 +14,13 @@ class Groups::LabelsController < Groups::ApplicationController
end
format.json do
available_labels = LabelsFinder.new(current_user, group_id: @group.id).execute
available_labels =
if params[:group_labels_only]
LabelsFinder.new(current_user, group_id: @group.id).execute
else
group.labels
end
render json: LabelSerializer.new.represent_appearance(available_labels)
end
end
......
......@@ -53,4 +53,22 @@ module BoardsHelper
def current_board_parent
@current_board_parent ||= @project || @group
end
def can_create_board_list?
board_parent = @project || @group
can?(current_user, :admin_list, board_parent)
end
def board_list_data
namespace_path = current_board_parent.try(:path) || current_board_parent.namespace.try(:path)
{
toggle: "dropdown",
labels: labels_filter_path(only_group_labels: true),
namespace_path: namespace_path,
project_path: @project&.try(:path), # Change this one on JS to use a single property: parent_path
group_path: @group&.try(:path) # Same here
}
end
end
......@@ -121,8 +121,8 @@ module LabelsHelper
end
end
def labels_filter_path
return group_labels_path(@group, :json) if @group
def labels_filter_path(only_group_labels = false)
return group_labels_path(@group, :json, only_group_labels: only_group_labels) if @group
project = @target_project || @project
......
......@@ -116,13 +116,13 @@
= icon('times')
.filter-dropdown-container
- if type == :boards
- if can?(current_user, :admin_list, @project)
- if can_create_board_list?
.dropdown.prepend-left-10#js-add-list
%button.btn.btn-create.btn-inverted.js-new-board-list{ type: "button", data: { toggle: "dropdown", labels: labels_filter_path, namespace_path: @project.try(:namespace).try(:path), project_path: @project.try(:path) } }
%button.btn.btn-create.btn-inverted.js-new-board-list{ type: "button", data: board_list_data }
Add list
.dropdown-menu.dropdown-menu-paging.dropdown-menu-align-right.dropdown-menu-issues-board-new.dropdown-menu-selectable
= render partial: "shared/issuable/label_page_default", locals: { show_footer: true, show_create: true, show_boards_content: true, title: "Add list" }
- if can?(current_user, :admin_label, @project)
- if can?(current_user, :admin_label, current_board_parent)
= render partial: "shared/issuable/label_page_create"
= dropdown_loading
#js-add-issues-btn.prepend-left-10
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment