Class: Sidebars::Panel

Inherits:
Object
  • Object
show all
Extended by:
Gitlab::Utils::Override
Includes:
Gitlab::Experiment::Dsl, Concerns::PositionableList
Defined in:
lib/sidebars/panel.rb

Direct Known Subclasses

Groups::Panel, Sidebars::Projects::Panel

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods included from Concerns::PositionableList

#add_element, #insert_element_after, #insert_element_before, #remove_element, #replace_element

Constructor Details

#initialize(context) ⇒ Panel

Returns a new instance of Panel.


11
12
13
14
15
16
17
18
# File 'lib/sidebars/panel.rb', line 11

def initialize(context)
  @context = context
  @scope_menu = nil
  @hidden_menu = nil
  @menus = []

  configure_menus
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.


9
10
11
# File 'lib/sidebars/panel.rb', line 9

def context
  @context
end

#hidden_menuObject (readonly)

Returns the value of attribute hidden_menu.


9
10
11
# File 'lib/sidebars/panel.rb', line 9

def hidden_menu
  @hidden_menu
end

#scope_menuObject (readonly)

Returns the value of attribute scope_menu.


9
10
11
# File 'lib/sidebars/panel.rb', line 9

def scope_menu
  @scope_menu
end

Instance Method Details

#add_menu(menu) ⇒ Object


24
25
26
# File 'lib/sidebars/panel.rb', line 24

def add_menu(menu)
  add_element(@menus, menu)
end

#aria_labelObject

Raises:

  • (NotImplementedError)

52
53
54
# File 'lib/sidebars/panel.rb', line 52

def aria_label
  raise NotImplementedError
end

#configure_menusObject


20
21
22
# File 'lib/sidebars/panel.rb', line 20

def configure_menus
  # No-op
end

#containerObject


64
65
66
# File 'lib/sidebars/panel.rb', line 64

def container
  context.container
end

#has_renderable_menus?Boolean

Returns:

  • (Boolean)

56
57
58
# File 'lib/sidebars/panel.rb', line 56

def has_renderable_menus?
  renderable_menus.any?
end

#insert_menu_after(after_menu, new_menu) ⇒ Object


32
33
34
# File 'lib/sidebars/panel.rb', line 32

def insert_menu_after(after_menu, new_menu)
  insert_element_after(@menus, after_menu, new_menu)
end

#insert_menu_before(before_menu, new_menu) ⇒ Object


28
29
30
# File 'lib/sidebars/panel.rb', line 28

def insert_menu_before(before_menu, new_menu)
  insert_element_before(@menus, before_menu, new_menu)
end

#remove_menu(menu_to_remove) ⇒ Object


40
41
42
# File 'lib/sidebars/panel.rb', line 40

def remove_menu(menu_to_remove)
  remove_element(@menus, menu_to_remove)
end

#render_raw_menus_partialObject

Auxiliar method that helps with the migration from regular views to the new logic.

Any menu inside this partial will be added after all the menus added in the `configure_menus` method.


80
81
82
# File 'lib/sidebars/panel.rb', line 80

def render_raw_menus_partial
  # No-op
end

#render_raw_scope_menu_partialObject

Auxiliar method that helps with the migration from regular views to the new logic


70
71
72
# File 'lib/sidebars/panel.rb', line 70

def render_raw_scope_menu_partial
  # No-op
end

#renderable_menusObject


60
61
62
# File 'lib/sidebars/panel.rb', line 60

def renderable_menus
  @renderable_menus ||= @menus.select(&:render?)
end

#replace_menu(menu_to_replace, new_menu) ⇒ Object


36
37
38
# File 'lib/sidebars/panel.rb', line 36

def replace_menu(menu_to_replace, new_menu)
  replace_element(@menus, menu_to_replace, new_menu)
end

#set_hidden_menu(hidden_menu) ⇒ Object


48
49
50
# File 'lib/sidebars/panel.rb', line 48

def set_hidden_menu(hidden_menu)
  @hidden_menu = hidden_menu
end

#set_scope_menu(scope_menu) ⇒ Object


44
45
46
# File 'lib/sidebars/panel.rb', line 44

def set_scope_menu(scope_menu)
  @scope_menu = scope_menu
end