Commit 951fbe6d authored by Felipe Artur's avatar Felipe Artur

Fix board form for project and make it re-usable for groups

parent 5dedc534
...@@ -22,9 +22,7 @@ module BoardsAuthorizations ...@@ -22,9 +22,7 @@ module BoardsAuthorizations
end end
def authorize_admin_list! def authorize_admin_list!
ability = board.is_group_board? ? :admin_milestones : :admin_list return render_403 unless action_allowed_for?(board.parent, :admin_list)
return render_403 unless action_allowed_for?(board.parent, ability)
end end
......
module EE module EE
module Projects module Boards
module BoardsController module BoardsController
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepended do prepended do
......
class Groups::BoardsController < Groups::ApplicationController class Groups::BoardsController < Groups::ApplicationController
prepend EE::Boards::BoardsController
before_action :check_group_issue_boards_available! before_action :check_group_issue_boards_available!
before_action :assign_endpoint_vars before_action :assign_endpoint_vars
......
class Projects::BoardsController < Projects::ApplicationController class Projects::BoardsController < Projects::ApplicationController
prepend EE::Projects::BoardsController prepend EE::Boards::BoardsController
include IssuableCollections include IssuableCollections
before_action :authorize_read_board!, only: [:index, :show] before_action :authorize_read_board!, only: [:index, :show]
......
...@@ -36,11 +36,21 @@ module BoardsHelper ...@@ -36,11 +36,21 @@ module BoardsHelper
end end
end end
def multiple_boards_available def multiple_boards_available?
if @project current_board_parent.multiple_issue_boards_available?(current_user)
@project.feature_available?(:multiple_issue_boards) end
elsif @group
@group.feature_available?(:multiple_issue_boards) def board_path(board)
@board_path ||= begin
if board.is_group_board?
group_board_path(current_board_parent, board)
else
project_board_path(current_board_parent, board)
end end
end end
end
def current_board_parent
@current_board_parent ||= @project || @group
end
end end
...@@ -235,6 +235,10 @@ class Namespace < ActiveRecord::Base ...@@ -235,6 +235,10 @@ class Namespace < ActiveRecord::Base
feature_available?(:multiple_issue_boards) feature_available?(:multiple_issue_boards)
end end
def issue_board_milestone_available?(user = nil)
feature_available?(:issue_board_milestone)
end
private private
def repository_storage_paths def repository_storage_paths
......
...@@ -1438,6 +1438,10 @@ class Project < ActiveRecord::Base ...@@ -1438,6 +1438,10 @@ class Project < ActiveRecord::Base
feature_available?(:multiple_issue_boards, user) feature_available?(:multiple_issue_boards, user)
end end
def issue_board_milestone_available?(user = nil)
feature_available?(:issue_board_milestone, user)
end
alias_method :name_with_namespace, :full_name alias_method :name_with_namespace, :full_name
alias_method :human_name, :full_name alias_method :human_name, :full_name
alias_method :path_with_namespace, :full_path alias_method :path_with_namespace, :full_path
......
...@@ -6,6 +6,14 @@ module EE ...@@ -6,6 +6,14 @@ module EE
with_scope :subject with_scope :subject
condition(:ldap_synced) { @subject.ldap_synced? } condition(:ldap_synced) { @subject.ldap_synced? }
rule { reporter }.policy do
enable :admin_list
enable :admin_board
end
rule { public_group } .enable :read_board
rule { guest } .enable :read_board
rule { ldap_synced }.prevent :admin_group_member rule { ldap_synced }.prevent :admin_group_member
rule { ldap_synced & admin }.policy do rule { ldap_synced & admin }.policy do
......
module Boards module Boards
class DestroyService < BaseService class DestroyService < BaseService
def execute(board) def execute(board)
return false if project.boards.size == 1 return false if parent.boards.size == 1
board.destroy board.destroy
end end
......
module Boards module Boards
class UpdateService < BaseService class UpdateService < BaseService
def execute(board) def execute(board)
params.delete(:milestone_id) unless project.feature_available?(:issue_board_milestone) params.delete(:milestone_id) unless parent.feature_available?(:issue_board_milestone)
board.update(params) board.update(params)
end end
......
- parent = board.parent
%boards-selector{ "inline-template" => true, %boards-selector{ "inline-template" => true,
":current-board" => current_board_json, ":current-board" => current_board_json,
"milestone-path" => milestones_filter_path(:json) } "milestone-path" => milestones_filter_path(:json) }
...@@ -22,38 +24,38 @@ ...@@ -22,38 +24,38 @@
%li{ "v-for" => "board in boards" } %li{ "v-for" => "board in boards" }
%a{ ":href" => "'#{board_base_url}/' + board.id" } %a{ ":href" => "'#{board_base_url}/' + board.id" }
{{ board.name }} {{ board.name }}
- if !multiple_boards_available && @boards.size > 1 - if !multiple_boards_available? && @boards.size > 1
%li.small %li.small
Some of your boards are hidden, activate a license to see them again. Some of your boards are hidden, activate a license to see them again.
.dropdown-loading{ "v-if" => "loading" } .dropdown-loading{ "v-if" => "loading" }
= icon("spin spinner") = icon("spin spinner")
- if can?(current_user, :admin_board, @group) - if can?(current_user, :admin_board, parent)
%board-selector-form{ "inline-template" => true, %board-selector-form{ "inline-template" => true,
":milestone-path" => "milestonePath", ":milestone-path" => "milestonePath",
"v-if" => "currentPage === 'new' || currentPage === 'edit' || currentPage === 'milestone'" } "v-if" => "currentPage === 'new' || currentPage === 'edit' || currentPage === 'milestone'" }
= render "group/boards/components/form" = render "shared/boards/components/form"
.dropdown-content.board-selector-page-two{ "v-if" => "currentPage === 'delete'" } .dropdown-content.board-selector-page-two{ "v-if" => "currentPage === 'delete'" }
%p %p
Are you sure you want to delete this board? Are you sure you want to delete this board?
.board-delete-btns.clearfix .board-delete-btns.clearfix
= link_to group_board_path(@group, board), = link_to board_path(board),
class: "btn btn-danger pull-left", class: "btn btn-danger pull-left",
method: :delete do method: :delete do
Delete Delete
%button.btn.btn-default.pull-right{ type: "button", %button.btn.btn-default.pull-right{ type: "button",
"@click.stop.prevent" => "showPage('')" } "@click.stop.prevent" => "showPage('')" }
Cancel Cancel
- if can?(current_user, :admin_board, @group) - if can?(current_user, :admin_board, parent)
.dropdown-footer{ "v-if" => "currentPage === ''" } .dropdown-footer{ "v-if" => "currentPage === ''" }
%ul.dropdown-footer-list %ul.dropdown-footer-list
- if @group.feature_available?(:multiple_issue_boards) - if parent.feature_available?(:multiple_issue_boards)
%li %li
%a{ "href" => "#", "@click.stop.prevent" => "showPage('new')" } %a{ "href" => "#", "@click.stop.prevent" => "showPage('new')" }
Create new board Create new board
%li %li
%a{ "href" => "#", "@click.stop.prevent" => "showPage('edit')" } %a{ "href" => "#", "@click.stop.prevent" => "showPage('edit')" }
Edit board name Edit board name
- if @group.feature_available?(:issue_board_milestone, current_user) - if parent.issue_board_milestone_available?(current_user)
%li %li
%a{ "href" => "#", "@click.stop.prevent" => "showPage('milestone')" } %a{ "href" => "#", "@click.stop.prevent" => "showPage('milestone')" }
Edit board milestone Edit board milestone
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
%input.form-control{ type: "text", %input.form-control{ type: "text",
id: "board-new-name", id: "board-new-name",
"v-model" => "board.name" } "v-model" => "board.name" }
- if @project.feature_available?(:issue_board_milestone, current_user) - if current_board_parent.issue_board_milestone_available?(current_user)
.dropdown.board-inner-milestone-dropdown{ ":class" => "{ open: milestoneDropdownOpen }", .dropdown.board-inner-milestone-dropdown{ ":class" => "{ open: milestoneDropdownOpen }",
"v-if" => "currentPage === 'new'" } "v-if" => "currentPage === 'new'" }
%label.label-light{ for: "board-milestone" } %label.label-light{ for: "board-milestone" }
......
...@@ -63,19 +63,7 @@ scope(path: 'groups/*group_id', ...@@ -63,19 +63,7 @@ scope(path: 'groups/*group_id',
end end
## EE-specific ## EE-specific
resources :boards, only: [:index, :show, :create, :update, :destroy] do resources :boards, only: [:index, :show, :create, :update, :destroy]
scope module: :boards do
resources :issues, only: [:index, :update]
resources :lists, only: [:index, :create, :update, :destroy] do
collection do
post :generate
end
resources :issues, only: [:index, :create]
end
end
end
end end
scope(path: 'groups/*id', scope(path: 'groups/*id',
......
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