Commit a0cd4f8f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'improve-merge-request-widget' into 'master'

Improve merge request widget

Return merge request widget improvements that were reverted with satellites

See merge request !1140
parents 630a9421 91836272
...@@ -47,6 +47,8 @@ v 7.14.0 (unreleased) ...@@ -47,6 +47,8 @@ v 7.14.0 (unreleased)
- Add support for CI skipped status - Add support for CI skipped status
- Fetch code from forks to refs/merge-requests/:id/head when merge request created - Fetch code from forks to refs/merge-requests/:id/head when merge request created
- Remove comments and email addresses when publicly exposing ssh keys (Zeger-Jan van de Weg) - Remove comments and email addresses when publicly exposing ssh keys (Zeger-Jan van de Weg)
- Improve MR merge widget text and UI consistency.
- Improve text in MR "How To Merge" modal.
- Cache all events - Cache all events
- Order commits by date when comparing branches - Order commits by date when comparing branches
- Fix bug causing error when the target branch of a symbolic ref was deleted - Fix bug causing error when the target branch of a symbolic ref was deleted
......
...@@ -49,10 +49,8 @@ class @MergeRequestWidget ...@@ -49,10 +49,8 @@ class @MergeRequestWidget
@setMergeButtonClass('btn-danger') @setMergeButtonClass('btn-danger')
showCiCoverage: (coverage) -> showCiCoverage: (coverage) ->
cov_html = $('<span>') text = 'Coverage ' + coverage + '%'
cov_html.addClass('ci-coverage') $('.ci_widget:visible .ci-coverage').text(text)
cov_html.text('Coverage ' + coverage + '%')
$('.ci_widget:visible').append(cov_html)
setMergeButtonClass: (css_class) -> setMergeButtonClass: (css_class) ->
$('.accept_merge_request').removeClass("btn-create").addClass(css_class) $('.accept_merge_request').removeClass("btn-create").addClass(css_class)
/**
/**
* MR -> show: Automerge widget * MR -> show: Automerge widget
* *
*/ */
.mr-state-widget { .mr-state-widget {
background: #FAFAFA;
margin-bottom: 20px;
color: #666;
border: 1px solid #e5e5e5;
@include box-shadow(0 1px 1px rgba(0, 0, 0, 0.05));
@include border-radius(3px);
form { form {
margin-bottom: 0; margin-bottom: 0;
.clearfix { .clearfix {
...@@ -20,15 +26,66 @@ ...@@ -20,15 +26,66 @@
display: inline-block; display: inline-block;
margin: 0; margin: 0;
margin-left: 20px; margin-left: 20px;
padding: 10px 0; padding: 5px;
line-height: 20px; line-height: 20px;
font-weight: bold;
.remove_source_checkbox { .remove_source_checkbox {
margin: 0; margin: 0;
}
}
}
.ci_widget {
border-bottom: 1px solid #EEE;
i {
margin-right: 4px;
}
&.ci-success {
color: $gl-success;
}
&.ci-skipped {
background-color: #eee;
color: #888;
}
&.ci-pending,
&.ci-running {
color: $gl-warning;
}
&.ci-failed,
&.ci-canceled,
&.ci-error {
color: $gl-danger;
}
}
.mr-widget-body,
.ci_widget,
.mr-widget-footer {
padding: 15px;
}
.mr-widget-body {
h4 {
font-weight: bold; font-weight: bold;
margin: 5px 0;
}
p:last-child {
margin-bottom: 0;
} }
} }
.mr-widget-footer {
border-top: 1px solid #EEE;
}
.ci-coverage {
float: right;
} }
} }
...@@ -61,23 +118,10 @@ ...@@ -61,23 +118,10 @@
} }
.label-branch { .label-branch {
@include border-radius(4px); color: #222;
padding: 3px 4px;
border: none;
background: $hover;
color: #333;
font-family: $monospace_font; font-family: $monospace_font;
font-weight: normal; font-weight: bold;
overflow: hidden; overflow: hidden;
.label-project {
@include border-radius-left(4px);
padding: 3px 4px;
background: #279;
position: relative;
left: -4px;
letter-spacing: -1px;
}
} }
.mr-list { .mr-list {
...@@ -124,64 +168,6 @@ ...@@ -124,64 +168,6 @@
display: none; display: none;
} }
.mr-state-widget {
font-size: 13px;
background: #FAFAFA;
margin-bottom: 20px;
color: #666;
border: 1px solid #e5e5e5;
@include box-shadow(0 1px 1px rgba(0, 0, 0, 0.05));
@include border-radius(3px);
.ci_widget {
padding: 10px 15px;
font-size: 15px;
border-bottom: 1px solid #EEE;
&.ci-success {
color: $gl-success;
}
&.ci-skipped {
background-color: #eee;
color: #888;
}
&.ci-pending,
&.ci-running {
color: $gl-warning;
}
&.ci-failed,
&.ci-canceled,
&.ci-error {
color: $gl-danger;
}
}
.mr-widget-body {
padding: 10px 15px;
h4 {
font-weight: bold;
margin: 5px 0;
}
p:last-child {
margin-bottom: 0;
}
}
.mr-widget-footer {
padding: 10px 15px;
border-top: 1px solid #EEE;
}
.ci-coverage {
float: right;
}
}
.merge-request-show-labels { .merge-request-show-labels {
a { a {
margin-right: 5px; margin-right: 5px;
...@@ -196,3 +182,7 @@ ...@@ -196,3 +182,7 @@
.merge-request-form .select2-container { .merge-request-form .select2-container {
width: 250px !important; width: 250px !important;
} }
#modal_merge_info .modal-dialog {
width: 600px;
}
...@@ -61,4 +61,14 @@ module MergeRequestsHelper ...@@ -61,4 +61,14 @@ module MergeRequestsHelper
} }
) )
end end
def source_branch_with_namespace(merge_request)
if merge_request.for_fork?
namespace = link_to(merge_request.source_project_namespace,
project_path(merge_request.source_project))
namespace + ":#{merge_request.source_branch}"
else
merge_request.source_branch
end
end
end end
...@@ -6,21 +6,6 @@ ...@@ -6,21 +6,6 @@
= render "projects/merge_requests/show/mr_box" = render "projects/merge_requests/show/mr_box"
%hr %hr
.append-bottom-20 .append-bottom-20
.slead
%span From
- if @merge_request.for_fork?
%strong.label-branch<
- if @merge_request.source_project
= link_to @merge_request.source_project_namespace, namespace_project_path(@merge_request.source_project.namespace, @merge_request.source_project)
- else
\ #{@merge_request.source_project_namespace}
\:#{@merge_request.source_branch}
%span into
%strong.label-branch #{@merge_request.target_project_namespace}:#{@merge_request.target_branch}
- else
%strong.label-branch #{@merge_request.source_branch}
%span into
%strong.label-branch #{@merge_request.target_branch}
- if @merge_request.open? - if @merge_request.open?
.btn-group.btn-group-sm.pull-right .btn-group.btn-group-sm.pull-right
%a.btn.btn-sm.dropdown-toggle{ data: {toggle: :dropdown} } %a.btn.btn-sm.dropdown-toggle{ data: {toggle: :dropdown} }
...@@ -30,16 +15,16 @@ ...@@ -30,16 +15,16 @@
%ul.dropdown-menu %ul.dropdown-menu
%li= link_to "Email Patches", merge_request_path(@merge_request, format: :patch) %li= link_to "Email Patches", merge_request_path(@merge_request, format: :patch)
%li= link_to "Plain Diff", merge_request_path(@merge_request, format: :diff) %li= link_to "Plain Diff", merge_request_path(@merge_request, format: :diff)
.light
- if @merge_request.open? and @merge_request.source_branch_exists? %div
.append-bottom-20 %span From
.slead %span.label-branch #{source_branch_with_namespace(@merge_request)}
%span %span into
Fetch the branch with %span.label-branch #{@merge_request.target_branch}
%strong.label-branch< - if @merge_request.open? && !@merge_request.branch_missing?
git fetch %div
\ #{@merge_request.source_project.http_url_to_repo} If you want to try or merge this request manually, you can use the
\ #{@merge_request.source_branch} = link_to "command line", "#modal_merge_info", class: "how_to_merge_link vlink", title: "How To Merge", "data-toggle" => "modal"
= render "projects/merge_requests/show/how_to_merge" = render "projects/merge_requests/show/how_to_merge"
= render "projects/merge_requests/widget/show.html.haml" = render "projects/merge_requests/widget/show.html.haml"
......
...@@ -3,42 +3,45 @@ ...@@ -3,42 +3,45 @@
.modal-content .modal-content
.modal-header .modal-header
%a.close{href: "#", "data-dismiss" => "modal"} × %a.close{href: "#", "data-dismiss" => "modal"} ×
%h3 How to merge %h3 Check out, review and merge locally
.modal-body .modal-body
- if @merge_request.for_fork?
- source_remote = @merge_request.source_project.namespace.nil? ? "source" :@merge_request.source_project.namespace.path
- target_remote = @merge_request.target_project.namespace.nil? ? "target" :@merge_request.target_project.namespace.path
%p %p
%strong Step 1. %strong Step 1.
Fetch the code and create a new branch pointing to it Fetch and check out the branch for this merge request
%pre.dark %pre.dark
- if @merge_request.for_fork?
:preserve :preserve
git fetch #{@merge_request.source_project.http_url_to_repo} #{@merge_request.source_branch} git fetch #{@merge_request.source_project.http_url_to_repo} #{@merge_request.source_branch}
git checkout -b #{@merge_request.source_project_path}-#{@merge_request.source_branch} FETCH_HEAD git checkout -b #{@merge_request.source_project_path}-#{@merge_request.source_branch} FETCH_HEAD
- else
:preserve
git fetch origin
git checkout -b #{@merge_request.source_branch} origin/#{@merge_request.source_branch}
%p %p
%strong Step 2. %strong Step 2.
Merge the branch and push the changes to GitLab Review the changes locally
%p
%strong Step 3.
Merge the branch and fix any conflicts that come up
%pre.dark %pre.dark
- if @merge_request.for_fork?
:preserve :preserve
git checkout #{@merge_request.target_branch} git checkout #{@merge_request.target_branch}
git merge --no-ff #{@merge_request.source_project_path}-#{@merge_request.source_branch} git merge --no-ff #{@merge_request.source_project_path}-#{@merge_request.source_branch}
git push origin #{@merge_request.target_branch}
- else - else
%p
%strong Step 1.
Update the repo and checkout the branch we are going to merge
%pre.dark
:preserve :preserve
git fetch origin git checkout #{@merge_request.target_branch}
git checkout -b #{@merge_request.source_branch} origin/#{@merge_request.source_branch} git merge --no-ff #{@merge_request.source_branch}
%p %p
%strong Step 2. %strong Step 4.
Merge the branch and push the changes to GitLab Push the result of the merge to GitLab
%pre.dark %pre.dark
:preserve :preserve
git checkout #{@merge_request.target_branch}
git merge --no-ff #{@merge_request.source_branch}
git push origin #{@merge_request.target_branch} git push origin #{@merge_request.target_branch}
- unless @merge_request.can_be_merged_by?(current_user)
%p
Note that pushing to GitLab requires write access to this repository.
:javascript :javascript
$(function(){ $(function(){
......
...@@ -6,4 +6,7 @@ ...@@ -6,4 +6,7 @@
- if @merge_request.closed_event - if @merge_request.closed_event
by #{link_to_member(@project, @merge_request.closed_event.author, avatar: true)} by #{link_to_member(@project, @merge_request.closed_event.author, avatar: true)}
#{time_ago_with_tooltip(@merge_request.closed_event.created_at)} #{time_ago_with_tooltip(@merge_request.closed_event.created_at)}
%p Changes were not merged into target branch %p
= succeed '.' do
The changes were not merged into
%span.label-branch= @merge_request.target_branch
- if @merge_request.has_ci? - if @merge_request.has_ci?
.mr-widget-heading .mr-widget-heading
.ci_widget.ci-success{style: "display:none"} - [:success, :skipped, :canceled, :failed, :running, :pending].each do |status|
= icon("check")
%span CI build passed
for #{@merge_request.last_commit_short_sha}.
= link_to "View build page", ci_build_details_path(@merge_request), :"data-no-turbolink" => "data-no-turbolink"
.ci_widget.ci-skipped{style: "display:none"}
= icon("check")
%span CI build skipped
for #{@merge_request.last_commit_short_sha}.
= link_to "View build page", ci_build_details_path(@merge_request), :"data-no-turbolink" => "data-no-turbolink"
.ci_widget.ci-failed{style: "display:none"}
= icon("times")
%span CI build failed
for #{@merge_request.last_commit_short_sha}.
= link_to "View build page", ci_build_details_path(@merge_request), :"data-no-turbolink" => "data-no-turbolink"
- [:running, :pending].each do |status|
.ci_widget{class: "ci-#{status}", style: "display:none"} .ci_widget{class: "ci-#{status}", style: "display:none"}
= icon("clock-o") - if status == :success
- status = "passed"
= icon("check-circle")
- else
= icon("circle")
%span CI build #{status} %span CI build #{status}
for #{@merge_request.last_commit_short_sha}. for #{@merge_request.last_commit_short_sha}.
= link_to "View build page", ci_build_details_path(@merge_request), :"data-no-turbolink" => "data-no-turbolink" %span.ci-coverage
= link_to "View build details", ci_build_details_path(@merge_request), :"data-no-turbolink" => "data-no-turbolink"
.ci_widget .ci_widget
= icon("spinner spin") = icon("spinner spin")
Checking for CI status for #{@merge_request.last_commit_short_sha} Checking CI status for #{@merge_request.last_commit_short_sha}&hellip;
.ci_widget.ci-not_found{style: "display:none"} .ci_widget.ci-not_found{style: "display:none"}
= icon("times") = icon("times-circle")
%span Can not find commit in the CI server Could not find CI status for #{@merge_request.last_commit_short_sha}.
for #{@merge_request.last_commit_short_sha}.
.ci_widget.ci-canceled{style: "display:none"}
= icon("times")
%span CI build canceled
for #{@merge_request.last_commit_short_sha}.
= link_to "View build page", ci_build_details_path(@merge_request), :"data-no-turbolink" => "data-no-turbolink"
.ci_widget.ci-error{style: "display:none"} .ci_widget.ci-error{style: "display:none"}
= icon("times") = icon("times-circle")
%span Cannot connect to the CI server. Please check your settings and try again. Could not connect to the CI server. Please check your settings and try again.
:coffeescript :coffeescript
$ -> $ ->
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
= render 'projects/merge_requests/widget/heading' = render 'projects/merge_requests/widget/heading'
.mr-widget-body .mr-widget-body
%h4 %h4
Merge in progress... = icon("spinner spin")
Merge in progress&hellip;
%p %p
Merging is in progress. While merging this request is locked and cannot be closed. This merge request is in the process of being merged, during which time it is locked and cannot be closed.
...@@ -7,23 +7,31 @@ ...@@ -7,23 +7,31 @@
by #{link_to_member(@project, @merge_request.merge_event.author, avatar: true)} by #{link_to_member(@project, @merge_request.merge_event.author, avatar: true)}
#{time_ago_with_tooltip(@merge_request.merge_event.created_at)} #{time_ago_with_tooltip(@merge_request.merge_event.created_at)}
%div %div
- if @source_branch.blank? - if !@merge_request.source_branch_exists?
Source branch has been removed = succeed '.' do
The changes were merged into
%span.label-branch= @merge_request.target_branch
The source branch has been removed.
- elsif can_remove_branch?(@merge_request.source_project, @merge_request.source_branch) && @merge_request.merged? - elsif can_remove_branch?(@merge_request.source_project, @merge_request.source_branch)
.remove_source_branch_widget .remove_source_branch_widget
%p Changes merged into #{@merge_request.target_branch}. You can remove source branch now %p
= succeed '.' do
The changes were merged into
%span.label-branch= @merge_request.target_branch
You can remove the source branch now.
= link_to namespace_project_branch_path(@merge_request.source_project.namespace, @merge_request.source_project, @source_branch), remote: true, method: :delete, class: "btn btn-primary btn-sm remove_source_branch" do = link_to namespace_project_branch_path(@merge_request.source_project.namespace, @merge_request.source_project, @source_branch), remote: true, method: :delete, class: "btn btn-primary btn-sm remove_source_branch" do
%i.fa.fa-times %i.fa.fa-times
Remove Source Branch Remove Source Branch
.remove_source_branch_widget.failed.hide .remove_source_branch_widget.failed.hide
Failed to remove source branch '#{@merge_request.source_branch}' %p
Failed to remove source branch '#{@merge_request.source_branch}'.
.remove_source_branch_in_progress.hide .remove_source_branch_in_progress.hide
%i.fa.fa-spinner.fa-spin %p
&nbsp; = icon('spinner spin')
Removing source branch '#{@merge_request.source_branch}'. Please wait. Page will be automatically reloaded. &nbsp; Removing source branch '#{@merge_request.source_branch}'. Please wait. This page will be automatically reload.
:coffeescript :coffeescript
$('.remove_source_branch').on 'click', -> $('.remove_source_branch').on 'click', ->
......
...@@ -24,6 +24,6 @@ ...@@ -24,6 +24,6 @@
.mr-widget-footer .mr-widget-footer
%span %span
%i.fa.fa-check %i.fa.fa-check
Accepting this merge request will close #{@closes_issues.size == 1 ? 'issue' : 'issues'} Accepting this merge request will close #{"issue".pluralize(@closes_issues.size)}
= succeed '.' do = succeed '.' do
!= gfm(issues_sentence(@closes_issues)) != gfm(issues_sentence(@closes_issues))
...@@ -8,22 +8,16 @@ ...@@ -8,22 +8,16 @@
.accept-control.checkbox .accept-control.checkbox
= label_tag :should_remove_source_branch, class: "remove_source_checkbox" do = label_tag :should_remove_source_branch, class: "remove_source_checkbox" do
= check_box_tag :should_remove_source_branch = check_box_tag :should_remove_source_branch
Remove source-branch Remove source branch
.accept-control .accept-control
= link_to "#", class: "modify-merge-commit-link js-toggle-button", title: "Modify merge commit message" do = link_to "#", class: "modify-merge-commit-link js-toggle-button" do
%i.fa.fa-edit = icon('edit')
Modify commit message Modify commit message
.js-toggle-content.hide.prepend-top-20 .js-toggle-content.hide.prepend-top-20
= render 'shared/commit_message_container', params: params, = render 'shared/commit_message_container', params: params,
text: @merge_request.merge_commit_message, text: @merge_request.merge_commit_message,
rows: 14, hint: true rows: 14, hint: true
%br
.light
If you want to merge this request manually, you can use the
%strong
= link_to "command line", "#modal_merge_info", class: "how_to_merge_link vlink", title: "How To Merge", "data-toggle" => "modal"
:coffeescript :coffeescript
$('.accept-mr-form').on 'ajax:before', -> $('.accept-mr-form').on 'ajax:before', ->
btn = $('.accept_merge_request') btn = $('.accept_merge_request')
......
%h4
Project is archived
%p %p
%strong Archived projects do not provide commit access. This merge request cannot be merged because archived projects cannot be written to.
%strong %strong
%i.fa.fa-spinner.fa-spin = icon("spinner spin")
Checking automatic merge… Checking ability to merge automatically&hellip;
:coffeescript :coffeescript
$ -> $ ->
......
- if @merge_request.can_be_merged_by?(current_user) %h4
%h4 = icon("exclamation-triangle")
This merge request contains merge conflicts that must be resolved. This merge request contains merge conflicts
%p
You can merge it manually using the %p
%strong Please resolve these conflicts or
= link_to "command line", "#modal_merge_info", class: "how_to_merge_link vlink", title: "How To Merge", "data-toggle" => "modal" - if @merge_request.can_be_merged_by?(current_user)
- else #{link_to "merge this request manually", "#modal_merge_info", class: "how_to_merge_link vlink", "data-toggle" => "modal"}.
%strong This merge request contains merge conflicts that must be resolved. - else
Only those with write access to this repository can merge merge requests. ask someone with write access to this repository to merge this request manually.
%h4 - unless @merge_request.source_branch_exists?
Can't be merged %h4
%p = icon("exclamation-triangle")
This merge request can not be accepted because branch Source branch
- unless @merge_request.source_branch_exists? %span.label-branch= source_branch_with_namespace(@merge_request)
%span.label.label-inverse= @merge_request.source_branch does not exist
does not exist in %p
%span.label.label-info= @merge_request.source_project_path Please restore the source branch or close this merge request and open a new merge request with a different source branch.
%br - else
%strong Please close this merge request and open a new merge request to change source branches. %h4
- else = icon("exclamation-triangle")
%span.label.label-inverse= @merge_request.target_branch Target branch
does not exist in %span.label-branch= @merge_request.target_branch
%span.label.label-info= @merge_request.target_project_path does not exist
%br %p
%strong Please close this merge request or change to another target branch. Please restore the target branch or use a different target branch.
%strong This request can be merged automatically. %h4
Only those with write access to this repository can merge merge requests. Ready to be merged automatically
%p
Ask someone with write access to this repository to merge this request.
%h4 Nothing to merge %h4
%p = icon("exclamation-triangle")
Nothing to merge from Nothing to merge from
%span.label-branch #{@merge_request.source_branch} %span.label-branch= source_branch_with_namespace(@merge_request)
to into
%span.label-branch #{@merge_request.target_branch} %span.label-branch= @merge_request.target_branch
%br %p
Try to use different branches or push new code. Please push new commits to the source branch or use a different target branch.
This merge request cannot be merged. Try to reload the page. %h4
= icon("exclamation-triangle")
This merge request failed to be merged automatically
%p
Please reload the page to find out the reason.
- if @merge_request.can_be_merged_by?(current_user) %h4
%h4 This merge request is currently a Work In Progress
This merge request cannot be accepted because it is marked as Work In Progress.
%p %p
%button.btn.disabled{:type => 'button'} When this merge request is ready, remove the "WIP" prefix from the title to allow it to be merged.
%i.fa.fa-warning
Accept Merge Request
&nbsp;
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.
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
%p.help-block %p.help-block
- if issuable.work_in_progress? - if issuable.work_in_progress?
Remove the <code>WIP</code> prefix from the title to allow this Remove the <code>WIP</code> prefix from the title to allow this
<strong>Work In Progress</strong> merge request to be accepted when it's ready. <strong>Work In Progress</strong> merge request to be merged when it's ready.
- else - else
Start the title with <code>[WIP]</code> or <code>WIP:</code> to prevent a Start the title with <code>[WIP]</code> or <code>WIP:</code> to prevent a
<strong>Work In Progress</strong> merge request from being accepted before it's ready. <strong>Work In Progress</strong> merge request from being merged before it's ready.
.form-group.issuable-description .form-group.issuable-description
= f.label :description, 'Description', class: 'control-label' = f.label :description, 'Description', class: 'control-label'
.col-sm-10 .col-sm-10
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment