Welcome to mirror list, hosted at ThFree Co, Russian Federation.

top_nav_menu_item.rb « nav « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a83cdbe15df3bed8fc37d5e07a1f456319a43939 (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
# frozen_string_literal: true

module Gitlab
  module Nav
    class TopNavMenuItem
      # 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
      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 || { qa_selector: 'menu_item_link', qa_title: title },
          partial: partial,
          component: component
        }
      end
      # rubocop: enable Metrics/ParameterLists
    end
  end
end