Commit 4dc83505 authored by Rubén Dávila's avatar Rubén Dávila Committed by Robert Speicher
Browse files

Reuser revert commit modal in MR detail page.

parent ef591b87
......@@ -237,3 +237,11 @@
}
}
}
// Revert Merge Request modal
#modal-revert-commit {
.js-create-merge-request-container {
line-height: $line-height-base;
}
}
......@@ -192,27 +192,6 @@ def merge
end
end
def revert
url_params = {
merge_request: { source_branch: @merge_request.revert_branch_name,
target_branch: @merge_request.target_branch,
source_project_id: @merge_request.target_project_id,
target_project_id: @merge_request.target_project_id,
description: @merge_request.revert_description }
}
if @merge_request.target_branch_exists? && @merge_request.merge_commit_sha.present?
@repository.revert_merge(current_user, @merge_request.merge_commit_sha,
@merge_request.revert_branch_name, @merge_request.target_branch,
@merge_request.revert_title)
redirect_to new_namespace_project_merge_request_url(@project.namespace, @project, url_params)
else
redirect_to namespace_project_merge_request_url(@project.namespace, @project, @merge_request),
alert: 'Merge Request cannot be reverted because target branch was deleted.'
end
end
def branch_from
#This is always source
@source_project = @merge_request.nil? ? @project : @merge_request.source_project
......
......@@ -17,7 +17,7 @@
= icon('files-o')
Browse Files
- if can_collaborate_with_project?
= link_to '#modal-revert-commit', { 'data-target' => '#modal-revert-commit', 'data-toggle' => 'modal', class: 'btn btn-grouped'} do
= link_to '#modal-revert-commit', { 'data-target' => '#modal-revert-commit', 'data-toggle' => 'modal', class: 'btn btn-grouped btn-close'} do
Revert
- else
- continue_params = { to: namespace_project_commit_path(@project.namespace, @project, @commit.id),
......
......@@ -5,7 +5,7 @@
%a.close{href: "#", "data-dismiss" => "modal"} ×
%h3.page-title Revert commit
.modal-body
= form_tag revert_namespace_project_commit_path(@project.namespace, @project, @commit.id), method: :post, remote: false, class: 'form-horizontal js-create-dir-form js-requires-input' do
= form_tag revert_namespace_project_commit_path(@project.namespace, @project, commit_id), method: :post, remote: false, class: 'form-horizontal js-create-dir-form js-requires-input' do
.form-group.branch
= label_tag 'target_branch', 'Target branch', class: 'control-label'
.col-sm-10
......
......@@ -13,4 +13,4 @@
diff_refs: @diff_refs
= render "projects/notes/notes_with_form"
- if can_collaborate_with_project?
= render "projects/commit/revert"
= render "projects/commit/revert", commit_id: @commit.id
......@@ -19,4 +19,6 @@
- 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 @merge_request.merged? && @merge_request.merge_commit_sha.present?
= link_to 'Revert', revert_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), method: :post, class: "btn btn-grouped btn-close", title: "Revert merge request"
= render "projects/commit/revert", commit_id: @merge_request.merge_commit_sha
= link_to '#modal-revert-commit', { 'data-target' => '#modal-revert-commit', 'data-toggle' => 'modal', class: 'btn btn-grouped btn-close'} do
Revert
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