2021-06-08 01:23:25 +05:30
|
|
|
# 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
|
2023-05-27 22:25:52 +05:30
|
|
|
def self.build(
|
|
|
|
id:, title:, active: false, icon: '', href: '', view: '',
|
|
|
|
css_class: nil, data: nil, partial: nil, component: nil
|
|
|
|
)
|
2021-06-08 01:23:25 +05:30
|
|
|
{
|
|
|
|
id: id,
|
2022-10-11 01:57:18 +05:30
|
|
|
type: :item,
|
2021-06-08 01:23:25 +05:30
|
|
|
title: title,
|
|
|
|
active: active,
|
|
|
|
icon: icon,
|
|
|
|
href: href,
|
|
|
|
view: view.to_s,
|
|
|
|
css_class: css_class,
|
2021-09-04 01:27:46 +05:30
|
|
|
data: data || { qa_selector: 'menu_item_link', qa_title: title },
|
2023-05-27 22:25:52 +05:30
|
|
|
partial: partial,
|
|
|
|
component: component
|
2021-06-08 01:23:25 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
# rubocop: enable Metrics/ParameterLists
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|