summaryrefslogtreecommitdiff
path: root/app/views/projects/new_tree/show.html.haml
blob: 4ce8d372a38b776461a7e64dae0be819e60024bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
%h3.page-title New file
%hr
.file-editor
  = form_tag(project_new_tree_path(@project, @id), method: :put, class: 'form-horizontal form-new-file') do
    .form-group.commit_message-group
      = label_tag 'file_name', class: 'control-label' do
        File name
      .col-sm-10
        .input-group
          %span.input-group-addon
            = @path[-1] == "/" ? @path : @path + "/"
          = text_field_tag 'file_name', params[:file_name], placeholder: "sample.rb", required: true, class: 'form-control'
          %span.input-group-addon
            on
            %span= @ref

    .form-group.commit_message-group
      = label_tag :encoding, class: "control-label" do
        Encoding
      .col-sm-10
        = select_tag :encoding, options_for_select([ "base64", "text" ], "text"), class: 'form-control'

    .form-group.commit_message-group
      = label_tag 'commit_message', class: "control-label" do
        Commit message
      .col-sm-10
        = render 'shared/commit_message_container', {textarea: text_area_tag('commit_message',
            params[:commit_message], placeholder: "Added new file", required: true, rows: 3, class: 'form-control')}

    .file-holder
      .file-title
        %i.icon-file
      .file-content.code
        %pre#editor= params[:content]

    .form-actions
      = hidden_field_tag 'content', '', id: "file-content"
      .commit-button-annotation
        = button_tag "Commit changes", class: 'btn commit-btn js-commit-button btn-create'
        .message
          to branch
          %strong= @ref
      = link_to "Cancel", project_tree_path(@project, @id), class: "btn btn-cancel", data: { confirm: leave_edit_message}

:javascript
  ace.config.set("modePath", gon.relative_url_root + "#{Gitlab::Application.config.assets.prefix}/ace-src-noconflict")
  var editor = ace.edit("editor");

  disableButtonIfAnyEmptyField($('.form-new-file'), '.form-control', '.btn-create')

  $(".js-commit-button").click(function(){
    $("#file-content").val(editor.getValue());
    $(".file-editor form").submit();
  });