Commit a967f1229bbbf0187d7ec1ebf289e1c75684c599
Exists in
master
and in
4 other branches
Merge pull request #5484 from jojosch/edit-file-on-commit-disable
Check if a file is editied "on" a branch or a commit.
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
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? | ... | ... |