Skip to content

Commit 26def0e

Browse files
committed
Added docs for the updated to the menu system
1 parent 6c70cc8 commit 26def0e

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
### Deprecations
99

1010
* Removed all references to ActiveAdmin::Renderer. If you were using these
11-
please update code to use an Arbre component
11+
please update code to use an Arbre component. Removed
12+
`ActiveAdmin:Views::HeaderRender` and replaced with
13+
`ActiveAdmin::Views::Header` component.
14+
* ActiveAdmin::Menu and ActiveAdmin::MenuItem API has changed. If you were
15+
creating custom menu items, the builder syntax has changed to. Menu#add now
16+
accepts a MenuItem, instead of building the menu item for you.
1217

1318

1419
## 0.4.2

docs/2-resource-customization.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ the resource from being displayed in the global navigation, pass `false` to the
3535

3636
The menu method accepts a hash with the following options:
3737

38-
* `:label` - The string label to display in the menu
38+
* `:label` - The string or proc label to display in the menu. If it's a proc, it
39+
will be called each time the menu is rendered.
3940
* `:parent` - The string label of the parent to set for this menu
4041
* `:if` - A block or a symbol of a method to call to decide if the menu item
4142
should be displayed
@@ -51,6 +52,13 @@ To change the name of the label in the menu:
5152

5253
By default the menu uses a pluralized version of your resource name.
5354

55+
If you wish to translate your label at runtime, store the label as a proc
56+
instead of a string. The proc will be called each time the menu is rendered.
57+
58+
ActiveAdmin.register Post do
59+
menu :label => proc{ I18n.t("mypost") }
60+
end
61+
5462
### Drop Down Menus
5563

5664
In many cases, a single level navigation will not be enough for the

lib/active_admin/menu.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
module ActiveAdmin
22

3+
# Each Namespace builds up it's own menu as the global navigation
4+
#
5+
# To build a new menu:
6+
#
7+
# menu = Menu.new do |m|
8+
# m.add MenuItem.new(:label => "Dashboard", :url => "/")
9+
# m.add MenuItem.new(:label => "Admin", :url => "/admin")
10+
# end
11+
#
12+
# If you're interested in configuring a menu item, take a look at the
13+
# options available in `ActiveAdmin::MenuItem`
14+
#
315
class Menu
416

517
attr_accessor :children

0 commit comments

Comments
 (0)