%li.header-new.dropdown
  = link_to new_project_path, class: "header-new-dropdown-toggle has-tooltip", title: "New...", ref: 'tooltip', aria: { label: "New..." }, data: { toggle: 'dropdown', placement: 'bottom', container: 'body' } do
    = icon('plus fw')
    = icon('caret-down')
  .dropdown-menu-nav.dropdown-menu-align-right
    %ul
      - create_group_project = can?(current_user, :create_projects, @group)
      - create_group_subgroup = can?(current_user, :create_subgroup, @group)
      - if @group && (create_group_project || create_group_subgroup)
        %li
          .bold This group
        - if create_group_project
          %li
            = link_to 'New project', new_project_path(namespace_id: @group.id)
        - if create_group_subgroup
          %li
            = link_to 'New subgroup', new_group_path(parent_id: @group.id)

      - if @project
        %li
          .bold This project
        %li
          = link_to 'New issue', new_namespace_project_issue_path(@project.namespace, @project)
        - merge_project = can?(current_user, :create_merge_request, @project) ? @project : (current_user && current_user.fork_of(@project))
        - if merge_project
          %li
            = link_to 'New merge request', new_namespace_project_merge_request_path(merge_project.namespace, merge_project)
        - if can?(current_user, :create_project_snippet, @project)
          %li
            = link_to 'New snippet', new_namespace_project_snippet_path(@project.namespace, @project)
      - if @group || @project
        %li.divider
        %li
          .bold GitLab
      - if current_user.can_create_project?
        %li
          = link_to 'New project', new_project_path
      - if current_user.can_create_group?
        %li
          = link_to 'New group', new_group_path
      %li
        = link_to 'New snippet', new_snippet_path