summaryrefslogtreecommitdiff
path: root/app/helpers/tree_helper.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-12-08 17:10:07 +0100
committerDouwe Maan <douwe@gitlab.com>2015-12-08 17:10:07 +0100
commit82ddd738b672afd4ed28f12fb58f512fa117d2be (patch)
tree2630ea3648b68058293a6d3f91d753a45fd1a6bb /app/helpers/tree_helper.rb
parentdf6750d3d6b562c8a6a0a57c12dfd694da38a0e8 (diff)
downloadgitlab-ce-82ddd738b672afd4ed28f12fb58f512fa117d2be.tar.gz
Show tooltip when trying to edit file when not on branch
Diffstat (limited to 'app/helpers/tree_helper.rb')
-rw-r--r--app/helpers/tree_helper.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index ac75c9a14b7..886a1e734b5 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -46,13 +46,20 @@ module TreeHelper
File.join(*args)
end
+ def on_top_of_branch?(project = @project, ref = @ref)
+ project.repository.branch_names.include?(ref)
+ end
+
def allowed_tree_edit?(project = nil, ref = nil)
project ||= @project
+ ref ||= @ref
+ return false unless on_top_of_branch?(project, ref)
+
can?(current_user, :push_code, project)
end
def tree_edit_branch(project = @project, ref = @ref)
- if allowed_tree_edit?
+ if allowed_tree_edit?(project, ref)
if can_push_branch?(project, ref)
ref
else
@@ -61,10 +68,6 @@ module TreeHelper
end
end
- def can_delete_or_replace?(blob)
- allowed_tree_edit? && !blob.lfs_pointer?
- end
-
def tree_breadcrumbs(tree, max_links = 2)
if @path.present?
part_path = ""