2021-05-05 23:10:25 -04:00
|
|
|
# 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
|
2021-06-11 14:10:13 -04:00
|
|
|
def self.build(id:, title:, active: false, icon: '', href: '', view: '', css_class: nil, data: nil, emoji: nil)
|
2021-05-05 23:10:25 -04:00
|
|
|
{
|
|
|
|
id: id,
|
|
|
|
title: title,
|
|
|
|
active: active,
|
|
|
|
icon: icon,
|
|
|
|
href: href,
|
|
|
|
view: view.to_s,
|
|
|
|
css_class: css_class,
|
2021-06-11 14:10:13 -04:00
|
|
|
data: data || { qa_selector: 'menu_item_link', qa_title: title },
|
2021-06-03 14:09:58 -04:00
|
|
|
emoji: emoji
|
2021-05-05 23:10:25 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
# rubocop: enable Metrics/ParameterLists
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|