summaryrefslogtreecommitdiff
path: root/app/views/layouts/_search.html.haml
blob: 245b9c3b4d447a735cb3074f7a44cb9817787c5f (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
- if controller.controller_path =~ /^groups/ && @group.persisted?
  - label = 'This group'
- if controller.controller_path =~ /^projects/ && @project.persisted?
  - label = 'This project'

.search.search-form{class: "#{'has-location-badge' if label.present?}"}
  = form_tag search_path, method: :get, class: 'navbar-form' do |f|
    .search-input-container
      - if label.present?
        .location-badge= label
      .search-input-wrap
        .dropdown{ data: {url: search_autocomplete_path } }
          = search_field_tag "search", nil, placeholder: 'Search', class: "search-input dropdown-menu-toggle", spellcheck: false, tabindex: "1", autocomplete: 'off',  data: { toggle: 'dropdown' }
          .dropdown-menu.dropdown-select
            = dropdown_content do
              %ul
                %li
                  %a.is-focused.dropdown-menu-empty-link
                    Loading...
            = dropdown_loading
          %i.search-icon
          %i.clear-icon.js-clear-input

    = hidden_field_tag :group_id, @group.try(:id)
    = hidden_field_tag :project_id, @project && @project.persisted? ? @project.id : '', id: 'search_project_id'

    - 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

      :javascript
        gl.projectOptions = gl.projectOptions || {};
        gl.projectOptions["#{j(@project.path)}"] = {
          issuesPath: "#{namespace_project_issues_path(@project.namespace, @project)}",
          mrPath: "#{namespace_project_merge_requests_path(@project.namespace, @project)}",
          name: "#{j(@project.name)}"
        };

    - if @group and @group.path
      :javascript
        gl.groupOptions = gl.groupOptions || {};
        gl.groupOptions["#{j(@group.path)}"] = {
          name: "#{j(@group.name)}",
          issuesPath: "#{issues_group_path(j(@group.path))}",
          mrPath: "#{merge_requests_group_path(j(@group.path))}"
        };


    :javascript
      gl.dashboardOptions = {
        issuesPath: "#{issues_dashboard_url}",
        mrPath: "#{merge_requests_dashboard_url}"
      };


    - 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 }