Module: Nav::TopNavHelper

Defined in:
app/helpers/nav/top_nav_helper.rb

Constant Summary collapse

PROJECTS_VIEW =
:projects
GROUPS_VIEW =
:groups
NEW_VIEW =
:new
SEARCH_VIEW =
:search

Instance Method Summary collapse

Instance Method Details

#top_nav_responsive_view_model(project:, group:) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/nav/top_nav_helper.rb', line 18

def top_nav_responsive_view_model(project:, group:)
  builder = ::Gitlab::Nav::TopNavViewModelBuilder.new

  build_base_view_model(builder: builder, project: project, group: group)

  new_view_model = new_dropdown_view_model(project: project, group: group)

  if new_view_model && new_view_model.fetch(:menu_sections)&.any?
    builder.add_view(NEW_VIEW, new_view_model)
  end

  if top_nav_show_search
    builder.add_view(SEARCH_VIEW, ::Gitlab::Nav::TopNavMenuItem.build(**top_nav_search_menu_item_attrs))
  end

  builder.build
end

#top_nav_search_menu_item_attrsObject


40
41
42
43
44
45
46
47
# File 'app/helpers/nav/top_nav_helper.rb', line 40

def top_nav_search_menu_item_attrs
  {
    id: 'search',
    title: _('Search'),
    icon: 'search',
    href: search_context.search_url
  }
end

#top_nav_show_searchObject


36
37
38
# File 'app/helpers/nav/top_nav_helper.rb', line 36

def top_nav_show_search
  header_link?(:search)
end

#top_nav_view_model(project:, group:) ⇒ Object


10
11
12
13
14
15
16
# File 'app/helpers/nav/top_nav_helper.rb', line 10

def top_nav_view_model(project:, group:)
  builder = ::Gitlab::Nav::TopNavViewModelBuilder.new

  build_base_view_model(builder: builder, project: project, group: group)

  builder.build
end