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