summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--app/assets/stylesheets/sections/commits.scss10
-rw-r--r--app/controllers/projects/edit_tree_controller.rb11
-rw-r--r--app/views/projects/commits/_diffs.html.haml22
-rw-r--r--app/views/projects/edit_tree/show.html.haml1
5 files changed, 34 insertions, 11 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 7d03d6a6135..51f9523da73 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,6 @@
v 6.7.0
- Add support for Gemnasium as a Project Service
+ - Add edit file button to MergeRequest diff
v 6.6.0
- Retrieving user ssh keys publically(github style): http://__HOST__/__USERNAME__.keys
diff --git a/app/assets/stylesheets/sections/commits.scss b/app/assets/stylesheets/sections/commits.scss
index 158db38549f..89054cb5b52 100644
--- a/app/assets/stylesheets/sections/commits.scss
+++ b/app/assets/stylesheets/sections/commits.scss
@@ -27,10 +27,14 @@
line-height: 2;
}
- .view-file {
- font-weight: bold;
+ .diff-btn-group {
float: right;
- background-color: #EEE;
+
+ .btn {
+ background-color: #EEE;
+ color: #666;
+ font-weight: bolder;
+ }
}
.commit-short-id {
diff --git a/app/controllers/projects/edit_tree_controller.rb b/app/controllers/projects/edit_tree_controller.rb
index 6bd1a455f32..c54b757d13c 100644
--- a/app/controllers/projects/edit_tree_controller.rb
+++ b/app/controllers/projects/edit_tree_controller.rb
@@ -12,7 +12,16 @@ class Projects::EditTreeController < Projects::BaseTreeController
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
- redirect_to project_blob_path(@project, @id)
+
+ # 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
diff --git a/app/views/projects/commits/_diffs.html.haml b/app/views/projects/commits/_diffs.html.haml
index a41a89bb972..0fd04f32ba8 100644
--- a/app/views/projects/commits/_diffs.html.haml
+++ b/app/views/projects/commits/_diffs.html.haml
@@ -49,18 +49,26 @@
- if diff.deleted_file
%span= diff.old_path
- - 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 @
- %span.commit-short-id= @commit.short_id(6)
+ .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 @
+ %span.commit-short-id= @commit.short_id(6)
- else
%span= diff.new_path
- if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode
%span.file-mode= "#{diff.a_mode} → #{diff.b_mode}"
- = 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)
+ .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
diff --git a/app/views/projects/edit_tree/show.html.haml b/app/views/projects/edit_tree/show.html.haml
index 433131640a1..96c00ab3661 100644
--- a/app/views/projects/edit_tree/show.html.haml
+++ b/app/views/projects/edit_tree/show.html.haml
@@ -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