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
2d633969
Commit
2d633969
authored
Jul 21, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move controllers to allow reusing
parent
ad36ddfb
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
121 additions
and
116 deletions
+121
-116
app/assets/javascripts/boards/boards_bundle.js
app/assets/javascripts/boards/boards_bundle.js
+4
-3
app/assets/javascripts/boards/services/board_service.js
app/assets/javascripts/boards/services/board_service.js
+5
-3
app/controllers/boards/application_controller.rb
app/controllers/boards/application_controller.rb
+15
-0
app/controllers/boards/issues_controller.rb
app/controllers/boards/issues_controller.rb
+0
-0
app/controllers/boards/lists_controller.rb
app/controllers/boards/lists_controller.rb
+84
-0
app/controllers/projects/boards/application_controller.rb
app/controllers/projects/boards/application_controller.rb
+0
-15
app/controllers/projects/boards/lists_controller.rb
app/controllers/projects/boards/lists_controller.rb
+0
-86
app/controllers/projects/boards_controller.rb
app/controllers/projects/boards_controller.rb
+1
-0
app/helpers/boards_helper.rb
app/helpers/boards_helper.rb
+2
-1
config/routes.rb
config/routes.rb
+10
-0
config/routes/project.rb
config/routes/project.rb
+0
-8
No files found.
app/assets/javascripts/boards/boards_bundle.js
View file @
2d633969
...
...
@@ -57,7 +57,8 @@ $(() => {
data
:
{
state
:
Store
.
state
,
loading
:
true
,
endpoint
:
$boardApp
.
dataset
.
endpoint
,
boardsEndpoint
:
$boardApp
.
dataset
.
boardsEndpoint
,
listsEndpoint
:
$boardApp
.
dataset
.
listsEndpoint
,
boardId
:
$boardApp
.
dataset
.
boardId
,
disabled
:
$boardApp
.
dataset
.
disabled
===
'
true
'
,
issueLinkBase
:
$boardApp
.
dataset
.
issueLinkBase
,
...
...
@@ -83,8 +84,8 @@ $(() => {
Store
.
updateFiltersUrl
(
true
);
}
gl
.
boardService
=
new
BoardService
(
this
.
e
ndpoint
,
this
.
bulkUpdatePath
,
this
.
boardId
);
Store
.
rootPath
=
this
.
e
ndpoint
;
gl
.
boardService
=
new
BoardService
(
this
.
boardsEndpoint
,
this
.
listsE
ndpoint
,
this
.
bulkUpdatePath
,
this
.
boardId
);
Store
.
rootPath
=
this
.
boardsE
ndpoint
;
this
.
filterManager
=
new
FilteredSearchBoards
(
Store
.
filter
,
true
,
[(
this
.
milestoneTitle
?
'
milestone
'
:
null
)]);
this
.
filterManager
.
setup
();
...
...
app/assets/javascripts/boards/services/board_service.js
View file @
2d633969
...
...
@@ -3,17 +3,19 @@
import
Vue
from
'
vue
'
;
class
BoardService
{
constructor
(
root
,
bulkUpdatePath
,
boardId
)
{
constructor
(
root
,
listsEndpoint
,
bulkUpdatePath
,
boardId
)
{
alert
(
listsEndpoint
)
alert
(
root
)
this
.
boards
=
Vue
.
resource
(
`
${
root
}
{/id}.json`
,
{},
{
issues
:
{
method
:
'
GET
'
,
url
:
`
${
root
}
/
${
boardId
}
/issues.json`
}
});
this
.
lists
=
Vue
.
resource
(
`
${
root
}
/
${
boardId
}
/lists
{/id}`
,
{},
{
this
.
lists
=
Vue
.
resource
(
`
${
listsEndpoint
}
{/id}`
,
{},
{
generate
:
{
method
:
'
POST
'
,
url
:
`
${
root
}
/
${
boardId
}
/lists
/generate.json`
url
:
`
${
listsEndpoint
}
/generate.json`
}
});
this
.
issue
=
Vue
.
resource
(
`
${
root
}
/
${
boardId
}
/issues{/id}`
,
{});
...
...
app/controllers/boards/application_controller.rb
0 → 100644
View file @
2d633969
module
Boards
class
ApplicationController
<
::
ApplicationController
respond_to
:json
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
private
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
end
end
app/controllers/
projects/
boards/issues_controller.rb
→
app/controllers/boards/issues_controller.rb
View file @
2d633969
File moved
app/controllers/boards/lists_controller.rb
0 → 100644
View file @
2d633969
module
Boards
class
ListsController
<
Boards
::
ApplicationController
# before_action :authorize_admin_list!, only: [:create, :update, :destroy, :generate]
# before_action :authorize_read_list!, only: [:index]
def
index
lists
=
::
Boards
::
Lists
::
ListService
.
new
(
project
,
current_user
).
execute
(
board
)
render
json:
serialize_as_json
(
lists
)
end
def
create
list
=
::
Boards
::
Lists
::
CreateService
.
new
(
project
,
current_user
,
list_params
).
execute
(
board
)
if
list
.
valid?
render
json:
serialize_as_json
(
list
)
else
render
json:
list
.
errors
,
status: :unprocessable_entity
end
end
def
update
list
=
board
.
lists
.
movable
.
find
(
params
[
:id
])
service
=
::
Boards
::
Lists
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
if
service
.
execute
(
list
)
head
:ok
else
head
:unprocessable_entity
end
end
def
destroy
list
=
board
.
lists
.
destroyable
.
find
(
params
[
:id
])
service
=
::
Boards
::
Lists
::
DestroyService
.
new
(
project
,
current_user
)
if
service
.
execute
(
list
)
head
:ok
else
head
:unprocessable_entity
end
end
def
generate
service
=
::
Boards
::
Lists
::
GenerateService
.
new
(
project
,
current_user
)
if
service
.
execute
(
board
)
render
json:
serialize_as_json
(
board
.
lists
.
movable
)
else
head
:unprocessable_entity
end
end
private
def
authorize_admin_list!
return
render_403
unless
can?
(
current_user
,
:admin_list
,
project
)
end
def
authorize_read_list!
return
render_403
unless
can?
(
current_user
,
:read_list
,
project
)
end
def
board
@board
||=
project
.
boards
.
find
(
params
[
:board_id
])
end
def
list_params
params
.
require
(
:list
).
permit
(
:label_id
)
end
def
move_params
params
.
require
(
:list
).
permit
(
:position
)
end
def
serialize_as_json
(
resource
)
resource
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
label:
true
)
end
end
end
app/controllers/projects/boards/application_controller.rb
deleted
100644 → 0
View file @
ad36ddfb
module
Projects
module
Boards
class
ApplicationController
<
Projects
::
ApplicationController
respond_to
:json
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
private
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
end
end
end
app/controllers/projects/boards/lists_controller.rb
deleted
100644 → 0
View file @
ad36ddfb
module
Projects
module
Boards
class
ListsController
<
Boards
::
ApplicationController
before_action
:authorize_admin_list!
,
only:
[
:create
,
:update
,
:destroy
,
:generate
]
before_action
:authorize_read_list!
,
only:
[
:index
]
def
index
lists
=
::
Boards
::
Lists
::
ListService
.
new
(
project
,
current_user
).
execute
(
board
)
render
json:
serialize_as_json
(
lists
)
end
def
create
list
=
::
Boards
::
Lists
::
CreateService
.
new
(
project
,
current_user
,
list_params
).
execute
(
board
)
if
list
.
valid?
render
json:
serialize_as_json
(
list
)
else
render
json:
list
.
errors
,
status: :unprocessable_entity
end
end
def
update
list
=
board
.
lists
.
movable
.
find
(
params
[
:id
])
service
=
::
Boards
::
Lists
::
MoveService
.
new
(
project
,
current_user
,
move_params
)
if
service
.
execute
(
list
)
head
:ok
else
head
:unprocessable_entity
end
end
def
destroy
list
=
board
.
lists
.
destroyable
.
find
(
params
[
:id
])
service
=
::
Boards
::
Lists
::
DestroyService
.
new
(
project
,
current_user
)
if
service
.
execute
(
list
)
head
:ok
else
head
:unprocessable_entity
end
end
def
generate
service
=
::
Boards
::
Lists
::
GenerateService
.
new
(
project
,
current_user
)
if
service
.
execute
(
board
)
render
json:
serialize_as_json
(
board
.
lists
.
movable
)
else
head
:unprocessable_entity
end
end
private
def
authorize_admin_list!
return
render_403
unless
can?
(
current_user
,
:admin_list
,
project
)
end
def
authorize_read_list!
return
render_403
unless
can?
(
current_user
,
:read_list
,
project
)
end
def
board
@board
||=
project
.
boards
.
find
(
params
[
:board_id
])
end
def
list_params
params
.
require
(
:list
).
permit
(
:label_id
)
end
def
move_params
params
.
require
(
:list
).
permit
(
:position
)
end
def
serialize_as_json
(
resource
)
resource
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
label:
true
)
end
end
end
end
app/controllers/projects/boards_controller.rb
View file @
2d633969
...
...
@@ -32,6 +32,7 @@ class Projects::BoardsController < Projects::ApplicationController
def
assign_endpoint_vars
@boards_endpoint
=
project_boards_path
(
project
)
@issues_path
=
project_issues_path
(
project
)
@bulk_issues_path
=
bulk_update_project_issues_path
(
@project
)
end
...
...
app/helpers/boards_helper.rb
View file @
2d633969
...
...
@@ -5,7 +5,8 @@ module BoardsHelper
board
=
@board
||
@boards
.
first
{
endpoint:
@boards_endpoint
,
boards_endpoint:
@boards_endpoint
,
lists_endpoint:
board_lists_path
(
board
),
board_id:
board
.
id
,
board_milestone_title:
board
&
.
milestone
&
.
title
,
disabled:
"
#{
!
can?
(
current_user
,
:admin_list
,
@project
)
}
"
,
# Create this permission for groups( if needed )
...
...
config/routes.rb
View file @
2d633969
...
...
@@ -96,5 +96,15 @@ Rails.application.routes.draw do
draw
:test
if
Rails
.
env
.
test?
resources
:boards
do
resources
:lists
,
module: :boards
,
only:
[
:index
,
:create
,
:update
,
:destroy
]
do
collection
do
post
:generate
end
resources
:issues
,
only:
[
:index
,
:create
,
:update
]
end
end
get
'*unmatched_route'
,
to:
'application#route_not_found'
end
config/routes/project.rb
View file @
2d633969
...
...
@@ -382,14 +382,6 @@ constraints(ProjectUrlConstrainer.new) do
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
...
...
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