Refactor revert_commit_link helper.

This commit is contained in:
Rubén Dávila 2016-02-13 11:08:01 -05:00 committed by Robert Speicher
parent a07021fa8e
commit e8d15f1339
4 changed files with 4 additions and 10 deletions

View file

@ -123,10 +123,10 @@ module CommitsHelper
)
end
def revert_commit_link(show_modal_condition, continue_to_path, btn_class: nil)
def revert_commit_link(continue_to_path, btn_class: nil)
return unless current_user
if show_modal_condition
if can_collaborate_with_project?
content_tag :span, 'data-toggle' => 'modal', 'data-target' => '#modal-revert-commit' do
link_to 'Revert', '#modal-revert-commit', 'data-toggle' => 'tooltip', 'data-original-title' => 'Create merge request to revert commit', class: "btn btn-close btn-#{btn_class}"
end

View file

@ -92,10 +92,4 @@ module MergeRequestsHelper
["#{source_path}:#{source_branch}", "#{target_path}:#{target_branch}"]
end
end
def can_update_merge_request?
project ||= @project
can_collaborate_with_project?(project)
end
end

View file

@ -16,7 +16,7 @@
= link_to namespace_project_tree_path(@project.namespace, @project, @commit), class: "btn btn-grouped" do
= icon('files-o')
Browse Files
= revert_commit_link(can_collaborate_with_project?, namespace_project_commit_path(@project.namespace, @project, @commit.id))
= revert_commit_link(namespace_project_commit_path(@project.namespace, @project, @commit.id))
%div
%p

View file

@ -7,7 +7,7 @@
by #{link_to_member(@project, @merge_request.merge_event.author, avatar: true)}
#{time_ago_with_tooltip(@merge_request.merge_event.created_at)}
- if @merge_request.merge_commit_sha.present?
= revert_commit_link(can_update_merge_request?, namespace_project_merge_request_path(@project.namespace, @project, @merge_request), btn_class: 'sm')
= revert_commit_link(namespace_project_merge_request_path(@project.namespace, @project, @merge_request), btn_class: 'sm')
%div
- if !@merge_request.source_branch_exists? || (params[:delete_source] == 'true')
The changes were merged into