summaryrefslogtreecommitdiff
path: root/app/views/layouts/_search.html.haml
blob: 496ec3c78b05c6ac922024e87fb9f10d08a83558 (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
- if @group && @group.persisted? && @group.path
  - group_data_attrs = { group_path: j(@group.path), name: @group.name, issues_path: issues_group_path(j(@group.path)), mr_path: merge_requests_group_path(j(@group.path)) }
- if @project && @project.persisted?
  - project_data_attrs = { project_path: j(@project.path), name: j(@project.name), issues_path: project_issues_path(@project), mr_path: project_merge_requests_path(@project), issues_disabled: !@project.issues_enabled? }
.search.search-form{ data: { track_label: "navbar_search", track_event: "activate_form_input" } }
  = form_tag search_path, method: :get, class: 'form-inline' do |f|
    .search-input-container
      .search-input-wrap
        .dropdown{ data: { url: search_autocomplete_path } }
          = search_field_tag 'search', nil, placeholder: _('Search or jump to…'),
                                            class: 'search-input dropdown-menu-toggle no-outline js-search-dashboard-options',
                                            spellcheck: false,
                                            tabindex: '1',
                                            autocomplete: 'off',
                                            data: { issues_path: issues_dashboard_path,
                                              mr_path: merge_requests_dashboard_path },
                                            aria: { label: _('Search or jump to…') }
          %button.hidden.js-dropdown-search-toggle{ type: 'button', data: { toggle: 'dropdown' } }
          .dropdown-menu.dropdown-select.js-dashboard-search-options
            = dropdown_content do
              %ul
                %li.dropdown-menu-empty-item
                  %a
                    = _('Loading...')
            = dropdown_loading
          = sprite_icon('search', size: 16, css_class: 'search-icon')
          = sprite_icon('close', size: 16, css_class: 'clear-icon js-clear-input')

    = hidden_field_tag :group_id, @group.try(:id), class: 'js-search-group-options', data: group_data_attrs

    = hidden_field_tag :project_id, @project && @project.persisted? ? @project.id : '', id: 'search_project_id', class: 'js-search-project-options', data: project_data_attrs

    - if @project && @project.persisted?
      - if current_controller?(:issues)
        = hidden_field_tag :scope, 'issues'
      - elsif current_controller?(:merge_requests)
        = hidden_field_tag :scope, 'merge_requests'
      - elsif current_controller?(:wikis)
        = hidden_field_tag :scope, 'wiki_blobs'
      - elsif current_controller?(:commits)
        = hidden_field_tag :scope, 'commits'
      - else
        = hidden_field_tag :search_code, true

    - if @snippet || @snippets
      = hidden_field_tag :snippets, true
    = hidden_field_tag :repository_ref, @ref
    = button_tag 'Go' if ENV['RAILS_ENV'] == 'test'
    .search-autocomplete-opts.hide{ :'data-autocomplete-path' => search_autocomplete_path, :'data-autocomplete-project-id' => @project.try(:id), :'data-autocomplete-project-ref' => @ref }