Commit e39f0de8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add edit button to MergeRequest diff

It will redirect you to file edit page.
After submit changes you will be redirected back to merge request.
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 138e2a50
......@@ -27,10 +27,14 @@
line-height: 2;
}
.view-file {
font-weight: bold;
.diff-btn-group {
float: right;
.btn {
background-color: #EEE;
color: #666;
font-weight: bolder;
}
}
.commit-short-id {
......
......@@ -12,7 +12,16 @@ class Projects::EditTreeController < Projects::BaseTreeController
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
# If blob edit was initiated from merge request page
from_merge_request = MergeRequest.find_by(id: params[:from_merge_request_id])
if from_merge_request
from_merge_request.reload_code
redirect_to diffs_project_merge_request_path(from_merge_request.target_project, from_merge_request)
else
redirect_to project_blob_path(@project, @id)
end
else
flash[:alert] = result[:error]
render :show
......
......@@ -49,6 +49,7 @@
- if diff.deleted_file
%span= diff.old_path
.diff-btn-group
- if @commit.parent_ids.present?
= link_to project_blob_path(project, tree_join(@commit.parent_id, diff.new_path)), { class: 'btn btn-small view-file' } do
View file @
......@@ -58,10 +59,17 @@
- if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode
%span.file-mode= "#{diff.a_mode}#{diff.b_mode}"
.diff-btn-group
- if @merge_request && @merge_request.source_project
= link_to project_edit_tree_path(@merge_request.source_project, tree_join(@merge_request.source_branch, diff.new_path), from_merge_request_id: @merge_request.id), { class: 'btn btn-small' } do
Edit
&nbsp;
= link_to project_blob_path(project, tree_join(@commit.id, diff.new_path)), { class: 'btn btn-small view-file' } do
View file @
%span.commit-short-id= @commit.short_id(6)
.content
-# Skipp all non non-supported blobs
- next unless file.respond_to?('text?')
......
......@@ -23,6 +23,7 @@
.form-actions
= hidden_field_tag 'last_commit', @last_commit
= hidden_field_tag 'content', '', id: "file-content"
= hidden_field_tag 'from_merge_request_id', params[:from_merge_request_id]
.commit-button-annotation
= button_tag "Commit changes", class: 'btn commit-btn js-commit-button btn-primary'
.message
......
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