From 6d1991a8d5dc4b0b5e9ccb542b0ef6dc977a3b6d Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Thu, 12 Aug 2021 10:20:37 +0200
Subject: [PATCH] clean

---
 app/assets/stylesheets/admin/styles.sass            |  2 ++
 app/controllers/admin/application_controller.rb     |  6 ++++++
 .../features/education/application_controller.rb    |  2 +-
 .../admin/features/education/programs_controller.rb |  5 +----
 .../admin/features/websites/sites_controller.rb     |  5 +----
 config/admin_navigation.rb                          | 13 +++----------
 6 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/app/assets/stylesheets/admin/styles.sass b/app/assets/stylesheets/admin/styles.sass
index 2bef76650..6abd473ba 100644
--- a/app/assets/stylesheets/admin/styles.sass
+++ b/app/assets/stylesheets/admin/styles.sass
@@ -5,6 +5,8 @@ h1
     min-width: 20px
 
 body, body[data-theme=dark]
+    .sidebar
+        background: black
     .sidebar-content
         background-color: black
         background-image: asset-url('sun.svg')
diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb
index 168a63016..9c3e0febd 100644
--- a/app/controllers/admin/application_controller.rb
+++ b/app/controllers/admin/application_controller.rb
@@ -8,4 +8,10 @@ class Admin::ApplicationController < ApplicationController
   def breadcrumb
     add_breadcrumb 'Tableau de bord', :admin_root_path
   end
+
+  def breadcrumb_for(object)
+    return unless object
+    object.persisted? ? add_breadcrumb(object, [:admin, object])
+                      : add_breadcrumb('Créer')
+  end
 end
diff --git a/app/controllers/admin/features/education/application_controller.rb b/app/controllers/admin/features/education/application_controller.rb
index 1346e9b2b..20fee4e63 100644
--- a/app/controllers/admin/features/education/application_controller.rb
+++ b/app/controllers/admin/features/education/application_controller.rb
@@ -1,6 +1,6 @@
 class Admin::Features::Education::ApplicationController < Admin::ApplicationController
   def breadcrumb
     super
-    add_breadcrumb Features::Education.model_name.human, :admin_features_education_dashboard_path
+    add_breadcrumb 'Enseignement'
   end
 end
diff --git a/app/controllers/admin/features/education/programs_controller.rb b/app/controllers/admin/features/education/programs_controller.rb
index e2a30b7ba..180fa3898 100644
--- a/app/controllers/admin/features/education/programs_controller.rb
+++ b/app/controllers/admin/features/education/programs_controller.rb
@@ -46,10 +46,7 @@ class Admin::Features::Education::ProgramsController < Admin::Features::Educatio
   def breadcrumb
     super
     add_breadcrumb Features::Education::Program.model_name.human(count: 2), admin_features_education_programs_path
-    if @program
-      @program.persisted? ? add_breadcrumb(@program, [:admin, @program])
-                          : add_breadcrumb('Créer')
-    end
+    breadcrumb_for @program
   end
 
   def program_params
diff --git a/app/controllers/admin/features/websites/sites_controller.rb b/app/controllers/admin/features/websites/sites_controller.rb
index 8f7b03572..5aac8fd87 100644
--- a/app/controllers/admin/features/websites/sites_controller.rb
+++ b/app/controllers/admin/features/websites/sites_controller.rb
@@ -47,10 +47,7 @@ class Admin::Features::Websites::SitesController < Admin::Features::Websites::Ap
   def breadcrumb
     super
     add_breadcrumb Features::Websites::Site.model_name.human(count: 2), admin_features_websites_sites_path
-    if @site
-      @site.persisted?  ? add_breadcrumb(@site, [:admin, @site])
-                        : add_breadcrumb('Créer')
-    end
+    breadcrumb_for @site
   end
 
   def site_params
diff --git a/config/admin_navigation.rb b/config/admin_navigation.rb
index cb2a2c857..dcf622602 100644
--- a/config/admin_navigation.rb
+++ b/config/admin_navigation.rb
@@ -4,14 +4,10 @@ SimpleNavigation::Configuration.run do |navigation|
   navigation.highlight_on_subpath = true
   navigation.selected_class = 'active'
   navigation.items do |primary|
-    primary.item :dashboard, t('dashboard'), admin_root_path, { icon: 'tachometer-alt' }
+    primary.item :dashboard, t('dashboard'), admin_root_path, { icon: 'tachometer-alt', highlights_on: /admin$/ }
 
     primary.item :teaching, 'Enseignement', nil, { kind: :header }
-    primary.item :education, 'Formations', nil, { icon: 'graduation-cap' } do |secondary|
-      secondary.item :dashboard, t('dashboard'), admin_features_education_dashboard_path
-      secondary.item :programs, Features::Education::Program.model_name.human(count: 2), admin_features_education_programs_path
-      secondary.item :qualiopi, Features::Education::Qualiopi.model_name.human, admin_features_education_qualiopi_criterions_path
-    end
+    primary.item :education, 'Formations', admin_features_education_programs_path, { icon: 'graduation-cap' }
     primary.item :teaching, 'Ecoles', nil, { icon: 'university' }
     primary.item :teaching, 'Enseignants', nil, { icon: 'user-graduate' }
     primary.item :teaching, 'Feedbacks', nil, { icon: 'comments' }
@@ -24,10 +20,7 @@ SimpleNavigation::Configuration.run do |navigation|
     primary.item :teaching, 'Veille', nil, { icon: 'eye' }
 
     primary.item :teaching, 'Communication', nil, { kind: :header }
-    primary.item :websites, Features::Websites.model_name.human, nil, { icon: 'sitemap' } do |secondary|
-      secondary.item :dashboard, t('dashboard'), admin_features_websites_dashboard_path
-      secondary.item :sites, Features::Websites::Site.model_name.human(count: 2), admin_features_websites_sites_path
-    end
+    primary.item :websites, 'Sites Web', admin_features_websites_sites_path, { icon: 'sitemap' }
     primary.item :teaching, 'Lettres d\'information', nil, { icon: 'envelope' }
     primary.item :teaching, 'Alumni', nil, { icon: 'users' }
 
-- 
GitLab