Permalink
Browse files

Move Menu to its own file.

  • Loading branch information...
varyonic committed Sep 3, 2017
1 parent fe3ee7b commit be8507dca6b2ec0a63fc4dd7b4f89035e86bffcb
Showing with 34 additions and 29 deletions.
  1. +32 −0 lib/active_admin/views/components/menu.rb
  2. +2 −29 lib/active_admin/views/tabbed_navigation.rb
@@ -0,0 +1,32 @@
module ActiveAdmin
module Views
# Renders an ActiveAdmin::Menu as a set of unordered list items.
#
# This component takes cares of deciding which items should be
# displayed given the current context and renders them appropriately.
#
# The entire component is rendered within one ul element.
class Menu < Component
attr_reader :menu
builder_method :menu
# @param [ActiveAdmin::Menu] menu the Menu to render
# @param [Hash] options the options as passed to the underlying ul element.
#
def build(menu, options = {})
@menu = menu
super(options)
menu.items.each do |item|
menu_item(item) if item.display?(self)
end
children.sort!
end
def tag_name
'ul'
end
end
end
end
@@ -1,34 +1,7 @@
require_relative 'components/menu'
module ActiveAdmin
module Views
# Renders an ActiveAdmin::Menu as a set of unordered list items.
#
# This component takes cares of deciding which items should be
# displayed given the current context and renders them appropriately.
#
# The entire component is rendered within one ul element.
class Menu < Component
attr_reader :menu
builder_method :menu
# @param [ActiveAdmin::Menu] menu the Menu to render
# @param [Hash] options the options as passed to the underlying ul element.
#
def build(menu, options = {})
@menu = menu
super(options)
menu.items.each do |item|
menu_item(item) if item.display?(self)
end
children.sort!
end
def tag_name
'ul'
end
end
class TabbedNavigation < Menu
def build(menu, options = {})
super(menu, options.reverse_merge(id: 'tabs'))

0 comments on commit be8507d

Please sign in to comment.