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
Boxiang Sun
gitlab-ce
Commits
d2d8037b
Commit
d2d8037b
authored
Jun 11, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor merge request widget step 2
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
644b6ba9
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
60 additions
and
75 deletions
+60
-75
app/assets/javascripts/merge_request.js.coffee
app/assets/javascripts/merge_request.js.coffee
+4
-23
app/assets/stylesheets/pages/merge_requests.scss
app/assets/stylesheets/pages/merge_requests.scss
+1
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+9
-1
app/views/projects/merge_requests/automerge.js.haml
app/views/projects/merge_requests/automerge.js.haml
+4
-4
app/views/projects/merge_requests/widget/_closed.html.haml
app/views/projects/merge_requests/widget/_closed.html.haml
+1
-1
app/views/projects/merge_requests/widget/_heading.html.haml
app/views/projects/merge_requests/widget/_heading.html.haml
+4
-0
app/views/projects/merge_requests/widget/_locked.html.haml
app/views/projects/merge_requests/widget/_locked.html.haml
+1
-1
app/views/projects/merge_requests/widget/_merged.html.haml
app/views/projects/merge_requests/widget/_merged.html.haml
+1
-1
app/views/projects/merge_requests/widget/_mr_accept.html.haml
...views/projects/merge_requests/widget/_mr_accept.html.haml
+0
-20
app/views/projects/merge_requests/widget/_open.html.haml
app/views/projects/merge_requests/widget/_open.html.haml
+1
-1
app/views/projects/merge_requests/widget/open/_accept.html.haml
...ews/projects/merge_requests/widget/open/_accept.html.haml
+6
-0
app/views/projects/merge_requests/widget/open/_check.html.haml
...iews/projects/merge_requests/widget/open/_check.html.haml
+4
-0
app/views/projects/merge_requests/widget/open/_conflict.html.haml
...s/projects/merge_requests/widget/open/_conflict.html.haml
+0
-5
app/views/projects/merge_requests/widget/open/_conflicts.html.haml
.../projects/merge_requests/widget/open/_conflicts.html.haml
+9
-0
app/views/projects/merge_requests/widget/open/_not_allowed.html.haml
...rojects/merge_requests/widget/open/_not_allowed.html.haml
+2
-9
app/views/projects/merge_requests/widget/open/_reload.html.haml
...ews/projects/merge_requests/widget/open/_reload.html.haml
+1
-0
app/views/projects/merge_requests/widget/open/_wip.html.haml
app/views/projects/merge_requests/widget/open/_wip.html.haml
+12
-8
No files found.
app/assets/javascripts/merge_request.js.coffee
View file @
d2d8037b
...
@@ -27,14 +27,11 @@ class @MergeRequest
...
@@ -27,14 +27,11 @@ class @MergeRequest
this
.
bindEvents
()
this
.
bindEvents
()
this
.
activateTabFromPath
()
this
.
activateTabFromPath
()
this
.
initMergeWidget
()
this
.
$
(
'.show-all-commits'
).
on
'click'
,
=>
this
.
$
(
'.show-all-commits'
).
on
'click'
,
=>
this
.
showAllCommits
()
this
.
showAllCommits
()
modal
=
$
(
'#modal_merge_info'
).
modal
(
show
:
false
)
modal
=
$
(
'#modal_merge_info'
).
modal
(
show
:
false
)
disableButtonIfEmptyField
'#commit_message'
,
'.accept_merge_request'
# Prevent duplicate event bindings
# Prevent duplicate event bindings
@
disableTaskList
()
@
disableTaskList
()
...
@@ -63,14 +60,11 @@ class @MergeRequest
...
@@ -63,14 +60,11 @@ class @MergeRequest
$
(
".context .inline-update"
).
on
"change"
,
"#merge_request_assignee_id"
,
->
$
(
".context .inline-update"
).
on
"change"
,
"#merge_request_assignee_id"
,
->
$
(
this
).
submit
()
$
(
this
).
submit
()
initMergeWidget
:
->
getMergeStatus
:
->
this
.
showState
(
@
opts
.
current_status
)
$
.
get
@
opts
.
url_to_automerge_check
,
(
data
)
->
$
(
'.mr-state-widget'
).
replaceWith
(
data
)
if
this
.
$
(
'.automerge_widget'
).
length
and
@
opts
.
check_enable
$
.
get
@
opts
.
url_to_automerge_check
,
(
data
)
=>
this
.
showState
(
data
.
merge_status
)
,
'json'
getCiStatus
:
->
if
@
opts
.
ci_enable
if
@
opts
.
ci_enable
$
.
get
@
opts
.
url_to_ci_check
,
(
data
)
=>
$
.
get
@
opts
.
url_to_ci_check
,
(
data
)
=>
this
.
showCiState
data
.
status
this
.
showCiState
data
.
status
...
@@ -92,10 +86,6 @@ class @MergeRequest
...
@@ -92,10 +86,6 @@ class @MergeRequest
unless
@
opts
.
action
==
'new'
unless
@
opts
.
action
==
'new'
@
setCurrentAction
(
tab_action
)
@
setCurrentAction
(
tab_action
)
this
.
$
(
'.accept_merge_request'
).
on
'click'
,
->
$
(
'.automerge_widget.can_be_merged'
).
hide
()
$
(
'.merge-in-progress'
).
show
()
this
.
$
(
'.remove_source_branch'
).
on
'click'
,
->
this
.
$
(
'.remove_source_branch'
).
on
'click'
,
->
$
(
'.remove_source_branch_widget'
).
hide
()
$
(
'.remove_source_branch_widget'
).
hide
()
$
(
'.remove_source_branch_in_progress'
).
show
()
$
(
'.remove_source_branch_in_progress'
).
show
()
...
@@ -157,10 +147,6 @@ class @MergeRequest
...
@@ -157,10 +147,6 @@ class @MergeRequest
# See https://github.com/rails/turbolinks/issues/363
# See https://github.com/rails/turbolinks/issues/363
history
.
replaceState
{
turbolinks
:
true
,
url
:
new_state
},
''
,
new_state
history
.
replaceState
{
turbolinks
:
true
,
url
:
new_state
},
''
,
new_state
showState
:
(
state
)
->
$
(
'.automerge_widget'
).
hide
()
$
(
'.automerge_widget.'
+
state
).
show
()
showCiState
:
(
state
)
->
showCiState
:
(
state
)
->
$
(
'.ci_widget'
).
hide
()
$
(
'.ci_widget'
).
hide
()
allowed_states
=
[
"failed"
,
"canceled"
,
"running"
,
"pending"
,
"success"
]
allowed_states
=
[
"failed"
,
"canceled"
,
"running"
,
"pending"
,
"success"
]
...
@@ -198,11 +184,6 @@ class @MergeRequest
...
@@ -198,11 +184,6 @@ class @MergeRequest
this
.
$
(
'.first-commits'
).
remove
()
this
.
$
(
'.first-commits'
).
remove
()
this
.
$
(
'.all-commits'
).
removeClass
'hide'
this
.
$
(
'.all-commits'
).
removeClass
'hide'
alreadyOrCannotBeMerged
:
->
this
.
$
(
'.automerge_widget'
).
hide
()
this
.
$
(
'.merge-in-progress'
).
hide
()
this
.
$
(
'.automerge_widget.already_cannot_be_merged'
).
show
()
setMergeButtonClass
:
(
css_class
)
->
setMergeButtonClass
:
(
css_class
)
->
$
(
'.accept_merge_request'
).
removeClass
(
"btn-create"
).
addClass
(
css_class
)
$
(
'.accept_merge_request'
).
removeClass
(
"btn-create"
).
addClass
(
css_class
)
...
...
app/assets/stylesheets/pages/merge_requests.scss
View file @
d2d8037b
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* MR -> show: Automerge widget
* MR -> show: Automerge widget
*
*
*/
*/
.
automerge_
widget
{
.
mr-state-
widget
{
form
{
form
{
margin-bottom
:
0
;
margin-bottom
:
0
;
.clearfix
{
.clearfix
{
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
d2d8037b
...
@@ -139,7 +139,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -139,7 +139,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request
.
check_if_can_be_merged
@merge_request
.
check_if_can_be_merged
end
end
render
json:
{
merge_status:
@merge_request
.
automerge_status
}
@allowed_to_merge
=
allowed_to_merge?
closes_issues
render
partial:
"projects/merge_requests/widget/show.html.haml"
,
layout:
false
end
end
def
automerge
def
automerge
...
@@ -151,6 +155,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -151,6 +155,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
else
else
@status
=
false
@status
=
false
end
end
respond_to
do
|
format
|
format
.
js
end
end
end
def
branch_from
def
branch_from
...
...
app/views/projects/merge_requests/automerge.js.haml
View file @
d2d8037b
-
if
@status
-
if
@status
:plain
:plain
merge_request.
mergeInProgres
s();
merge_request.
getMergeStatu
s();
-
else
-
else
:plain
:plain
merge_request.alreadyOrCannotBeMerged()
$('.mr-widget-body').html("
#{
escape_javascript
(
render
(
'projects/merge_requests/widget/open/reload'
))
}
");
app/views/projects/merge_requests/widget/_closed.html.haml
View file @
d2d8037b
.mr-state-widget
.mr-state-widget
=
render
'heading'
=
render
'
projects/merge_requests/widget/
heading'
.mr-widget-body
.mr-widget-body
%h4
%h4
Rejected
Rejected
...
...
app/views/projects/merge_requests/widget/_heading.html.haml
View file @
d2d8037b
...
@@ -32,3 +32,7 @@
...
@@ -32,3 +32,7 @@
.ci_widget.ci-error
{
style:
"display:none"
}
.ci_widget.ci-error
{
style:
"display:none"
}
=
icon
(
"times"
)
=
icon
(
"times"
)
%span
Cannot connect to the CI server. Please check your settings and try again.
%span
Cannot connect to the CI server. Please check your settings and try again.
:coffeescript
$ ->
merge_request.getCiStatus()
app/views/projects/merge_requests/widget/_locked.html.haml
View file @
d2d8037b
.mr-state-widget
.mr-state-widget
=
render
'heading'
=
render
'
projects/merge_requests/widget/
heading'
.mr-widget-body
.mr-widget-body
%h4
%h4
Merge in progress...
Merge in progress...
...
...
app/views/projects/merge_requests/widget/_merged.html.haml
View file @
d2d8037b
.mr-state-widget
.mr-state-widget
=
render
'heading'
=
render
'
projects/merge_requests/widget/
heading'
.mr-widget-body
.mr-widget-body
%h4
%h4
Accepted
Accepted
...
...
app/views/projects/merge_requests/widget/_mr_accept.html.haml
deleted
100644 → 0
View file @
644b6ba9
-
if
@show_merge_controls
.automerge_widget.can_be_merged.hide
.clearfix
.automerge_widget.cannot_be_merged.hide
%p
%button
.btn.disabled
{
:type
=>
'button'
}
%i
.fa.fa-warning
Accept Merge Request
This happens when Git is not able to automatically resolve conflicts between branches.
.automerge_widget.unchecked
.automerge_widget.already_cannot_be_merged.hide
%p
%strong
This merge request cannot be merged. Try to reload the page.
app/views/projects/merge_requests/widget/_open.html.haml
View file @
d2d8037b
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
=
render
'projects/merge_requests/widget/open/archived'
=
render
'projects/merge_requests/widget/open/archived'
-
elsif
!
@project
.
satellite
.
exists?
-
elsif
!
@project
.
satellite
.
exists?
=
render
'projects/merge_requests/widget/open/no_satellite'
=
render
'projects/merge_requests/widget/open/no_satellite'
-
elsif
@commits
.
blank?
-
elsif
@
merge_request
.
commits
.
blank?
=
render
'projects/merge_requests/widget/open/nothing'
=
render
'projects/merge_requests/widget/open/nothing'
-
elsif
@merge_request
.
branch_missing?
-
elsif
@merge_request
.
branch_missing?
=
render
'projects/merge_requests/widget/open/missing_branch'
=
render
'projects/merge_requests/widget/open/missing_branch'
...
...
app/views/projects/merge_requests/widget/open/_accept.html.haml
View file @
d2d8037b
=
form_for
[
:automerge
,
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@merge_request
],
remote:
true
,
method: :post
do
|
f
|
=
form_for
[
:automerge
,
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@merge_request
],
remote:
true
,
method: :post
do
|
f
|
=
hidden_field_tag
:authenticity_token
,
form_authenticity_token
.accept-merge-holder.clearfix.js-toggle-container
.accept-merge-holder.clearfix.js-toggle-container
.accept-action
.accept-action
=
f
.
submit
"Accept Merge Request"
,
class:
"btn btn-create accept_merge_request"
=
f
.
submit
"Accept Merge Request"
,
class:
"btn btn-create accept_merge_request"
...
@@ -22,3 +23,8 @@
...
@@ -22,3 +23,8 @@
%strong
%strong
=
link_to
"command line"
,
"#modal_merge_info"
,
class:
"how_to_merge_link vlink"
,
title:
"How To Merge"
,
"data-toggle"
=>
"modal"
=
link_to
"command line"
,
"#modal_merge_info"
,
class:
"how_to_merge_link vlink"
,
title:
"How To Merge"
,
"data-toggle"
=>
"modal"
:coffeescript
disableButtonIfEmptyField '#commit_message', '.accept_merge_request'
$('.accept_merge_request').on 'click', ->
$('.mr-widget-body').html("
#{
escape_javascript
(
render
(
'projects/merge_requests/widget/open/mip'
))
}
")
app/views/projects/merge_requests/widget/open/_check.html.haml
View file @
d2d8037b
...
@@ -2,3 +2,7 @@
...
@@ -2,3 +2,7 @@
%strong
%strong
%i
.fa.fa-spinner.fa-spin
%i
.fa.fa-spinner.fa-spin
Checking automatic merge…
Checking automatic merge…
:coffeescript
$ ->
merge_request.getMergeStatus()
app/views/projects/merge_requests/widget/open/_conflict.html.haml
deleted
100644 → 0
View file @
644b6ba9
%h4
This merge request contains merge conflicts that must be resolved.
You can try it manually on the
%strong
=
link_to
"command line"
,
"#modal_merge_info"
,
class:
"how_to_merge_link vlink"
,
title:
"How To Merge"
,
"data-toggle"
=>
"modal"
app/views/projects/merge_requests/widget/open/_conflicts.html.haml
0 → 100644
View file @
d2d8037b
-
if
@allowed_to_merge
%h4
This merge request contains merge conflicts that must be resolved.
You can try it manually on the
%strong
=
link_to
"command line"
,
"#modal_merge_info"
,
class:
"how_to_merge_link vlink"
,
title:
"How To Merge"
,
"data-toggle"
=>
"modal"
-
else
%strong
This merge request contains merge conflicts that must be resolved.
Only those with write access to this repository can merge merge requests.
app/views/projects/merge_requests/widget/open/_not_allowed.html.haml
View file @
d2d8037b
.automerge_widget.cannot_be_merged.hide
%strong
This request can be merged automatically.
%strong
This merge request contains merge conflicts that must be resolved.
Only those with write access to this repository can merge merge requests.
Only those with write access to this repository can merge merge requests.
.automerge_widget.work_in_progress.hide
%strong
This merge request is marked as Work In Progress.
Only those with write access to this repository can merge merge requests.
.automerge_widget.can_be_merged.hide
%strong
This request can be merged automatically.
Only those with write access to this repository can merge merge requests.
app/views/projects/merge_requests/widget/open/_reload.html.haml
0 → 100644
View file @
d2d8037b
This merge request cannot be merged. Try to reload the page.
app/views/projects/merge_requests/widget/open/_wip.html.haml
View file @
d2d8037b
%h4
-
if
@allowed_to_merge
%h4
This merge request cannot be accepted because it is marked as Work In Progress.
This merge request cannot be accepted because it is marked as Work In Progress.
%p
%p
%button
.btn.disabled
{
:type
=>
'button'
}
%button
.btn.disabled
{
:type
=>
'button'
}
%i
.fa.fa-warning
%i
.fa.fa-warning
Accept Merge Request
Accept Merge Request
When the merge request is ready, remove the "WIP" prefix from the title to allow it to be accepted.
When the merge request is ready, remove the "WIP" prefix from the title to allow it to be accepted.
-
else
%strong
This merge request is marked as Work In Progress.
Only those with write access to this repository can merge merge requests.
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