BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
1dd279d8
Commit
1dd279d8
authored
Mar 15, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use helper to create list of projects issue can be moved to
This also adds confirmation message if issue move has been requested.
parent
41455893
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
6 deletions
+37
-6
issuable_form.js.coffee
app/assets/javascripts/issuable_form.js.coffee
+10
-1
issues_helper.rb
app/helpers/issues_helper.rb
+11
-0
_form.html.haml
app/views/shared/issuable/_form.html.haml
+3
-3
move_service_spec.rb
spec/services/issues/move_service_spec.rb
+13
-2
No files found.
app/assets/javascripts/issuable_form.js.coffee
View file @
1dd279d8
class
@
IssuableForm
ISSUE_MOVE_CONFIRM_MSG
=
'Are you sure you want to move this issue to another project?'
constructor
:
(
@
form
)
->
GitLab
.
GfmAutoComplete
.
setup
()
new
UsersSelect
()
...
...
@@ -6,12 +8,13 @@ class @IssuableForm
@
titleField
=
@
form
.
find
(
"input[name*='[title]']"
)
@
descriptionField
=
@
form
.
find
(
"textarea[name*='[description]']"
)
@
issueMoveField
=
@
form
.
find
(
"#move_to_project_id"
)
return
unless
@
titleField
.
length
&&
@
descriptionField
.
length
@
initAutosave
()
@
form
.
on
"submit"
,
@
resetAutosave
@
form
.
on
"submit"
,
@
handleSubmit
@
form
.
on
"click"
,
".btn-cancel"
,
@
resetAutosave
initAutosave
:
->
...
...
@@ -27,6 +30,12 @@ class @IssuableForm
"description"
]
handleSubmit
:
(
e
)
=>
@
resetAutosave
if
(
parseInt
(
@
issueMoveField
?
.
val
())
?
0
)
>
0
e
.
preventDefault
()
unless
confirm
(
ISSUE_MOVE_CONFIRM_MSG
)
resetAutosave
:
=>
@
titleField
.
data
(
"autosave"
).
reset
()
@
descriptionField
.
data
(
"autosave"
).
reset
()
app/helpers/issues_helper.rb
View file @
1dd279d8
...
...
@@ -57,6 +57,17 @@ module IssuesHelper
options_from_collection_for_select
(
milestones
,
'id'
,
'title'
,
object
.
milestone_id
)
end
def
project_options
(
issuable
,
current_user
,
ability: :read_project
)
projects
=
current_user
.
authorized_projects
projects
=
projects
.
select
do
|
project
|
current_user
.
can?
(
ability
,
project
)
&&
project
!=
issuable
.
project
end
projects
.
unshift
(
OpenStruct
.
new
(
id:
0
,
name_with_namespace:
'No project'
))
options_from_collection_for_select
(
projects
,
:id
,
:name_with_namespace
,
0
)
end
def
status_box_class
(
item
)
if
item
.
respond_to?
(
:expired?
)
&&
item
.
expired?
'status-box-expired'
...
...
app/views/shared/issuable/_form.html.haml
View file @
1dd279d8
...
...
@@ -72,9 +72,9 @@
.form-group
=
f
.
label
:move_to_project_id
,
'Move'
,
class:
'control-label'
.col-sm-10
=
project_select_tag
(
:move_to_project_id
,
placeholder:
'Select project'
,
class:
'custom-form-control'
,
data:
{
'select-id'
=>
'id'
,
'access-level'
=>
Gitlab
::
Access
::
REPORTER
,
'without-id'
=>
issuable
.
project
.
id
})
-
projects
=
project_options
(
issuable
,
current_user
,
ability: :admin_issue
)
=
select_tag
(
:move_to_project_id
,
projects
,
include_blank:
true
,
class:
'select2'
,
data:
{
placeholder:
'Select project'
})
-
if
issuable
.
is_a?
(
MergeRequest
)
%hr
...
...
spec/services/issues/move_service_spec.rb
View file @
1dd279d8
...
...
@@ -28,7 +28,7 @@ describe Issues::MoveService, services: true do
new_project
.
team
<<
[
user
,
:reporter
]
end
end
context
'issue movable'
do
include_context
'issue move requested'
include_context
'user can move issue'
...
...
@@ -162,6 +162,18 @@ describe Issues::MoveService, services: true do
end
end
context
'moving to same project'
do
let
(
:new_project
)
{
old_project
}
include_context
'issue move requested'
include_context
'user can move issue'
it
'raises error'
do
expect
{
move_service
}
.
to
raise_error
(
StandardError
,
/Cannot move issue/
)
end
end
context
'issue move not requested'
do
let
(
:new_project_id
)
{
nil
}
...
...
@@ -179,7 +191,6 @@ describe Issues::MoveService, services: true do
end
end
describe
'move permissions'
do
include_context
'issue move requested'
...
...
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