lib/active_admin/dashboards.rb in activeadmin-0.4.4 vs lib/active_admin/dashboards.rb in activeadmin-0.5.0.pre
- old
+ new
@@ -1,11 +1,11 @@
+require 'active_admin/dashboards/dashboard_controller'
+require 'active_admin/dashboards/section'
+
module ActiveAdmin
module Dashboards
- autoload :DashboardController, 'active_admin/dashboards/dashboard_controller'
- autoload :Section, 'active_admin/dashboards/section'
-
@@sections = {}
mattr_accessor :sections
class << self
@@ -19,13 +19,19 @@
# # return a list of posts
# end
# end
#
def build(&block)
+ warn "DEPRECATION WARNING: ActiveAdmin::Dashboard is deprecated and will be removed in the next version"
+ @built = true
module_eval(&block)
end
+ def built?
+ !!@built
+ end
+
# Add a new dashboard section to a namespace. If no namespace is given
# it will be added to the default namespace.
#
# Options include:
# :namespace => only display for specified namespace.
@@ -44,9 +50,20 @@
def clear_all_sections!
@@sections = {}
end
- end
+ # Called from MenuBuilder to register dashboard to menu.
+ def add_to_menu(namespace, menu)
+ return unless ActiveAdmin::Dashboards.built?
+ dashboard_path = namespace.root? ? :dashboard_path : "#{namespace.name}_dashboard_path".to_sym
+
+ item = MenuItem.new :id => "dashboard",
+ :label => proc{ I18n.t("active_admin.dashboard") },
+ :url => dashboard_path,
+ :priority => 1
+ menu.add item
+ end
+ end
end
end