summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-01-21 22:46:49 +0100
committerDouwe Maan <douwe@selenight.nl>2016-01-21 22:46:49 +0100
commit9369b7ec1f98f8e94a0483e4fbb8c36c2333d60b (patch)
treebf73f8507ded979b7d7ba60c78c10e2d54628056
parent3f7993b5ceb9c5ba616dffef39f9b535482d92c1 (diff)
downloadgitlab-ce-fix-mr-diff-edit-button.tar.gz
Fix MR diff 'Edit' buttonfix-mr-diff-edit-button
-rw-r--r--app/controllers/concerns/creates_commit.rb2
-rw-r--r--app/helpers/blob_helper.rb12
-rw-r--r--app/helpers/commits_helper.rb2
-rw-r--r--app/views/projects/diffs/_file.html.haml40
4 files changed, 27 insertions, 29 deletions
diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb
index 62127a09081..b9eb0a22f88 100644
--- a/app/controllers/concerns/creates_commit.rb
+++ b/app/controllers/concerns/creates_commit.rb
@@ -97,7 +97,7 @@ module CreatesCommit
# Merge request from fork to this project
@mr_source_project = @tree_edit_project
@mr_target_project = @project
- @mr_target_branch = @mr_target_project.repository.root_ref
+ @mr_target_branch = @ref
end
end
end
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 7c55934edda..8b689b29a41 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -26,10 +26,10 @@ module BlobHelper
tree_join(ref, path),
link_opts)
- if !on_top_of_branch?
+ if !on_top_of_branch?(project, ref)
button_tag "Edit", class: "btn btn-default disabled has_tooltip", title: "You can only edit files when you are on a branch", data: { container: 'body' }
- elsif can_edit_blob?(blob)
- link_to "Edit", edit_path, class: 'btn btn-small'
+ elsif can_edit_blob?(blob, project, ref)
+ link_to "Edit", edit_path, class: 'btn'
elsif can?(current_user, :fork_project, project)
continue_params = {
to: edit_path,
@@ -39,7 +39,7 @@ module BlobHelper
fork_path = namespace_project_fork_path(project.namespace, project, namespace_key: current_user.namespace.id,
continue: continue_params)
- link_to "Edit", fork_path, class: 'btn btn-small', method: :post
+ link_to "Edit", fork_path, class: 'btn', method: :post
end
end
@@ -50,11 +50,11 @@ module BlobHelper
return unless blob
- if !on_top_of_branch?
+ if !on_top_of_branch?(project, ref)
button_tag label, class: "btn btn-#{btn_class} disabled has_tooltip", title: "You can only #{action} files when you are on a branch", data: { container: 'body' }
elsif blob.lfs_pointer?
button_tag label, class: "btn btn-#{btn_class} disabled has_tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: { container: 'body' }
- elsif can_edit_blob?(blob)
+ elsif can_edit_blob?(blob, project, ref)
button_tag label, class: "btn btn-#{btn_class}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal'
elsif can?(current_user, :fork_project, project)
continue_params = {
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index 590d20ac7b3..d26f007c8e6 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -166,7 +166,7 @@ module CommitsHelper
link_to(
namespace_project_blob_path(project.namespace, project,
tree_join(commit_sha, diff.new_path)),
- class: 'btn btn-small view-file js-view-file'
+ class: 'btn view-file js-view-file'
) do
raw('View file @') + content_tag(:span, commit_sha[0..6],
class: 'commit-short-id')
diff --git a/app/views/projects/diffs/_file.html.haml b/app/views/projects/diffs/_file.html.haml
index 517f6aef7c5..fc0eaef2286 100644
--- a/app/views/projects/diffs/_file.html.haml
+++ b/app/views/projects/diffs/_file.html.haml
@@ -1,39 +1,37 @@
-.diff-file{id: "diff-#{i}", data: diff_file_html_data(project, diff_commit, diff_file)}
- .diff-header{id: "file-path-#{hexdigest(diff_file.file_path)}"}
+.diff-file.file-holder{id: "diff-#{i}", data: diff_file_html_data(project, diff_commit, diff_file)}
+ .file-title{id: "file-path-#{hexdigest(diff_file.file_path)}"}
- if diff_file.diff.submodule?
%span
= icon('archive fw')
%strong
= submodule_link(blob, @commit.id, project.repository)
- else
- %span
- = blob_icon blob.mode, blob.name
- = link_to "#diff-#{i}" do
- %strong
- = diff_file.new_path
+ = blob_icon blob.mode, blob.name
+ = link_to "#diff-#{i}" do
+ %strong
+ = diff_file.new_path
- - if diff_file.deleted_file
- deleted
- - elsif diff_file.renamed_file
- renamed from
- %strong
- = diff_file.old_path
+ - if diff_file.deleted_file
+ deleted
+ - elsif diff_file.renamed_file
+ renamed from
+ %strong
+ = diff_file.old_path
- - if diff_file.mode_changed?
- %small
- = "#{diff_file.diff.a_mode} → #{diff_file.diff.b_mode}"
+ - if diff_file.mode_changed?
+ %small
+ = "#{diff_file.diff.a_mode} → #{diff_file.diff.b_mode}"
- .diff-controls
+ .file-actions.hidden-xs
- if blob_text_viewable?(blob)
- = link_to '#', class: 'js-toggle-diff-comments btn btn-sm active has_tooltip', title: "Toggle comments for this file" do
- %i.fa.fa-comments
- &nbsp;
+ = link_to '#', class: 'js-toggle-diff-comments btn active has_tooltip', title: "Toggle comments for this file" do
+ = icon('comments')
+ \
- if editable_diff?(diff_file)
= edit_blob_link(@merge_request.source_project,
@merge_request.source_branch, diff_file.new_path,
from_merge_request_id: @merge_request.id)
- &nbsp;
= view_file_btn(diff_commit.id, diff_file, project)