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 ...@@ -34,7 +34,7 @@ module Boards
def destroy def destroy
list = board.lists.destroyable.find(params[:id]) 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) if service.execute(list)
head :ok head :ok
......
...@@ -9,7 +9,7 @@ module EE ...@@ -9,7 +9,7 @@ module EE
end end
def create 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| respond_to do |format|
format.json do format.json do
...@@ -23,7 +23,7 @@ module EE ...@@ -23,7 +23,7 @@ module EE
end end
def update def update
service = ::Boards::UpdateService.new(project, current_user, board_params) service = ::Boards::UpdateService.new(parent, current_user, board_params)
service.execute(@board) service.execute(@board)
...@@ -39,18 +39,18 @@ module EE ...@@ -39,18 +39,18 @@ module EE
end end
def destroy def destroy
service = ::Boards::DestroyService.new(project, current_user) service = ::Boards::DestroyService.new(parent, current_user)
service.execute(@board) service.execute(@board)
respond_to do |format| respond_to do |format|
format.html { redirect_to project_boards_path(@project), status: 302 } format.html { redirect_to boards_path, status: 302 }
end end
end end
private private
def authorize_admin_board! 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 end
def board_params def board_params
...@@ -58,7 +58,19 @@ module EE ...@@ -58,7 +58,19 @@ module EE
end end
def find_board 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 end
def serialize_as_json(resource) def serialize_as_json(resource)
......
...@@ -15,6 +15,17 @@ class Groups::BoardsController < Groups::ApplicationController ...@@ -15,6 +15,17 @@ class Groups::BoardsController < Groups::ApplicationController
end end
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 def assign_endpoint_vars
@boards_endpoint = group_boards_path(group) @boards_endpoint = group_boards_path(group)
@issues_path = issues_group_path(group) @issues_path = issues_group_path(group)
......
...@@ -14,7 +14,13 @@ class Groups::LabelsController < Groups::ApplicationController ...@@ -14,7 +14,13 @@ class Groups::LabelsController < Groups::ApplicationController
end end
format.json do 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) render json: LabelSerializer.new.represent_appearance(available_labels)
end end
end end
......
...@@ -53,4 +53,22 @@ module BoardsHelper ...@@ -53,4 +53,22 @@ module BoardsHelper
def current_board_parent def current_board_parent
@current_board_parent ||= @project || @group @current_board_parent ||= @project || @group
end 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 end
...@@ -121,8 +121,8 @@ module LabelsHelper ...@@ -121,8 +121,8 @@ module LabelsHelper
end end
end end
def labels_filter_path def labels_filter_path(only_group_labels = false)
return group_labels_path(@group, :json) if @group return group_labels_path(@group, :json, only_group_labels: only_group_labels) if @group
project = @target_project || @project project = @target_project || @project
......
...@@ -116,13 +116,13 @@ ...@@ -116,13 +116,13 @@
= icon('times') = icon('times')
.filter-dropdown-container .filter-dropdown-container
- if type == :boards - if type == :boards
- if can?(current_user, :admin_list, @project) - if can_create_board_list?
.dropdown.prepend-left-10#js-add-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 Add list
.dropdown-menu.dropdown-menu-paging.dropdown-menu-align-right.dropdown-menu-issues-board-new.dropdown-menu-selectable .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" } = 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" = render partial: "shared/issuable/label_page_create"
= dropdown_loading = dropdown_loading
#js-add-issues-btn.prepend-left-10 #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