Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
65db35d1
Commit
65db35d1
authored
Aug 03, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use EE modules where needed and prepare to CE backport
parent
bbe9ee48
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
138 additions
and
80 deletions
+138
-80
app/controllers/boards/issues_controller.rb
app/controllers/boards/issues_controller.rb
+4
-4
app/controllers/boards/lists_controller.rb
app/controllers/boards/lists_controller.rb
+1
-1
app/controllers/concerns/boards_responses.rb
app/controllers/concerns/boards_responses.rb
+0
-48
app/controllers/concerns/ee/boards_responses.rb
app/controllers/concerns/ee/boards_responses.rb
+50
-0
app/controllers/groups/boards_controller.rb
app/controllers/groups/boards_controller.rb
+1
-1
app/controllers/projects/boards_controller.rb
app/controllers/projects/boards_controller.rb
+1
-1
app/helpers/boards_helper.rb
app/helpers/boards_helper.rb
+6
-20
app/helpers/ee/boards_helper.rb
app/helpers/ee/boards_helper.rb
+36
-0
app/helpers/ee/labels_helper.rb
app/helpers/ee/labels_helper.rb
+6
-0
app/models/ee/group.rb
app/models/ee/group.rb
+2
-0
app/models/ee/label.rb
app/models/ee/label.rb
+9
-0
app/models/group.rb
app/models/group.rb
+0
-1
app/models/label.rb
app/models/label.rb
+3
-1
app/services/boards/issues/list_service.rb
app/services/boards/issues/list_service.rb
+3
-2
app/services/ee/boards/issues/list_service.rb
app/services/ee/boards/issues/list_service.rb
+15
-0
spec/factories/boards.rb
spec/factories/boards.rb
+1
-1
No files found.
app/controllers/boards/issues_controller.rb
View file @
65db35d1
module
Boards
module
Boards
class
IssuesController
<
Boards
::
ApplicationController
class
IssuesController
<
Boards
::
ApplicationController
include
BoardsResponses
include
EE
::
BoardsResponses
before_action
:authorize_read_issue
,
only:
[
:index
]
before_action
:authorize_read_issue
,
only:
[
:index
]
before_action
:authorize_create_issue
,
only:
[
:create
]
before_action
:authorize_create_issue
,
only:
[
:create
]
...
@@ -72,9 +72,9 @@ module Boards
...
@@ -72,9 +72,9 @@ module Boards
end
end
def
issue_params
def
issue_params
params
.
require
(
:issue
)
.
params
.
require
(
:issue
)
permit
(
:title
,
:milestone_id
,
:project_id
).
.
permit
(
:title
,
:milestone_id
,
:project_id
)
merge
(
board_id:
params
[
:board_id
],
list_id:
params
[
:list_id
],
request:
request
)
.
merge
(
board_id:
params
[
:board_id
],
list_id:
params
[
:list_id
],
request:
request
)
end
end
def
serialize_as_json
(
resource
)
def
serialize_as_json
(
resource
)
...
...
app/controllers/boards/lists_controller.rb
View file @
65db35d1
module
Boards
module
Boards
class
ListsController
<
Boards
::
ApplicationController
class
ListsController
<
Boards
::
ApplicationController
include
BoardsResponses
include
EE
::
BoardsResponses
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
]
...
...
app/controllers/concerns/boards_responses.rb
deleted
100644 → 0
View file @
bbe9ee48
module
BoardsResponses
# Shared authorizations between projects and groups which
# have different policies.
def
authorize_read_list
ability
=
board
.
is_group_board?
?
:read_group
:
:read_list
authorize_action_for!
(
board
.
parent
,
ability
)
end
def
authorize_read_issue
ability
=
board
.
is_group_board?
?
:read_group
:
:read_issue
authorize_action_for!
(
board
.
parent
,
ability
)
end
def
authorize_update_issue
authorize_action_for!
(
issue
,
:admin_issue
)
end
def
authorize_create_issue
authorize_action_for!
(
project
,
:admin_issue
)
end
def
authorize_admin_list
authorize_action_for!
(
board
.
parent
,
:admin_list
)
end
def
authorize_action_for!
(
resource
,
ability
)
return
render_403
unless
can?
(
current_user
,
ability
,
resource
)
end
def
respond_with_boards
respond_with
(
@boards
)
end
def
respond_with_board
respond_with
(
@board
)
end
def
respond_with
(
resource
)
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
serialize_as_json
(
resource
)
end
end
end
end
app/controllers/concerns/ee/boards_responses.rb
0 → 100644
View file @
65db35d1
module
EE
module
BoardsResponses
# Shared authorizations between projects and groups which
# have different policies.
def
authorize_read_list
ability
=
board
.
is_group_board?
?
:read_group
:
:read_list
authorize_action_for!
(
board
.
parent
,
ability
)
end
def
authorize_read_issue
ability
=
board
.
is_group_board?
?
:read_group
:
:read_issue
authorize_action_for!
(
board
.
parent
,
ability
)
end
def
authorize_update_issue
authorize_action_for!
(
issue
,
:admin_issue
)
end
def
authorize_create_issue
authorize_action_for!
(
project
,
:admin_issue
)
end
def
authorize_admin_list
authorize_action_for!
(
board
.
parent
,
:admin_list
)
end
def
authorize_action_for!
(
resource
,
ability
)
return
render_403
unless
can?
(
current_user
,
ability
,
resource
)
end
def
respond_with_boards
respond_with
(
@boards
)
end
def
respond_with_board
respond_with
(
@board
)
end
def
respond_with
(
resource
)
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
serialize_as_json
(
resource
)
end
end
end
end
end
app/controllers/groups/boards_controller.rb
View file @
65db35d1
class
Groups::BoardsController
<
Groups
::
ApplicationController
class
Groups::BoardsController
<
Groups
::
ApplicationController
prepend
EE
::
Boards
::
BoardsController
prepend
EE
::
Boards
::
BoardsController
include
BoardsResponses
include
EE
::
BoardsResponses
before_action
:check_group_issue_boards_available!
before_action
:check_group_issue_boards_available!
before_action
:assign_endpoint_vars
before_action
:assign_endpoint_vars
...
...
app/controllers/projects/boards_controller.rb
View file @
65db35d1
class
Projects::BoardsController
<
Projects
::
ApplicationController
class
Projects::BoardsController
<
Projects
::
ApplicationController
prepend
EE
::
Boards
::
BoardsController
prepend
EE
::
Boards
::
BoardsController
include
IssuableCollections
include
IssuableCollections
include
BoardsResponses
include
EE
::
BoardsResponses
before_action
:authorize_read_board!
,
only:
[
:index
,
:show
]
before_action
:authorize_read_board!
,
only:
[
:index
,
:show
]
before_action
:assign_endpoint_vars
before_action
:assign_endpoint_vars
...
...
app/helpers/boards_helper.rb
View file @
65db35d1
...
@@ -20,9 +20,7 @@ module BoardsHelper
...
@@ -20,9 +20,7 @@ module BoardsHelper
end
end
def
build_issue_link_base
def
build_issue_link_base
return
project_issues_path
(
@project
)
unless
@board
.
is_group_board?
project_issues_path
(
@project
)
"/
#{
@board
.
group
.
path
}
/:project_path/issues"
end
end
def
current_board_json
def
current_board_json
...
@@ -37,11 +35,7 @@ module BoardsHelper
...
@@ -37,11 +35,7 @@ module BoardsHelper
end
end
def
board_base_url
def
board_base_url
if
@project
project_boards_path
(
@project
)
project_boards_path
(
@project
)
elsif
@group
group_boards_path
(
@group
)
end
end
end
def
multiple_boards_available?
def
multiple_boards_available?
...
@@ -49,17 +43,11 @@ module BoardsHelper
...
@@ -49,17 +43,11 @@ module BoardsHelper
end
end
def
board_path
(
board
)
def
board_path
(
board
)
@board_path
||=
begin
@board_path
||=
project_board_path
(
current_board_parent
,
board
)
if
board
.
is_group_board?
group_board_path
(
current_board_parent
,
board
)
else
project_board_path
(
current_board_parent
,
board
)
end
end
end
end
def
current_board_parent
def
current_board_parent
@current_board_parent
||=
@project
||
@group
@current_board_parent
||=
@project
end
end
def
can_admin_issue?
def
can_admin_issue?
...
@@ -72,8 +60,7 @@ module BoardsHelper
...
@@ -72,8 +60,7 @@ module BoardsHelper
list_labels_path:
labels_filter_path
(
true
),
list_labels_path:
labels_filter_path
(
true
),
labels_endpoint:
@labels_endpoint
,
labels_endpoint:
@labels_endpoint
,
namespace_path:
@namespace_path
,
namespace_path:
@namespace_path
,
project_path:
@project
&
.
try
(
:path
),
project_path:
@project
&
.
try
(
:path
)
group_path:
@group
&
.
try
(
:path
)
}
}
end
end
...
@@ -86,7 +73,6 @@ module BoardsHelper
...
@@ -86,7 +73,6 @@ module BoardsHelper
first_user:
current_user
&
.
username
,
first_user:
current_user
&
.
username
,
current_user:
'true'
,
current_user:
'true'
,
project_id:
@project
&
.
try
(
:id
),
project_id:
@project
&
.
try
(
:id
),
group_id:
@group
&
.
try
(
:id
),
null_user:
'true'
,
null_user:
'true'
,
multi_select:
'true'
,
multi_select:
'true'
,
'dropdown-header'
:
dropdown_options
[
:data
][
:'dropdown-header'
],
'dropdown-header'
:
dropdown_options
[
:data
][
:'dropdown-header'
],
...
...
app/helpers/ee/boards_helper.rb
View file @
65db35d1
...
@@ -4,5 +4,41 @@ module EE
...
@@ -4,5 +4,41 @@ module EE
parent
=
@group
||
@project
parent
=
@group
||
@project
super
.
merge
(
focus_mode_available:
parent
.
feature_available?
(
:issue_board_focus_mode
).
to_s
)
super
.
merge
(
focus_mode_available:
parent
.
feature_available?
(
:issue_board_focus_mode
).
to_s
)
end
end
def
build_issue_link_base
return
super
unless
@board
.
is_group_board?
"/
#{
@board
.
group
.
path
}
/:project_path/issues"
end
def
board_base_url
return
group_boards_path
(
@group
)
if
@group
end
def
board_path
(
board
)
@board_path
||=
begin
if
board
.
is_group_board?
group_board_path
(
current_board_parent
,
board
)
else
super
(
board
)
end
end
end
def
current_board_parent
@current_board_parent
||=
@group
||
super
end
def
can_admin_issue?
can?
(
current_user
,
:admin_issue
,
current_board_parent
)
end
def
board_list_data
super
.
merge
(
group_path:
@group
&
.
path
)
end
def
board_sidebar_user_data
super
.
merge
(
group_id:
@group
&
.
path
)
end
end
end
end
end
app/helpers/ee/labels_helper.rb
0 → 100644
View file @
65db35d1
module
EE
module
LabelsHelper
def
labels_filter_path
(
only_group_labels
=
false
)
end
end
end
app/models/ee/group.rb
View file @
65db35d1
...
@@ -7,6 +7,8 @@ module EE
...
@@ -7,6 +7,8 @@ module EE
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
included
do
included
do
has_many
:boards
state_machine
:ldap_sync_status
,
namespace: :ldap_sync
,
initial: :ready
do
state_machine
:ldap_sync_status
,
namespace: :ldap_sync
,
initial: :ready
do
state
:ready
state
:ready
state
:started
state
:started
...
...
app/models/ee/label.rb
0 → 100644
View file @
65db35d1
module
EE
module
Label
extend
ActiveSupport
::
Concern
prepended
do
scope
:on_group_boards
,
->
(
group_id
)
{
with_lists_and_board
.
where
(
boards:
{
group_id:
group_id
})
}
end
end
end
app/models/group.rb
View file @
65db35d1
...
@@ -22,7 +22,6 @@ class Group < Namespace
...
@@ -22,7 +22,6 @@ class Group < Namespace
has_many
:requesters
,
->
{
where
.
not
(
requested_at:
nil
)
},
dependent: :destroy
,
as: :source
,
class_name:
'GroupMember'
# rubocop:disable Cop/ActiveRecordDependent
has_many
:requesters
,
->
{
where
.
not
(
requested_at:
nil
)
},
dependent: :destroy
,
as: :source
,
class_name:
'GroupMember'
# rubocop:disable Cop/ActiveRecordDependent
has_many
:boards
has_many
:milestones
has_many
:milestones
has_many
:project_group_links
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:project_group_links
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:shared_projects
,
through: :project_group_links
,
source: :project
has_many
:shared_projects
,
through: :project_group_links
,
source: :project
...
...
app/models/label.rb
View file @
65db35d1
...
@@ -3,6 +3,9 @@ class Label < ActiveRecord::Base
...
@@ -3,6 +3,9 @@ class Label < ActiveRecord::Base
include
Referable
include
Referable
include
Subscribable
include
Subscribable
# EE specific
prepend
EE
::
Label
# Represents a "No Label" state used for filtering Issues and Merge
# Represents a "No Label" state used for filtering Issues and Merge
# Requests that have no label assigned.
# Requests that have no label assigned.
LabelStruct
=
Struct
.
new
(
:title
,
:name
)
LabelStruct
=
Struct
.
new
(
:title
,
:name
)
...
@@ -36,7 +39,6 @@ class Label < ActiveRecord::Base
...
@@ -36,7 +39,6 @@ class Label < ActiveRecord::Base
scope
:with_title
,
->
(
title
)
{
where
(
title:
title
)
}
scope
:with_title
,
->
(
title
)
{
where
(
title:
title
)
}
scope
:with_lists_and_board
,
->
{
joins
(
lists: :board
).
merge
(
List
.
movable
)
}
scope
:with_lists_and_board
,
->
{
joins
(
lists: :board
).
merge
(
List
.
movable
)
}
scope
:on_project_boards
,
->
(
project_id
)
{
with_lists_and_board
.
where
(
boards:
{
project_id:
project_id
})
}
scope
:on_project_boards
,
->
(
project_id
)
{
with_lists_and_board
.
where
(
boards:
{
project_id:
project_id
})
}
scope
:on_group_boards
,
->
(
group_id
)
{
with_lists_and_board
.
where
(
boards:
{
group_id:
group_id
})
}
def
self
.
prioritized
(
project
)
def
self
.
prioritized
(
project
)
joins
(
:priorities
)
joins
(
:priorities
)
...
...
app/services/boards/issues/list_service.rb
View file @
65db35d1
module
Boards
module
Boards
module
Issues
module
Issues
class
ListService
<
BaseService
class
ListService
<
BaseService
prepend
EE
::
Boards
::
Issues
::
ListService
def
execute
def
execute
issues
=
IssuesFinder
.
new
(
current_user
,
filter_params
).
execute
issues
=
IssuesFinder
.
new
(
current_user
,
filter_params
).
execute
issues
=
without_board_labels
(
issues
)
unless
movable_list?
||
closed_list?
issues
=
without_board_labels
(
issues
)
unless
movable_list?
||
closed_list?
...
@@ -45,8 +47,7 @@ module Boards
...
@@ -45,8 +47,7 @@ module Boards
end
end
def
set_parent
def
set_parent
param_key
=
parent
.
is_a?
(
Group
)
?
:group_id
:
:project_id
params
[
:project_id
]
=
@parent
.
id
params
[
param_key
]
=
parent
.
id
end
end
def
set_state
def
set_state
...
...
app/services/ee/boards/issues/list_service.rb
0 → 100644
View file @
65db35d1
module
EE
module
Boards
module
Issues
module
ListService
def
set_parent
if
@parent
.
is_a?
(
Group
)
params
[
:group_id
]
=
@parent
.
id
else
super
end
end
end
end
end
end
spec/factories/boards.rb
View file @
65db35d1
...
@@ -10,7 +10,7 @@ FactoryGirl.define do
...
@@ -10,7 +10,7 @@ FactoryGirl.define do
parent
nil
parent
nil
end
end
after
(
:build
)
do
|
board
,
evaluator
|
after
(
:build
,
:stub
)
do
|
board
,
evaluator
|
if
evaluator
.
group
if
evaluator
.
group
board
.
group
=
evaluator
.
group
board
.
group
=
evaluator
.
group
elsif
evaluator
.
group_id
elsif
evaluator
.
group_id
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment