WebEditor: base implementation
This commit is contained in:
parent
0b3e9fd218
commit
42bdfd021b
4 changed files with 55 additions and 10 deletions
|
@ -26,8 +26,14 @@ class TreeController < ProjectResourceController
|
|||
|
||||
def update
|
||||
file_editor = Gitlab::FileEditor.new(current_user, @project, @ref)
|
||||
if file_editor.can_edit?(@path, params[:last_commit])
|
||||
file_editor.update(@path, params[:content])
|
||||
update_status = file_editor.update(
|
||||
@path,
|
||||
params[:content],
|
||||
params[:commit_message],
|
||||
params[:last_commit]
|
||||
)
|
||||
|
||||
if update_status
|
||||
redirect_to project_tree_path(@project, @id), :notice => "File has been successfully changed"
|
||||
else
|
||||
flash[:notice] = "You can't save file because it has been changed"
|
||||
|
|
|
@ -13,10 +13,15 @@
|
|||
= text_area_tag 'commit_message'
|
||||
.form-actions
|
||||
= hidden_field_tag 'last_commit', @last_commit
|
||||
= hidden_field_tag 'content'
|
||||
= submit_tag "Save", class: 'btn save-btn'
|
||||
= hidden_field_tag 'content', '', :id => :file_content
|
||||
= button_tag "Save", class: 'btn save-btn'
|
||||
|
||||
:javascript
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
|
||||
$(".save-btn").click(function(){
|
||||
$("#file_content").val(editor.getValue());
|
||||
$(".form_editor form").submit();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue