From: Tomas Sedovic <[email protected]>

This change won't last as the whole UI structure (including navigation) of
Aggregator will be revamped soon.

Still, it shows how to use the `simple-navigation` gem and will provide a
reference for the changes that are to come.
---
 src/app/stylesheets/dcloud.scss    |    5 -----
 src/app/views/layouts/_header.haml |   11 +----------
 src/config/environment.rb          |    1 +
 src/config/navigation.rb           |   11 +++++++++++
 4 files changed, 13 insertions(+), 15 deletions(-)
 create mode 100644 src/config/navigation.rb

diff --git a/src/app/stylesheets/dcloud.scss b/src/app/stylesheets/dcloud.scss
index 36fce3d..b9cdfae 100644
--- a/src/app/stylesheets/dcloud.scss
+++ b/src/app/stylesheets/dcloud.scss
@@ -218,11 +218,6 @@ ul {
   }
 }
 
-.selected {
-  background: #f2a922;
-  color: white;
-}
-
 .instance_action_list {
   padding: 0;
   li {
diff --git a/src/app/views/layouts/_header.haml 
b/src/app/views/layouts/_header.haml
index 916a162..06a63ef 100644
--- a/src/app/views/layouts/_header.haml
+++ b/src/app/views/layouts/_header.haml
@@ -1,15 +1,6 @@
-- menu = [ { :text => t(:dashboard), :controller => "dashboard" }, |
-  { :text => t(:instances), :controller => "instance" }, |
-  { :text => t(:templates), :controller => "image", :action => "show" }, |
-    ({ :text => t(:users), :controller => "permissions", :action => "list" } 
if @current_user && 
has_view_perms?(BasePermissionObject.general_permission_scope)), |
-  { :text => t(:settings), :controller => "settings" }, |
-  ].find_all {|item| item != nil} |
 .header_logo
   %span Deltacloud Aggregator
-  %ul.nav
-    - menu.each do |item|
-      %li{ :class => ("selected" if item[:controller] == 
controller.controller_name) }<
-        = link_to item[:text], { :controller => item[:controller], :action => 
item[:action] }
+  = render_navigation
 
 .header_info
   #hi-username
diff --git a/src/config/environment.rb b/src/config/environment.rb
index 8c1aff5..e82c578 100644
--- a/src/config/environment.rb
+++ b/src/config/environment.rb
@@ -50,6 +50,7 @@ Rails::Initializer.run do |config|
   config.gem "scruffy"
   config.gem "compass", :version => ">= 0.10.2"
   config.gem "compass-960-plugin", :lib => "ninesixty"
+  config.gem "simple-navigation"
 
   config.active_record.observers = :instance_observer, :task_observer
   # Only load the plugins named here, in the order given. By default, all 
plugins
diff --git a/src/config/navigation.rb b/src/config/navigation.rb
new file mode 100644
index 0000000..f3b34a0
--- /dev/null
+++ b/src/config/navigation.rb
@@ -0,0 +1,11 @@
+SimpleNavigation::Configuration.run do |navigation|
+  navigation.items do |primary|
+    primary.dom_class = 'nav'
+    primary.item :dashboard, t(:dashboard), :controller => "dashboard"
+    primary.item :instances, t(:instances), :controller => "instance"
+    primary.item :templates, t(:templates), :controller => "image", :action => 
"show"
+    primary.item :users, t(:users), {:controller => "permissions", :action => 
"list"} , :if => lambda {
+      @current_user && 
has_view_perms?(BasePermissionObject.general_permission_scope) }
+    primary.item :settings, t(:settings), :controller => "settings"
+  end
+end
-- 
1.7.2.2

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to