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
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
this
.
bindEvents
()
this
.
activateTabFromPath
()
this
.
initMergeWidget
()
this
.
$
(
'.show-all-commits'
).
on
'click'
,
=>
this
.
showAllCommits
()
modal
=
$
(
'#modal_merge_info'
).
modal
(
show
:
false
)
disableButtonIfEmptyField
'#commit_message'
,
'.accept_merge_request'
# Prevent duplicate event bindings
@
disableTaskList
()
...
...
@@ -63,14 +60,11 @@ class @MergeRequest
$
(
".context .inline-update"
).
on
"change"
,
"#merge_request_assignee_id"
,
->
$
(
this
).
submit
()
initMergeWidget
:
->
this
.
showState
(
@
opts
.
current_status
)
if
this
.
$
(
'.automerge_widget'
).
length
and
@
opts
.
check_enable
$
.
get
@
opts
.
url_to_automerge_check
,
(
data
)
=>
this
.
showState
(
data
.
merge_status
)
,
'json'
getMergeStatus
:
->
$
.
get
@
opts
.
url_to_automerge_check
,
(
data
)
->
$
(
'.mr-state-widget'
).
replaceWith
(
data
)
getCiStatus
:
->
if
@
opts
.
ci_enable
$
.
get
@
opts
.
url_to_ci_check
,
(
data
)
=>
this
.
showCiState
data
.
status
...
...
@@ -92,10 +86,6 @@ class @MergeRequest
unless
@
opts
.
action
==
'new'
@
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'
,
->
$
(
'.remove_source_branch_widget'
).
hide
()
$
(
'.remove_source_branch_in_progress'
).
show
()
...
...
@@ -157,10 +147,6 @@ class @MergeRequest
# See https://github.com/rails/turbolinks/issues/363
history
.
replaceState
{
turbolinks
:
true
,
url
:
new_state
},
''
,
new_state
showState
:
(
state
)
->
$
(
'.automerge_widget'
).
hide
()
$
(
'.automerge_widget.'
+
state
).
show
()
showCiState
:
(
state
)
->
$
(
'.ci_widget'
).
hide
()
allowed_states
=
[
"failed"
,
"canceled"
,
"running"
,
"pending"
,
"success"
]
...
...
@@ -198,11 +184,6 @@ class @MergeRequest
this
.
$
(
'.first-commits'
).
remove
()
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
)
->
$
(
'.accept_merge_request'
).
removeClass
(
"btn-create"
).
addClass
(
css_class
)
...
...
app/assets/stylesheets/pages/merge_requests.scss
View file @
d2d8037b
...
...
@@ -3,7 +3,7 @@
* MR -> show: Automerge widget
*
*/
.
automerge_
widget
{
.
mr-state-
widget
{
form
{
margin-bottom
:
0
;
.clearfix
{
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
d2d8037b
...
...
@@ -139,7 +139,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request
.
check_if_can_be_merged
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
def
automerge
...
...
@@ -151,6 +155,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
else
@status
=
false
end
respond_to
do
|
format
|
format
.
js
end
end
def
branch_from
...
...
app/views/projects/merge_requests/automerge.js.haml
View file @
d2d8037b
-
if
@status
-
if
@status
:plain
merge_request.
mergeInProgres
s();
-
else
merge_request.
getMergeStatu
s();
-
else
: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
=
render
'heading'
=
render
'
projects/merge_requests/widget/
heading'
.mr-widget-body
%h4
Rejected
...
...
app/views/projects/merge_requests/widget/_heading.html.haml
View file @
d2d8037b
...
...
@@ -32,3 +32,7 @@
.ci_widget.ci-error
{
style:
"display:none"
}
=
icon
(
"times"
)
%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
=
render
'heading'
=
render
'
projects/merge_requests/widget/
heading'
.mr-widget-body
%h4
Merge in progress...
...
...
app/views/projects/merge_requests/widget/_merged.html.haml
View file @
d2d8037b
.mr-state-widget
=
render
'heading'
=
render
'
projects/merge_requests/widget/
heading'
.mr-widget-body
%h4
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 @@
=
render
'projects/merge_requests/widget/open/archived'
-
elsif
!
@project
.
satellite
.
exists?
=
render
'projects/merge_requests/widget/open/no_satellite'
-
elsif
@commits
.
blank?
-
elsif
@
merge_request
.
commits
.
blank?
=
render
'projects/merge_requests/widget/open/nothing'
-
elsif
@merge_request
.
branch_missing?
=
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
|
=
hidden_field_tag
:authenticity_token
,
form_authenticity_token
.accept-merge-holder.clearfix.js-toggle-container
.accept-action
=
f
.
submit
"Accept Merge Request"
,
class:
"btn btn-create accept_merge_request"
...
...
@@ -22,3 +23,8 @@
%strong
=
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 @@
%strong
%i
.fa.fa-spinner.fa-spin
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 merge request contains merge conflicts that must be resolved.
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.
%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.
%p
%p
%button
.btn.disabled
{
:type
=>
'button'
}
%i
.fa.fa-warning
Accept Merge Request
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