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
0
Merge Requests
0
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
Kazuhiko Shiozaki
gitlab-ce
Commits
cbdc8dd4
Commit
cbdc8dd4
authored
Jan 05, 2016
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds ajax open and close merges, with discussion/comments working as well
parent
5a997a02
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
25 deletions
+67
-25
app/assets/javascripts/merge_request.js.coffee
app/assets/javascripts/merge_request.js.coffee
+43
-0
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+4
-0
app/models/merge_request.rb
app/models/merge_request.rb
+0
-10
app/views/projects/merge_requests/_discussion.html.haml
app/views/projects/merge_requests/_discussion.html.haml
+4
-5
app/views/projects/merge_requests/show/_mr_title.html.haml
app/views/projects/merge_requests/show/_mr_title.html.haml
+16
-10
No files found.
app/assets/javascripts/merge_request.js.coffee
View file @
cbdc8dd4
...
...
@@ -22,6 +22,7 @@ class @MergeRequest
if
$
(
"a.btn-close"
).
length
@
initTaskList
()
@
initMergeRequestBtnEventListeners
()
# Local jQuery finder
$
:
(
selector
)
->
...
...
@@ -35,6 +36,48 @@ class @MergeRequest
# Show the first tab (Commits)
$
(
'.merge-request-tabs a[data-toggle="tab"]:first'
).
tab
(
'show'
)
initMergeRequestBtnEventListeners
:
->
_this
=
@
mergeRequestFailMessage
=
'Unable to update this merge request at this time.'
$
(
'a.btn-close, a.btn-reopen'
).
on
'click'
,
(
e
)
->
e
.
preventDefault
()
e
.
stopImmediatePropagation
()
$this
=
$
(
this
)
isClose
=
$this
.
hasClass
(
'btn-close'
)
shouldSubmit
=
$this
.
hasClass
(
'btn-comment'
)
if
shouldSubmit
_this
.
submitNoteForm
(
$this
.
closest
(
'form'
))
$this
.
prop
(
'disabled'
,
true
)
url
=
$this
.
attr
(
'href'
)
$
.
ajax
type
:
'PUT'
,
url
:
url
,
error
:
(
jqXHR
,
textStatus
,
errorThrown
)
->
mergeRequestStatus
=
if
isClose
then
'close'
else
'open'
new
Flash
(
mergeRequestFailMessage
,
'alert'
)
success
:
(
data
,
textStatus
,
jqXHR
)
->
if
data
.
saved
if
isClose
$
(
'a.btn-close'
).
addClass
(
'hidden'
)
$
(
'a.issuable-edit'
).
addClass
(
'hidden'
)
$
(
'a.btn-reopen'
).
removeClass
(
'hidden'
)
$
(
'div.status-box-closed'
).
removeClass
(
'hidden'
)
$
(
'div.status-box-open'
).
addClass
(
'hidden'
)
else
$
(
'a.btn-reopen'
).
addClass
(
'hidden'
)
$
(
'a.issuable-edit'
).
removeClass
(
'hidden'
)
$
(
'a.btn-close'
).
removeClass
(
'hidden'
)
$
(
'div.status-box-closed'
).
addClass
(
'hidden'
)
$
(
'div.status-box-open'
).
removeClass
(
'hidden'
)
else
new
Flash
(
mergeRequestFailMessage
,
'alert'
)
$this
.
prop
(
'disabled'
,
false
)
submitNoteForm
:
(
form
)
=>
noteText
=
form
.
find
(
"textarea.js-note-text"
).
val
()
if
noteText
.
trim
().
length
>
0
form
.
submit
()
showAllCommits
:
->
this
.
$
(
'.first-commits'
).
remove
()
this
.
$
(
'.all-commits'
).
removeClass
'hide'
...
...
app/helpers/merge_requests_helper.rb
View file @
cbdc8dd4
...
...
@@ -19,6 +19,10 @@ module MergeRequestsHelper
}
end
def
merge_request_button_visibility
(
mr
,
closed
)
return
'hidden'
if
mr
.
closed?
==
closed
end
def
mr_css_classes
(
mr
)
classes
=
"merge-request"
classes
<<
" closed"
if
mr
.
closed?
...
...
app/models/merge_request.rb
View file @
cbdc8dd4
...
...
@@ -456,16 +456,6 @@ class MergeRequest < ActiveRecord::Base
::
Gitlab
::
GitAccess
.
new
(
user
,
project
).
can_push_to_branch?
(
target_branch
)
end
def
state_human_name
if
merged?
"Merged"
elsif
closed?
"Closed"
else
"Open"
end
end
def
target_sha
@target_sha
||=
target_project
.
repository
.
commit
(
target_branch
).
sha
...
...
app/views/projects/merge_requests/_discussion.html.haml
View file @
cbdc8dd4
-
content_for
:note_actions
do
-
if
can?
(
current_user
,
:update_merge_request
,
@merge_request
)
-
if
@merge_request
.
open?
=
link_to
'Close'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :close
}),
method: :put
,
class:
"btn btn-nr btn-grouped btn-close close-mr-link js-note-target-close"
,
title:
"Close merge request"
-
if
@merge_request
.
closed?
=
link_to
'Reopen'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :reopen
}),
method: :put
,
class:
"btn btn-nr btn-grouped btn-reopen reopen-mr-link js-note-target-reopen"
,
title:
"Reopen merge request"
=
link_to
'Close'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :close
},
format:
'json'
),
data:
{
no_turbolinks:
true
},
method: :put
,
class:
"btn btn-nr btn-grouped btn-close close-mr-link btn-comment js-note-target-close
#{
merge_request_button_visibility
(
@merge_request
,
true
)
}
"
,
title:
"Close merge request"
=
link_to
'Reopen'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :reopen
},
format:
'json'
),
data:
{
no_turbolinks:
true
},
method: :put
,
class:
"btn btn-nr btn-grouped btn-reopen reopen-mr-link btn-comment js-note-target-reopen
#{
merge_request_button_visibility
(
@merge_request
,
false
)
}
"
,
title:
"Reopen merge request"
#notes
=
render
"projects/notes/notes_with_form"
#notes
=
render
"projects/notes/notes_with_form"
app/views/projects/merge_requests/show/_mr_title.html.haml
View file @
cbdc8dd4
.detail-page-header
.status-box
{
class:
status_box_class
(
@merge_request
)
}
=
@merge_request
.
state_human_name
-
if
@merge_request
.
merged?
.status-box
{
class:
"status-box-merged"
}
Merged
-
else
.status-box
{
class:
"status-box-closed #{merge_request_button_visibility(@merge_request, false)}"
}
Closed
.status-box
{
class:
"status-box-open #{merge_request_button_visibility(@merge_request, true)}"
}
Open
%span
.identifier
Merge Request ##{@merge_request.iid}
%span
.creator
...
...
@@ -15,11 +21,11 @@
=
time_ago_with_tooltip
(
@merge_request
.
updated_at
,
placement:
'bottom'
)
.issue-btn-group.pull-right
-
if
can?
(
current_user
,
:update_merge_request
,
@merge_request
)
-
if
@merge_request
.
open?
=
link_to
'Close'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :close
}),
method: :put
,
class:
'btn btn-nr btn-grouped btn-close'
,
title:
'Close
merge request'
=
link_to
edit_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
class:
'btn btn-nr btn-grouped issuable-edit'
,
id:
'edit_merge_request'
do
%i
.fa.fa-pencil-square-o
Edit
-
if
@merge_request
.
closed?
=
link_to
'Reopen'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :reopen
}),
method: :put
,
class:
'btn btn-nr btn-grouped btn-reopen reopen-mr-link'
,
title:
'Reopen merge request'
-
if
can?
(
current_user
,
:update_merge_request
,
@merge_request
)
&&
!
@merge_request
.
merged?
=
link_to
'Reopen'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :reopen
},
format:
'json'
),
data:
{
no_turbolink:
true
},
method: :put
,
class:
"btn btn-nr btn-grouped btn-reopen reopen-mr-link
#{
merge_request_button_visibility
(
@merge_request
,
false
)
}
"
,
title:
'Reopen
merge request'
=
link_to
'Close'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :close
},
format:
'json'
),
data:
{
no_turbolink:
true
},
method: :put
,
class:
"btn btn-nr btn-grouped btn-close
#{
merge_request_button_visibility
(
@merge_request
,
true
)
}
"
,
title:
'Close merge request'
=
link_to
edit_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
class:
"btn btn-nr btn-grouped issuable-edit
#{
merge_request_button_visibility
(
@merge_request
,
true
)
}
"
,
id:
'edit_merge_request'
do
%i
.fa.fa-pencil-square-o
Edit
\ No newline at end of file
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