summaryrefslogtreecommitdiff
path: root/app/views/projects/buttons/_dropdown.html.haml
blob: 12ce4667e1aaf2b9ea6d5a9b573bd11793acdeef (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
- can_create_issue = show_new_issue_link?(@project)
- can_create_project_snippet = can?(current_user, :create_snippet, @project)
- can_push_code = can?(current_user, :push_code, @project)
- create_mr_from_new_fork = can?(current_user, :fork_project, @project) && can?(current_user, :create_merge_request_in, @project)
- merge_project = merge_request_source_project_for_project(@project)

- show_menu = can_create_issue || can_create_project_snippet || can_push_code || create_mr_from_new_fork || merge_project

- if show_menu
  .project-action-button.dropdown.inline<
    %a.btn.btn-default.gl-button.dropdown-toggle.has-tooltip.qa-create-new-dropdown{ href: '#', title: _('Create new...'), 'data-toggle' => 'dropdown', 'data-container' => 'body', 'aria-label' => _('Create new...'), 'data-display' => 'static' }
      = sprite_icon('plus', css_class: 'gl-icon')
      = sprite_icon("chevron-down", css_class: 'gl-icon')
    %ul.dropdown-menu.dropdown-menu-right.project-home-dropdown
      - if can_create_issue || merge_project || can_create_project_snippet
        %li.dropdown-header= _('This project')

      - if can_create_issue
        %li= link_to _('New issue'), new_project_issue_path(@project)

      - if merge_project
        %li= link_to _('New merge request'), project_new_merge_request_path(merge_project)

      - if can_create_project_snippet
        %li= link_to _('New snippet'), new_project_snippet_path(@project)

      - if can_push_code
        %li.dropdown-header= _('This repository')

      - if can_push_code
        %li.qa-new-file-option= link_to _('New file'), project_new_blob_path(@project, @project.default_branch_or_main)
        - unless @project.empty_repo?
          %li= link_to _('New branch'), new_project_branch_path(@project)
          %li= link_to _('New tag'), new_project_tag_path(@project)
      - elsif can_collaborate_with_project?(@project)
        %li= link_to _('New file'), project_new_blob_path(@project, @project.default_branch_or_main)
      - elsif create_mr_from_new_fork
        - continue_params = { to: project_new_blob_path(@project, @project.default_branch_or_main),
                              notice: edit_in_new_fork_notice,
                              notice_now: edit_in_new_fork_notice_now }
        - fork_path = project_forks_path(@project, namespace_key: current_user.namespace.id, continue: continue_params)
        %li= link_to _('New file'), fork_path, method: :post