BigW Consortium Gitlab

_search.html.haml 2.67 KB
Newer Older
1
- if controller.controller_path =~ /^groups/ && @group.persisted?
2
  - label = 'This group'
3
- if controller.controller_path =~ /^projects/ && @project.persisted?
4
  - label = 'This project'
5
- if @group && @group.persisted? && @group.path
6
  - 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)) }
7
- if @project && @project.persisted?
8
  - project_data_attrs = { project_path: j(@project.path), name: j(@project.name), issues_path: namespace_project_issues_path(@project.namespace, @project), mr_path: namespace_project_merge_requests_path(@project.namespace, @project) }
9
.search.search-form{ class: "#{'has-location-badge' if label.present?}" }
10 11
  = form_tag search_path, method: :get, class: 'navbar-form' do |f|
    .search-input-container
12 13
      - if label.present?
        .location-badge= label
14
      .search-input-wrap
15
        .dropdown{ data: { url: search_autocomplete_path } }
16
          = search_field_tag 'search', nil, placeholder: 'Search', class: 'search-input dropdown-menu-toggle no-outline js-search-dashboard-options', spellcheck: false, tabindex: '1', autocomplete: 'off', data: { toggle: 'dropdown', issues_path: issues_dashboard_url, mr_path: merge_requests_dashboard_url }, aria: { label: 'Search' }
17
          .dropdown-menu.dropdown-select
18
            = dropdown_content do
19 20 21 22
              %ul
                %li
                  %a.is-focused.dropdown-menu-empty-link
                    Loading...
23
            = dropdown_loading
24 25
          %i.search-icon
          %i.clear-icon.js-clear-input
26

27 28 29
    = 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
30 31

    - if @project && @project.persisted?
32 33 34 35 36 37
      - 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'
38 39
      - elsif current_controller?(:commits)
        = hidden_field_tag :scope, 'commits'
40 41 42
      - else
        = hidden_field_tag :search_code, true

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