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 45 end
46 46  
47 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 52 end
49 53 end
... ...
app/views/projects/blob/_actions.html.haml
1 1 .btn-group.tree-btn-group
2 2 -# only show edit link for text files
3 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 8 = link_to "raw", project_raw_path(@project, @id), class: "btn btn-small", target: "_blank"
6 9 -# only show normal/blame view links for text files
7 10 - if @blob.text?
... ...