Commit 846cec83 authored by Felipe Artur's avatar Felipe Artur

Fixes to projects boards

parent a424d173
...@@ -4,8 +4,6 @@ import Vue from 'vue'; ...@@ -4,8 +4,6 @@ import Vue from 'vue';
class BoardService { class BoardService {
constructor (root, listsEndpoint, bulkUpdatePath, boardId) { constructor (root, listsEndpoint, bulkUpdatePath, boardId) {
// alert(listsEndpoint)
// alert(root)
this.boards = Vue.resource(`${root}{/id}.json`, {}, { this.boards = Vue.resource(`${root}{/id}.json`, {}, {
issues: { issues: {
method: 'GET', method: 'GET',
......
...@@ -2,7 +2,7 @@ module Boards ...@@ -2,7 +2,7 @@ module Boards
class ListsController < Boards::ApplicationController class ListsController < Boards::ApplicationController
include BoardsAuthorizations include BoardsAuthorizations
#before_action :authorize_admin_list!, only: [:create, :update, :destroy, :generate] before_action :authorize_admin_list!, only: [:create, :update, :destroy, :generate]
before_action :authorize_read_list!, only: [:index] before_action :authorize_read_list!, only: [:index]
def index def index
...@@ -12,7 +12,7 @@ module Boards ...@@ -12,7 +12,7 @@ module Boards
end end
def create def create
list = ::Boards::Lists::CreateService.new(project, current_user, list_params).execute(board) list = ::Boards::Lists::CreateService.new(board.parent, current_user, list_params).execute(board)
if list.valid? if list.valid?
render json: serialize_as_json(list) render json: serialize_as_json(list)
...@@ -23,7 +23,7 @@ module Boards ...@@ -23,7 +23,7 @@ module Boards
def update def update
list = board.lists.movable.find(params[:id]) list = board.lists.movable.find(params[:id])
service = Boards::Lists::MoveService.new(project, current_user, move_params) service = Boards::Lists::MoveService.new(board_parent, current_user, move_params)
if service.execute(list) if service.execute(list)
head :ok head :ok
...@@ -55,10 +55,6 @@ module Boards ...@@ -55,10 +55,6 @@ module Boards
private private
def authorize_admin_list!
return render_403 unless can?(current_user, :admin_list, project)
end
def list_params def list_params
params.require(:list).permit(:label_id) params.require(:list).permit(:label_id)
end end
......
...@@ -21,6 +21,13 @@ module BoardsAuthorizations ...@@ -21,6 +21,13 @@ module BoardsAuthorizations
return render_403 unless action_allowed_for?(board.parent, :admin_issue) return render_403 unless action_allowed_for?(board.parent, :admin_issue)
end end
def authorize_admin_list!
ability = board.is_group_board? ? :admin_milestones : :admin_list
return render_403 unless action_allowed_for?(board.parent, ability)
end
def action_allowed_for?(resource, ability) def action_allowed_for?(resource, ability)
can?(current_user, ability, resource) can?(current_user, ability, resource)
end end
......
...@@ -9,7 +9,7 @@ module BoardsHelper ...@@ -9,7 +9,7 @@ module BoardsHelper
lists_endpoint: board_lists_path(board), lists_endpoint: board_lists_path(board),
board_id: board.id, board_id: board.id,
board_milestone_title: board&.milestone&.title, board_milestone_title: board&.milestone&.title,
disabled: "#{!can?(current_user, :admin_list, @project)}", # Create this permission for groups( if needed ) disabled: "#{!can?(current_user, :admin_list, @project)}",
issue_link_base: @issues_path, issue_link_base: @issues_path,
root_path: root_path, root_path: root_path,
bulk_update_path: @bulk_issues_path, bulk_update_path: @bulk_issues_path,
......
...@@ -22,7 +22,7 @@ module EE ...@@ -22,7 +22,7 @@ module EE
end end
def parent def parent
group || project @parent ||= group || project
end end
def is_group_board? def is_group_board?
......
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