Commit e53b47b447b1f1ba8185aa07b8c53102c592ead8
1 parent
02c83f12
Exists in
master
and in
4 other branches
WebEditor: sceleton
Showing
3 changed files
with
30 additions
and
2 deletions
Show diff stats
app/controllers/tree_controller.rb
... | ... | @@ -26,5 +26,13 @@ class TreeController < ProjectResourceController |
26 | 26 | |
27 | 27 | def update |
28 | 28 | last_commit = @project.commits(@ref, @path, 1).first.sha |
29 | + file_editor = Gitlab::FileEditor.new(current_user, @project) | |
30 | + if file_editor.can_edit?(@path, last_commit) | |
31 | + file_editor.update(@path, params[:content]) | |
32 | + redirect_to project_tree_path(@project, @id), :notice => "File has been successfully changed" | |
33 | + else | |
34 | + flash[:notice] = "You can't save file because it has been changed" | |
35 | + render :edit | |
36 | + end | |
29 | 37 | end |
30 | 38 | end | ... | ... |
app/views/tree/edit.html.haml
... | ... | @@ -8,9 +8,9 @@ |
8 | 8 | #editor= @tree.data |
9 | 9 | |
10 | 10 | .editor-commit-comment |
11 | - = label_tag 'text-commit' do | |
11 | + = label_tag 'commit_message' do | |
12 | 12 | %p.slead Commit message |
13 | - = text_area_tag 'text_commit' | |
13 | + = text_area_tag 'commit_message' | |
14 | 14 | .form-actions |
15 | 15 | = hidden_field_tag 'last_commit', @last_commit |
16 | 16 | = hidden_field_tag 'content' | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +module Gitlab | |
2 | + class FileEditor | |
3 | + | |
4 | + attr_accessor :user, :project | |
5 | + | |
6 | + def initialize(user, project) | |
7 | + self.user = user | |
8 | + self.project = project | |
9 | + end | |
10 | + | |
11 | + def can_edit?(path, last_commit) | |
12 | + true | |
13 | + end | |
14 | + | |
15 | + def update(path, content) | |
16 | + true | |
17 | + end | |
18 | + | |
19 | + end | |
20 | +end | ... | ... |