Commit a967f1229bbbf0187d7ec1ebf289e1c75684c599

Authored by Dmitriy Zaporozhets
2 parents ee0e9830 cc505f55

Merge pull request #5484 from jojosch/edit-file-on-commit-disable

Check if a file is editied "on" a branch or a commit.
app/controllers/projects/edit_tree_controller.rb
@@ -45,5 +45,9 @@ class Projects::EditTreeController < Projects::ApplicationController @@ -45,5 +45,9 @@ class Projects::EditTreeController < Projects::ApplicationController
45 end 45 end
46 46
47 return access_denied! unless allowed 47 return access_denied! unless allowed
  48 +
  49 + unless @repository.branch_names.include?(@ref)
  50 + redirect_to project_blob_path(@project, @id), notice: "You can only edit this file if you are on top of a branch"
  51 + end
48 end 52 end
49 end 53 end
app/views/projects/blob/_actions.html.haml
1 .btn-group.tree-btn-group 1 .btn-group.tree-btn-group
2 -# only show edit link for text files 2 -# only show edit link for text files
3 - if @blob.text? 3 - if @blob.text?
4 - = link_to "edit", project_edit_tree_path(@project, @id), class: "btn btn-small", disabled: !allowed_tree_edit? 4 + - if allowed_tree_edit?
  5 + = link_to "edit", project_edit_tree_path(@project, @id), class: "btn btn-small"
  6 + - else
  7 + %span.btn.btn-small.disabled Edit
5 = link_to "raw", project_raw_path(@project, @id), class: "btn btn-small", target: "_blank" 8 = link_to "raw", project_raw_path(@project, @id), class: "btn btn-small", target: "_blank"
6 -# only show normal/blame view links for text files 9 -# only show normal/blame view links for text files
7 - if @blob.text? 10 - if @blob.text?