From a1fb8dab573b6b17ff0d549b5aa63c33a9f506bd Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Mon, 30 Oct 2023 15:37:04 +0100 Subject: [PATCH] chore(announces): main navigation across announces --- .../super_admins/release_notes_controller.rb | 4 ++ app/views/layouts/_account_dropdown.haml | 2 +- app/views/layouts/_header.haml | 4 ++ .../release_notes/_main_navigation.html.haml | 17 ++++++++ .../super_admins/release_notes/edit.html.haml | 2 + .../release_notes/index.html.haml | 43 +++++++++++-------- .../super_admins/release_notes/new.html.haml | 2 + .../views/layouts/_account_dropdown.en.yml | 1 + .../views/layouts/_account_dropdown.fr.yml | 1 + 9 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 app/views/super_admins/release_notes/_main_navigation.html.haml diff --git a/app/controllers/super_admins/release_notes_controller.rb b/app/controllers/super_admins/release_notes_controller.rb index 75cb668fc2f..9522d9ac29f 100644 --- a/app/controllers/super_admins/release_notes_controller.rb +++ b/app/controllers/super_admins/release_notes_controller.rb @@ -2,6 +2,10 @@ class SuperAdmins::ReleaseNotesController < ApplicationController before_action :authenticate_super_admin! before_action :set_note, only: [:edit, :update, :destroy] + def nav_bar_profile + :superadmin + end + def index @release_notes = ReleaseNote .order(released_on: :desc, id: :asc) diff --git a/app/views/layouts/_account_dropdown.haml b/app/views/layouts/_account_dropdown.haml index 99f86a93f84..0d9934470e2 100644 --- a/app/views/layouts/_account_dropdown.haml +++ b/app/views/layouts/_account_dropdown.haml @@ -36,7 +36,7 @@ %span.fr-icon-refresh-line.fr-icon--sm = t('go_gestionnaire', scope: [:layouts]) - - if super_admin_signed_in? + - if super_admin_signed_in? && nav_bar_profile != :superadmin %li = link_to manager_root_path, class: "fr-nav__link" do %span.fr-icon-shield-line.fr-icon--sm diff --git a/app/views/layouts/_header.haml b/app/views/layouts/_header.haml index 58e290b9bcb..22a4e47e3a7 100644 --- a/app/views/layouts/_header.haml +++ b/app/views/layouts/_header.haml @@ -99,4 +99,8 @@ - if current_user.expert && current_expert.avis_summary[:total] > 0 = render partial: 'layouts/header/avis_tab', locals: { current_expert: current_expert } + - if content_for?(:navigation_principale) + .fr-container + = yield(:navigation_principale) + = yield(:notice_info) diff --git a/app/views/super_admins/release_notes/_main_navigation.html.haml b/app/views/super_admins/release_notes/_main_navigation.html.haml new file mode 100644 index 00000000000..2959495b0a6 --- /dev/null +++ b/app/views/super_admins/release_notes/_main_navigation.html.haml @@ -0,0 +1,17 @@ +- content_for(:navigation_principale) do + .fr-container + %nav.fr-nav#header-navigation{ role: "navigation", aria: { label: 'Menu principal annonces' } } + %ul.fr-nav__list + %li.fr-nav__item + = link_to "Toutes les annonces", super_admins_release_notes_path, class: "fr-nav__link", target: "_self", aria: { current: action == :index ? "page" : nil } + + %li.fr-nav__item + = link_to("Nouvelle annonce", new_super_admins_release_note_path(date: @release_note&.released_on), class: "fr-nav__link", target: "_self", aria: { current: action == :new ? "page" : nil }) + + - if action == :edit + %li.fr-nav__item + = link_to "Annonce", '', class: "fr-nav__link", target: "_self", aria: { current: "page" } + + %li.fr-nav__item + = link_to "Annonces publiées", release_notes_path, class: "fr-nav__link", target: "_self" + diff --git a/app/views/super_admins/release_notes/edit.html.haml b/app/views/super_admins/release_notes/edit.html.haml index 8b5c4005465..df87cc38679 100644 --- a/app/views/super_admins/release_notes/edit.html.haml +++ b/app/views/super_admins/release_notes/edit.html.haml @@ -1,3 +1,5 @@ += render "main_navigation", action: :edit + .fr-container.fr-my-5w .fr-grid-row.fr-grid-row--center .fr-col-lg-10 diff --git a/app/views/super_admins/release_notes/index.html.haml b/app/views/super_admins/release_notes/index.html.haml index 12dca787024..24e1d99879f 100644 --- a/app/views/super_admins/release_notes/index.html.haml +++ b/app/views/super_admins/release_notes/index.html.haml @@ -1,24 +1,31 @@ += render "main_navigation", action: :index + .fr-container.fr-my-5w .fr-grid-row.fr-grid-row--center .fr-col-lg-10 - %h1.fr-h2 Liste des annonces - = link_to("Créer une annonce", new_super_admins_release_note_path, class: "fr-btn") + %h1.fr-h2 Liste des annonces - %table.fr-table - %thead - %th Annoncé le - %th Publié? - %th Actions - %tbody - - @release_notes.each do |note| - %tr - %td= l(note.released_on) if note.released_on - %td - - if note.published? - %span.fr-badge.fr-badge--success.fr-badge--no-icon Publié - - else - %span.fr-badge.fr-badge--warning.fr-badge--no-icon Brouillon - %td - = link_to 'Modifier', edit_super_admins_release_note_path(note), class: 'fr-btn fr-btn--secondary' + -# haml-lint:disable ApplicationNameLinter + = link_to "Releases sur GitHub", "https://github.com/demarches-simplifiees/demarches-simplifiees.fr/releases", **external_link_attributes + -# haml-lint:enable ApplicationNameLinter + .fr-table + %table + %thead + %th Annoncé le + %th Publié? + %th Notes + %th Actions + %tbody + - @release_notes.each do |note| + %tr + %td= l(note.released_on) if note.released_on + %td + - if note.published? + %span.fr-badge.fr-badge--success.fr-badge--no-icon Publié + - else + %span.fr-badge.fr-badge--warning.fr-badge--no-icon Brouillon + %td= note.body.to_plain_text.truncate_words(12) + %td + = link_to 'Modifier', edit_super_admins_release_note_path(note), class: 'fr-btn fr-btn--secondary' diff --git a/app/views/super_admins/release_notes/new.html.haml b/app/views/super_admins/release_notes/new.html.haml index 68362d0fd89..961a9f78f27 100644 --- a/app/views/super_admins/release_notes/new.html.haml +++ b/app/views/super_admins/release_notes/new.html.haml @@ -1,3 +1,5 @@ += render "main_navigation", action: :new + .fr-container.fr-my-5w .fr-grid-row.fr-grid-row--center .fr-col-lg-10 diff --git a/config/locales/views/layouts/_account_dropdown.en.yml b/config/locales/views/layouts/_account_dropdown.en.yml index a611a8065dd..1d3d64b8882 100644 --- a/config/locales/views/layouts/_account_dropdown.en.yml +++ b/config/locales/views/layouts/_account_dropdown.en.yml @@ -16,6 +16,7 @@ en: instructeur: instructor administrateur: admin gestionnaire: admins group manager + superadmin: super-admin expert: expert user: user guest: guest diff --git a/config/locales/views/layouts/_account_dropdown.fr.yml b/config/locales/views/layouts/_account_dropdown.fr.yml index 5b3ab8274e5..67f427a339b 100644 --- a/config/locales/views/layouts/_account_dropdown.fr.yml +++ b/config/locales/views/layouts/_account_dropdown.fr.yml @@ -16,6 +16,7 @@ fr: instructeur: instructeur administrateur: administrateur gestionnaire: gestionnaire + superadmin: super-admin expert: expert user: usager guest: invité