Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'wantful/master' into heroku-workaround

* wantful/master:
  use admin_notes toggle in configuration (no comments option)
  Rails 3.1 compatibility (dispatcher)
  Fixed documentation error for rendering views. Fixes #54
  Added configurable global navigation naming. Closes #48
  • Loading branch information...
commit 114a8e7147f4e2a618c36b251d9a06a3e02eacf8 2 parents 554e28c + 78e8778
@webmat authored
View
38 README.rdoc
@@ -96,6 +96,42 @@ it is set to the name of your Rails.application class name.
# config/initializers/active_admin.rb
config.site_title = "My Admin Site"
+== Customize The Resource
+
+=== Rename the Resource
+
+By default, any references to the resource (menu, routes, buttons, etc) in the
+interface will use the name of the class. You can rename the resource by using
+the <tt>:as</tt> option.
+
+ ActiveAdmin.register Post, :as => "Article"
+
+The resource will then be available as /admin/articles
+
+=== Customize the Navigation
+
+The resource will be displayed in the global navigation by default.
+
+To disable the resource from being displayed in the global navigation:
+
+ ActiveAdmin.register Post do
+ menu false
+ end
+
+To change the name of the label in the menu:
+
+ ActiveAdmin.register Post do
+ menu :label => "My Posts"
+ end
+
+To add the menu as a child of another menu:
+
+ ActiveAdmin.register Post do
+ menu :parent => "Blog"
+ end
+
+This will create the menu item if it doesn't exist yet.
+
== Customizing the Index Page
Filtering and listing resources is one of the most important tasks for
@@ -298,7 +334,7 @@ can also render a partial at any point.
ActiveAdmin.register Post do
show do
- # renders app/admin/posts/_some_partial.html.erb
+ # renders app/views/admin/posts/_some_partial.html.erb
render "some_partial"
end
end
View
26 features/menu.feature
@@ -0,0 +1,26 @@
+Feature: Menu
+
+ Background:
+ Given I am logged in
+
+ Scenario: Hide the menu item
+ Given a configuration of:
+ """
+ ActiveAdmin.register Post do
+ menu false
+ end
+ """
+ When I am on the dashboard
+ Then I should not see a menu item for "Posts"
+
+ Scenario: Set the menu item label
+ Given a configuration of:
+ """
+ ActiveAdmin.register Post do
+ menu :label => "Articles"
+ end
+ """
+ When I am on the dashboard
+ Then I should see a menu item for "Articles"
+ Then show me the page
+ And I should not see a menu item for "Posts"
View
7 features/step_definitions/menu_steps.rb
@@ -0,0 +1,7 @@
+Then /^I should see a menu item for "([^"]*)"$/ do |name|
+ Then %{I should see "#{name}" within "#tabs li a"}
+end
+
+Then /^I should not see a menu item for "([^"]*)"$/ do |name|
+ Then %{I should not see "#{name}" within "#tabs li a"}
+end
View
4 lib/active_admin.rb
@@ -118,7 +118,7 @@ def setup
# Dispatch request which gets triggered once in production
# and on every require in development mode
- ActionDispatch::Callbacks.to_prepare :active_admin do
+ ActionDispatch::Callbacks.to_prepare do
ActiveAdmin.unload!
Rails.application.reload_routes!
end
@@ -134,7 +134,7 @@ def setup
# Registers a brand new configuration for the given resource.
def register(resource, options = {}, &block)
- namespace_name = (options[:namespace] || default_namespace) == false ? :root : (options[:namespace] || default_namespace)
+ namespace_name = options[:namespace] == false ? :root : (options[:namespace] || default_namespace || :root)
namespace = find_or_create_namespace(namespace_name)
namespace.register(resource, options, &block)
end
View
2  lib/active_admin/comments/show_page_helper.rb
@@ -9,7 +9,7 @@ module ShowPageHelper
# turned on for the current resource
def default_main_content
super
- active_admin_comments if active_admin_config.comments?
+ active_admin_comments if active_admin_config.admin_notes?
end
# Display the comments for the resource. Same as calling
View
9 lib/active_admin/resource.rb
@@ -121,16 +121,17 @@ def parent_menu_item_name
@menu_options[:parent]
end
+ # Returns the name to be displayed in the menu for this resource
+ def menu_item_name
+ @menu_options[:label] || plural_resource_name
+ end
+
# Should this resource be added to the menu system?
def include_in_menu?
return false if @menu_options[:display] == false
!(belongs_to? && !belongs_to_config.optional?)
end
- # Returns the name to be displayed in the menu for this resource
- def menu_item_name
- @menu_item_name ||= plural_resource_name
- end
# Clears all the member actions this resource knows about
def clear_member_actions!
View
10 spec/unit/resource_spec.rb
@@ -90,6 +90,16 @@ module ::Mock; class Resource; end; end
end
end
+ describe "menu item name" do
+ it "should be the resource name when not set" do
+ config.menu_item_name.should == "Categories"
+ end
+ it "should be settable" do
+ config.menu :label => "My Label"
+ config.menu_item_name.should == "My Label"
+ end
+ end
+
describe "parent menu item name" do
it "should be nil when not set" do
config.parent_menu_item_name.should == nil
Please sign in to comment.
Something went wrong with that request. Please try again.