From 3a3b0da81e2320be890ddb9c00a055ea4c6a305b Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Fri, 3 Oct 2014 12:56:48 +0200 Subject: [PATCH] Make blob new and edit file editors more uniform --- app/views/projects/_blob_editor.html.haml | 15 +++++++++++++++ app/views/projects/edit_tree/show.html.haml | 17 +---------------- app/views/projects/new_tree/show.html.haml | 7 +------ 3 files changed, 17 insertions(+), 22 deletions(-) create mode 100644 app/views/projects/_blob_editor.html.haml diff --git a/app/views/projects/_blob_editor.html.haml b/app/views/projects/_blob_editor.html.haml new file mode 100644 index 00000000000..1fb74b55c41 --- /dev/null +++ b/app/views/projects/_blob_editor.html.haml @@ -0,0 +1,15 @@ +.file-holder.file + .file-title + %i.icon-file + %span.file_name + %span.monospace.light #{ref} + - if local_assigns[:path] + = ': ' + local_assigns[:path] + .file-content.code + %pre.js-edit-mode-pane#editor + = params[:content] || local_assigns[:blob_data] + - if local_assigns[:path] + .js-edit-mode-pane#preview.hide + .center + %h2 + %i.icon-spinner.icon-spin diff --git a/app/views/projects/edit_tree/show.html.haml b/app/views/projects/edit_tree/show.html.haml index 5ccde05063e..7e0789853af 100644 --- a/app/views/projects/edit_tree/show.html.haml +++ b/app/views/projects/edit_tree/show.html.haml @@ -6,21 +6,7 @@ = link_to editing_preview_title(@blob.name), '#preview', 'data-preview-url' => preview_project_edit_tree_path(@project, @id) = form_tag(project_edit_tree_path(@project, @id), method: :put, class: "form-horizontal") do - .file-holder.file - .file-title - %i.fa.fa-file - %span.file_name - %span.monospace.light #{@ref}: - = @path - %span.options - .btn-group.tree-btn-group - = link_to "Cancel", @after_edit_path, class: "btn btn-tiny btn-cancel", data: { confirm: leave_edit_message } - .file-content.code - %pre.js-edit-mode-pane#editor - .js-edit-mode-pane#preview.hide - .center - %h2 - %i.fa.fa-spinner.fa-spin + = render 'projects/blob_editor', ref: @ref, path: @path, blob_data: @blob.data = render 'shared/commit_message_container', params: params, placeholder: "Update #{@blob.name}" = hidden_field_tag 'last_commit', @last_commit @@ -34,7 +20,6 @@ ace.config.loadModule("ace/ext/searchbox"); var ace_mode = "#{@blob.language.try(:ace_mode)}"; var editor = ace.edit("editor"); - editor.setValue("#{escape_javascript(@blob.data)}"); if (ace_mode) { editor.getSession().setMode('ace/mode/' + ace_mode); } diff --git a/app/views/projects/new_tree/show.html.haml b/app/views/projects/new_tree/show.html.haml index f09d3659774..cf7b768694f 100644 --- a/app/views/projects/new_tree/show.html.haml +++ b/app/views/projects/new_tree/show.html.haml @@ -19,12 +19,7 @@ Encoding .col-sm-10 = select_tag :encoding, options_for_select([ "base64", "text" ], "text"), class: 'form-control' - .file-holder - .file-title - %i.fa.fa-file - .file-content.code - %pre#editor= params[:content] - + = render 'projects/blob_editor', ref: @ref = render 'shared/commit_message_container', params: params, placeholder: 'Add new file' = hidden_field_tag 'content', '', id: 'file-content' -- GitLab