Class: Gitlab::Nav::TopNavMenuItem

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/nav/top_nav_menu_item.rb

Class Method Summary collapse

Class Method Details

.build(id:, title:, active: false, icon: '', href: '', view: '', css_class: nil, data: nil, partial: nil, component: nil) ⇒ Object

We want to have all keyword arguments for type safety. Ordinarily we could introduce a params object, but that’s kind of what this is already :/. We could also take a hash and manually check every entry, but it’s much more maintainable to do rely on native Ruby. rubocop: disable Metrics/ParameterLists



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/nav/top_nav_menu_item.rb', line 11

def self.build(
  id:, title:, active: false, icon: '', href: '', view: '',
  css_class: nil, data: nil, partial: nil, component: nil
)
  {
    id: id,
    type: :item,
    title: title,
    active: active,
    icon: icon,
    href: href,
    view: view.to_s,
    css_class: css_class,
    data: data || { testid: 'menu_item_link', qa_title: title },
    partial: partial,
    component: component
  }
end