_tree_header.html.haml 3.55 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
.tree-ref-holder
  = render 'shared/ref_switcher', destination: 'tree', path: @path

%ul.breadcrumb.repo-breadcrumb
  %li
    = link_to namespace_project_tree_path(@project.namespace, @project, @ref) do
      = @project.path
  - tree_breadcrumbs(tree, 6) do |title, path|
    %li
      - if path
        = link_to truncate(title, length: 40), namespace_project_tree_path(@project.namespace, @project, path)
      - else
        = link_to title, '#'
14 15

  - if current_user
16
    %li
17 18
      - if !on_top_of_branch?
        %span.btn.btn-sm.add-to-tree.disabled.has_tooltip{title: "You can only add files when you are on a branch", data: {container: 'body'}}
19
          = icon('plus')
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
      - elsif can_edit_tree?
        %span.dropdown
          %a.dropdown-toggle.btn.btn-sm.add-to-tree{href: '#', "data-toggle" => "dropdown"}
            = icon('plus')
          %ul.dropdown-menu
            %li
              = link_to namespace_project_new_blob_path(@project.namespace, @project, @id) do
                = icon('pencil fw')
                Create file
            %li
              = link_to '#modal-upload-blob', { 'data-target' => '#modal-upload-blob', 'data-toggle' => 'modal'} do
                = icon('file fw')
                Upload file
            %li.divider
            %li
              = link_to '#modal-create-new-dir', { 'data-target' => '#modal-create-new-dir', 'data-toggle' => 'modal'} do
                = icon('folder fw')
                New directory
      - elsif can?(current_user, :fork_project, @project)
        %span.dropdown
          %a.dropdown-toggle.btn.btn-sm.add-to-tree{href: '#', "data-toggle" => "dropdown"}
            = icon('plus')
          %ul.dropdown-menu
            %li
              - continue_params = { to:         namespace_project_new_blob_path(@project.namespace, @project, @id),
                                    notice:     edit_in_new_fork_notice,
                                    notice_now: edit_in_new_fork_notice_now }
              - fork_path = namespace_project_fork_path(@project.namespace, @project, namespace_key:  current_user.namespace.id,
                                                                                      continue:       continue_params)
              = link_to fork_path, method: :post do
                = icon('pencil fw')
                Create file
            %li
              - continue_params = { to:         request.fullpath,
                                    notice:     edit_in_new_fork_notice + " Try to upload a file again.",
                                    notice_now: edit_in_new_fork_notice_now }
              - fork_path = namespace_project_fork_path(@project.namespace, @project, namespace_key:  current_user.namespace.id,
                                                                                      continue:       continue_params)
              = link_to fork_path, method: :post do
                = icon('file fw')
                Upload file
            %li.divider
            %li
              - continue_params = { to:         request.fullpath,
                                    notice:     edit_in_new_fork_notice + " Try to create a new directory again.",
                                    notice_now: edit_in_new_fork_notice_now }
              - fork_path = namespace_project_fork_path(@project.namespace, @project, namespace_key:  current_user.namespace.id,
                                                                                      continue:       continue_params)
              = link_to fork_path, method: :post do
                = icon('folder fw')
                New directory