Class: Sidebars::MenuItem
- Inherits:
-
Object
- Object
- Sidebars::MenuItem
- Includes:
- Concerns::LinkWithHtmlOptions
- Defined in:
- lib/sidebars/menu_item.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#active_routes ⇒ Object
readonly
Returns the value of attribute active_routes.
-
#avatar ⇒ Object
readonly
Returns the value of attribute avatar.
-
#container_html_options ⇒ Object
readonly
Returns the value of attribute container_html_options.
-
#entity_id ⇒ Object
readonly
Returns the value of attribute entity_id.
-
#has_pill ⇒ Object
(also: #has_pill?)
readonly
Returns the value of attribute has_pill.
-
#hint_html_options ⇒ Object
readonly
Returns the value of attribute hint_html_options.
-
#item_id ⇒ Object
readonly
Returns the value of attribute item_id.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#pill_count ⇒ Object
readonly
Returns the value of attribute pill_count.
-
#sprite_icon ⇒ Object
readonly
Returns the value of attribute sprite_icon.
-
#sprite_icon_html_options ⇒ Object
readonly
Returns the value of attribute sprite_icon_html_options.
-
#super_sidebar_parent ⇒ Object
readonly
Returns the value of attribute super_sidebar_parent.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title:, link:, active_routes:, item_id: nil, container_html_options: {}, sprite_icon: nil, sprite_icon_html_options: {}, hint_html_options: {}, has_pill: false, pill_count: nil, super_sidebar_parent: nil, avatar: nil, entity_id: nil) ⇒ MenuItem
constructor
rubocop: disable Metrics/ParameterLists.
- #nav_link_html_options ⇒ Object
- #render? ⇒ Boolean
- #serialize_for_super_sidebar ⇒ Object
-
#show_hint? ⇒ Boolean
rubocop: enable Metrics/ParameterLists.
Methods included from Concerns::LinkWithHtmlOptions
Constructor Details
#initialize(title:, link:, active_routes:, item_id: nil, container_html_options: {}, sprite_icon: nil, sprite_icon_html_options: {}, hint_html_options: {}, has_pill: false, pill_count: nil, super_sidebar_parent: nil, avatar: nil, entity_id: nil) ⇒ MenuItem
rubocop: disable Metrics/ParameterLists
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sidebars/menu_item.rb', line 11 def initialize(title:, link:, active_routes:, item_id: nil, container_html_options: {}, sprite_icon: nil, sprite_icon_html_options: {}, hint_html_options: {}, has_pill: false, pill_count: nil, super_sidebar_parent: nil, avatar: nil, entity_id: nil) @title = title @link = link @active_routes = active_routes @item_id = item_id @container_html_options = { aria: { label: title } }.merge() @sprite_icon = sprite_icon @sprite_icon_html_options = @avatar = avatar @entity_id = entity_id @hint_html_options = @has_pill = has_pill @pill_count = pill_count @super_sidebar_parent = end |
Instance Attribute Details
#active_routes ⇒ Object (readonly)
Returns the value of attribute active_routes.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def active_routes @active_routes end |
#avatar ⇒ Object (readonly)
Returns the value of attribute avatar.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def avatar @avatar end |
#container_html_options ⇒ Object (readonly)
Returns the value of attribute container_html_options.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def @container_html_options end |
#entity_id ⇒ Object (readonly)
Returns the value of attribute entity_id.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def entity_id @entity_id end |
#has_pill ⇒ Object (readonly) Also known as: has_pill?
Returns the value of attribute has_pill.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def has_pill @has_pill end |
#hint_html_options ⇒ Object (readonly)
Returns the value of attribute hint_html_options.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def @hint_html_options end |
#item_id ⇒ Object (readonly)
Returns the value of attribute item_id.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def item_id @item_id end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def link @link end |
#pill_count ⇒ Object (readonly)
Returns the value of attribute pill_count.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def pill_count @pill_count end |
#sprite_icon ⇒ Object (readonly)
Returns the value of attribute sprite_icon.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def sprite_icon @sprite_icon end |
#sprite_icon_html_options ⇒ Object (readonly)
Returns the value of attribute sprite_icon_html_options.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def @sprite_icon_html_options end |
#super_sidebar_parent ⇒ Object (readonly)
Returns the value of attribute super_sidebar_parent.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def @super_sidebar_parent end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/sidebars/menu_item.rb', line 7 def title @title end |
Instance Method Details
#nav_link_html_options ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/sidebars/menu_item.rb', line 57 def { data: { track_label: item_id } } end |
#render? ⇒ Boolean
32 33 34 |
# File 'lib/sidebars/menu_item.rb', line 32 def render? true end |
#serialize_for_super_sidebar ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sidebars/menu_item.rb', line 36 def { id: item_id, title: title, icon: sprite_icon, avatar: avatar, entity_id: entity_id, link: link, active_routes: active_routes, pill_count: has_pill ? pill_count : nil, link_classes: [:class] # Check whether support is needed for the following properties, # in order to get feature parity with the HAML renderer # https://gitlab.com/gitlab-org/gitlab/-/issues/391864 # # container_html_options # hint_html_options # nav_link_html_options } end |
#show_hint? ⇒ Boolean
rubocop: enable Metrics/ParameterLists
28 29 30 |
# File 'lib/sidebars/menu_item.rb', line 28 def show_hint? .present? end |