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
1782ec0b
Commit
1782ec0b
authored
Mar 06, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch '28010-mr-merge-button-default-to-danger' into 'master'"
This reverts commit
071bf3b7
.
parent
5343a65b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
38 additions
and
125 deletions
+38
-125
app/assets/javascripts/merge_request_widget.js.es6
app/assets/javascripts/merge_request_widget.js.es6
+19
-29
app/assets/javascripts/merge_request_widget/ci_bundle.js.es6
app/assets/javascripts/merge_request_widget/ci_bundle.js.es6
+6
-6
app/assets/stylesheets/pages/merge_requests.scss
app/assets/stylesheets/pages/merge_requests.scss
+1
-7
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-4
app/models/merge_request.rb
app/models/merge_request.rb
+1
-4
app/views/projects/merge_requests/widget/open/_accept.html.haml
...ews/projects/merge_requests/widget/open/_accept.html.haml
+7
-5
changelogs/unreleased/28010-mr-merge-button-default-to-danger.yml
...gs/unreleased/28010-mr-merge-button-default-to-danger.yml
+0
-4
spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb
...es/merge_requests/merge_immediately_with_pipeline_spec.rb
+1
-1
spec/features/merge_requests/widget_spec.rb
spec/features/merge_requests/widget_spec.rb
+2
-65
No files found.
app/assets/javascripts/merge_request_widget.js.es6
View file @
1782ec0b
...
@@ -129,9 +129,8 @@ require('./smart_interval');
...
@@ -129,9 +129,8 @@ require('./smart_interval');
};
};
MergeRequestWidget.prototype.getMergeStatus = function() {
MergeRequestWidget.prototype.getMergeStatus = function() {
return $.get(this.opts.merge_check_url,
(data) =>
{
return $.get(this.opts.merge_check_url,
function(data)
{
var $html = $(data);
var $html = $(data);
this.updateMergeButton(this.status, this.hasCi, $html);
$('.mr-widget-body').replaceWith($html.find('.mr-widget-body'));
$('.mr-widget-body').replaceWith($html.find('.mr-widget-body'));
$('.mr-widget-footer').replaceWith($html.find('.mr-widget-footer'));
$('.mr-widget-footer').replaceWith($html.find('.mr-widget-footer'));
});
});
...
@@ -155,9 +154,9 @@ require('./smart_interval');
...
@@ -155,9 +154,9 @@ require('./smart_interval');
return $.getJSON(this.opts.ci_status_url, (function(_this) {
return $.getJSON(this.opts.ci_status_url, (function(_this) {
return function(data) {
return function(data) {
var message, status, title;
var message, status, title;
_this.status = data.status;
if (!data.status) {
_this.hasCi = data.has_ci
;
return
;
_this.updateMergeButton(_this.status, _this.hasCi);
}
if (data.environments && data.environments.length) _this.renderEnvironments(data.environments);
if (data.environments && data.environments.length) _this.renderEnvironments(data.environments);
if (data.status !== _this.opts.ci_status ||
if (data.status !== _this.opts.ci_status ||
data.sha !== _this.opts.ci_sha ||
data.sha !== _this.opts.ci_sha ||
...
@@ -228,51 +227,42 @@ require('./smart_interval');
...
@@ -228,51 +227,42 @@ require('./smart_interval');
};
};
MergeRequestWidget.prototype.showCIStatus = function(state) {
MergeRequestWidget.prototype.showCIStatus = function(state) {
// TODO: Can this variable be removed? - Felipe Artur
var allowed_states;
var allowed_states;
if (state == null) {
if (state == null) {
return;
return;
}
}
$('.ci_widget').hide();
$('.ci_widget').hide();
$('.ci_widget.ci-' + state).show();
allowed_states = ["failed", "canceled", "running", "pending", "success", "success_with_warnings", "skipped", "not_found"];
if (indexOf.call(allowed_states, state) >= 0) {
this.initMiniPipelineGraph();
$('.ci_widget.ci-' + state).show();
};
MergeRequestWidget.prototype.showCICoverage = function(coverage) {
var text = `Coverage ${coverage}%`;
return $('.ci_widget:visible .ci-coverage').text(text);
};
MergeRequestWidget.prototype.updateMergeButton = function(state, hasCi, $html) {
const allowed_states = ["failed", "canceled", "running", "pending", "success", "success_with_warnings", "skipped", "not_found"];
let stateClass = 'btn-danger';
if (!hasCi) {
stateClass = 'btn-create';
} else if (indexOf.call(allowed_states, state) !== -1) {
switch (state) {
switch (state) {
case "failed":
case "failed":
case "canceled":
case "canceled":
case "not_found":
case "not_found":
stateClass = 'btn-danger'
;
this.setMergeButtonClass('btn-danger')
;
break;
break;
case "running":
case "running":
stateClass = 'btn-info'
;
this.setMergeButtonClass('btn-info')
;
break;
break;
case "success":
case "success":
case "success_with_warnings":
case "success_with_warnings":
stateClass = 'btn-create'
;
this.setMergeButtonClass('btn-create')
;
}
}
} else {
} else {
$('.ci_widget.ci-error').show();
$('.ci_widget.ci-error').show();
stateClass = 'btn-danger'
;
this.setMergeButtonClass('btn-danger')
;
}
}
this.initMiniPipelineGraph();
};
this.setMergeButtonClass(stateClass, $html);
MergeRequestWidget.prototype.showCICoverage = function(coverage) {
var text;
text = 'Coverage ' + coverage + '%';
return $('.ci_widget:visible .ci-coverage').text(text);
};
};
MergeRequestWidget.prototype.setMergeButtonClass = function(css_class
, $html = $('.mr-state-widget')
) {
MergeRequestWidget.prototype.setMergeButtonClass = function(css_class) {
return $
html.find('.js-merge-button
').removeClass('btn-danger btn-info btn-create').addClass(css_class);
return $
('.js-merge-button,.accept-action .dropdown-toggle
').removeClass('btn-danger btn-info btn-create').addClass(css_class);
};
};
MergeRequestWidget.prototype.updatePipelineUrls = function(id) {
MergeRequestWidget.prototype.updatePipelineUrls = function(id) {
...
...
app/assets/javascripts/merge_request_widget/ci_bundle.js.es6
View file @
1782ec0b
...
@@ -15,15 +15,15 @@
...
@@ -15,15 +15,15 @@
});
});
$(document)
$(document)
.off('click', '.accept
-merge-
request')
.off('click', '.accept
_merge_
request')
.on('click', '.accept
-merge-
request', () => {
.on('click', '.accept
_merge_
request', () => {
$('.js-merge-button
, .js-merge-when-pipeline-succeeds-button
').html('<i class="fa fa-spinner fa-spin"></i> Merge in progress');
$('.js-merge-button').html('<i class="fa fa-spinner fa-spin"></i> Merge in progress');
});
});
$(document)
$(document)
.off('click', '.merge
-when-pipeline-
succeeds')
.off('click', '.merge
_when_build_
succeeds')
.on('click', '.merge
-when-pipeline-
succeeds', () => {
.on('click', '.merge
_when_build_
succeeds', () => {
$('#merge_when_
pipeline
_succeeds').val('1');
$('#merge_when_
build
_succeeds').val('1');
});
});
$(document)
$(document)
...
...
app/assets/stylesheets/pages/merge_requests.scss
View file @
1782ec0b
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
background-color
:
$gl-success
;
background-color
:
$gl-success
;
}
}
.accept
-merge-
request
{
.accept
_merge_
request
{
&
.ci-pending
,
&
.ci-pending
,
&
.ci-running
{
&
.ci-running
{
@include
btn-blue
;
@include
btn-blue
;
...
@@ -42,12 +42,6 @@
...
@@ -42,12 +42,6 @@
@include
btn-red
;
@include
btn-red
;
}
}
}
}
.dropdown-toggle
{
.fa
{
color
:
inherit
;
}
}
}
}
.accept-control
{
.accept-control
{
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
1782ec0b
...
@@ -308,7 +308,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -308,7 +308,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
merge_check
def
merge_check
@merge_request
.
check_if_can_be_merged
@merge_request
.
check_if_can_be_merged
@pipelines
=
@merge_request
.
all_pipelines
render
partial:
"projects/merge_requests/widget/show.html.haml"
,
layout:
false
render
partial:
"projects/merge_requests/widget/show.html.haml"
,
layout:
false
end
end
...
@@ -427,7 +426,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -427,7 +426,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
ci_status
def
ci_status
pipeline
=
@merge_request
.
head_pipeline
pipeline
=
@merge_request
.
head_pipeline
@pipelines
=
@merge_request
.
all_pipelines
if
pipeline
if
pipeline
status
=
pipeline
.
status
status
=
pipeline
.
status
...
@@ -446,8 +444,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -446,8 +444,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
sha:
(
merge_request
.
diff_head_commit
.
short_id
if
merge_request
.
diff_head_sha
),
sha:
(
merge_request
.
diff_head_commit
.
short_id
if
merge_request
.
diff_head_sha
),
status:
status
,
status:
status
,
coverage:
coverage
,
coverage:
coverage
,
pipeline:
pipeline
.
try
(
:id
),
pipeline:
pipeline
.
try
(
:id
)
has_ci:
@merge_request
.
has_ci?
}
}
render
json:
response
render
json:
response
...
...
app/models/merge_request.rb
View file @
1782ec0b
...
@@ -692,10 +692,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -692,10 +692,7 @@ class MergeRequest < ActiveRecord::Base
end
end
def
has_ci?
def
has_ci?
has_ci_integration
=
source_project
.
try
(
:ci_service
)
source_project
.
try
(
:ci_service
)
&&
commits
.
any?
uses_gitlab_ci
=
all_pipelines
.
any?
(
has_ci_integration
||
uses_gitlab_ci
)
&&
commits
.
any?
end
end
def
branch_missing?
def
branch_missing?
...
...
app/views/projects/merge_requests/widget/open/_accept.html.haml
View file @
1782ec0b
-
content_for
:page_specific_javascripts
do
-
content_for
:page_specific_javascripts
do
=
page_specific_javascript_bundle_tag
(
'merge_request_widget'
)
=
page_specific_javascript_bundle_tag
(
'merge_request_widget'
)
-
status_class
=
@pipeline
?
" ci-
#{
@pipeline
.
status
}
"
:
nil
=
form_for
[
:merge
,
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@merge_request
],
remote:
true
,
method: :post
,
html:
{
class:
'accept-mr-form js-quick-submit js-requires-input'
}
do
|
f
|
=
form_for
[
:merge
,
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@merge_request
],
remote:
true
,
method: :post
,
html:
{
class:
'accept-mr-form js-quick-submit js-requires-input'
}
do
|
f
|
=
hidden_field_tag
:authenticity_token
,
form_authenticity_token
=
hidden_field_tag
:authenticity_token
,
form_authenticity_token
=
hidden_field_tag
:sha
,
@merge_request
.
diff_head_sha
=
hidden_field_tag
:sha
,
@merge_request
.
diff_head_sha
...
@@ -9,10 +11,10 @@
...
@@ -9,10 +11,10 @@
.accept-action
.accept-action
-
if
@pipeline
&&
@pipeline
.
active?
-
if
@pipeline
&&
@pipeline
.
active?
%span
.btn-group
%span
.btn-group
=
button_tag
class:
"btn btn-
info js-merge-when-pipeline-succeeds-button merge-when-pipeline-
succeeds"
do
=
button_tag
class:
"btn btn-
create js-merge-button merge_when_build_
succeeds"
do
Merge When Pipeline Succeeds
Merge When Pipeline Succeeds
-
unless
@project
.
only_allow_merge_if_
pipeline
_succeeds?
-
unless
@project
.
only_allow_merge_if_
build
_succeeds?
=
button_tag
class:
"btn btn-
info
dropdown-toggle"
,
'data-toggle'
=>
'dropdown'
do
=
button_tag
class:
"btn btn-
success
dropdown-toggle"
,
'data-toggle'
=>
'dropdown'
do
=
icon
(
'caret-down'
)
=
icon
(
'caret-down'
)
%span
.sr-only
%span
.sr-only
Select Merge Moment
Select Merge Moment
...
@@ -22,11 +24,11 @@
...
@@ -22,11 +24,11 @@
=
icon
(
'check fw'
)
=
icon
(
'check fw'
)
Merge When Pipeline Succeeds
Merge When Pipeline Succeeds
%li
%li
=
link_to
"#"
,
class:
"accept
-merge-
request"
do
=
link_to
"#"
,
class:
"accept
_merge_
request"
do
=
icon
(
'warning fw'
)
=
icon
(
'warning fw'
)
Merge Immediately
Merge Immediately
-
else
-
else
=
f
.
button
class:
"btn btn-
grouped js-merge-button accept-merge-request
"
do
=
f
.
button
class:
"btn btn-
create btn-grouped js-merge-button accept_merge_request
#{
status_class
}
"
do
Accept Merge Request
Accept Merge Request
-
if
@merge_request
.
force_remove_source_branch?
-
if
@merge_request
.
force_remove_source_branch?
.accept-control
.accept-control
...
...
changelogs/unreleased/28010-mr-merge-button-default-to-danger.yml
deleted
100644 → 0
View file @
5343a65b
---
title
:
Default to subtle MR mege button until CI status is available
merge_request
:
author
:
spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb
View file @
1782ec0b
...
@@ -34,7 +34,7 @@ feature 'Merge immediately', :feature, :js do
...
@@ -34,7 +34,7 @@ feature 'Merge immediately', :feature, :js do
click_link
'Merge Immediately'
click_link
'Merge Immediately'
expect
(
find
(
'.js-merge-
when-pipeline-succeeds-
button'
)).
to
have_content
(
'Merge in progress'
)
expect
(
find
(
'.js-merge-button'
)).
to
have_content
(
'Merge in progress'
)
end
end
end
end
end
end
...
...
spec/features/merge_requests/widget_spec.rb
View file @
1782ec0b
...
@@ -3,8 +3,8 @@ require 'rails_helper'
...
@@ -3,8 +3,8 @@ require 'rails_helper'
describe
'Merge request'
,
:feature
,
:js
do
describe
'Merge request'
,
:feature
,
:js
do
include
WaitForAjax
include
WaitForAjax
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
before
do
before
do
...
@@ -31,7 +31,7 @@ describe 'Merge request', :feature, :js do
...
@@ -31,7 +31,7 @@ describe 'Merge request', :feature, :js do
wait_for_ajax
wait_for_ajax
expect
(
page
).
to
have_selector
(
'.accept
-merge-
request'
)
expect
(
page
).
to
have_selector
(
'.accept
_merge_
request'
)
end
end
end
end
...
@@ -51,69 +51,6 @@ describe 'Merge request', :feature, :js do
...
@@ -51,69 +51,6 @@ describe 'Merge request', :feature, :js do
expect
(
find
(
'.js-environment-link'
)[
:href
]).
to
include
(
environment
.
formatted_external_url
)
expect
(
find
(
'.js-environment-link'
)[
:href
]).
to
include
(
environment
.
formatted_external_url
)
end
end
end
end
it
'shows green accept merge request button'
do
# Wait for the `ci_status` and `merge_check` requests
wait_for_ajax
expect
(
page
).
to
have_selector
(
'.accept-merge-request.btn-create'
)
end
end
context
'view merge request with external CI service'
do
before
do
create
(
:service
,
project:
project
,
active:
true
,
type:
'CiService'
,
category:
'ci'
)
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
it
'has danger button while waiting for external CI status'
do
# Wait for the `ci_status` and `merge_check` requests
wait_for_ajax
expect
(
page
).
to
have_selector
(
'.accept-merge-request.btn-danger'
)
end
end
context
'view merge request with failed GitLab CI pipelines'
do
before
do
commit_status
=
create
(
:commit_status
,
project:
project
,
status:
'failed'
)
pipeline
=
create
(
:ci_pipeline
,
project:
project
,
sha:
merge_request
.
diff_head_sha
,
ref:
merge_request
.
source_branch
,
status:
'failed'
,
statuses:
[
commit_status
])
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
it
'has danger button when not succeeded'
do
# Wait for the `ci_status` and `merge_check` requests
wait_for_ajax
expect
(
page
).
to
have_selector
(
'.accept-merge-request.btn-danger'
)
end
end
context
'view merge request with MWBS button'
do
before
do
commit_status
=
create
(
:commit_status
,
project:
project
,
status:
'pending'
)
pipeline
=
create
(
:ci_pipeline
,
project:
project
,
sha:
merge_request
.
diff_head_sha
,
ref:
merge_request
.
source_branch
,
status:
'pending'
,
statuses:
[
commit_status
])
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
it
'has info button when MWBS button'
do
# Wait for the `ci_status` and `merge_check` requests
wait_for_ajax
expect
(
page
).
to
have_selector
(
'.merge-when-pipeline-succeeds.btn-info'
)
end
end
end
context
'merge error'
do
context
'merge error'
do
...
...
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