From 52b32684c30128cab00162d185d5fc6e7e1181b5 Mon Sep 17 00:00:00 2001 From: Mathieu Ducrot Date: Tue, 4 Jun 2024 18:54:32 +0200 Subject: [PATCH] Add server env banner on standard_layout.html.twig --- CHANGELOG.md | 6 ++++ assets/styles/_skin.scss | 10 +++++++ templates/standard_layout.html.twig | 45 +++++++++++++++++++++++++++++ translations/admin.fr.xlf | 26 +++++++++++++++++ 4 files changed, 87 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29ca038..66d1486 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ CHANGELOG =================== +## v2.3.0 - (2024-06-05) +### Added +- `AbstractApiCallAdmin::getOriginChoices` for api call origin filter +- `standard_layout.html.twig` add banner on the **sonata_header_noscript_warning** block to show current server environment + - to unlock it add the following to your `twig.globals` config : `smart_server_environment: '%env(default::ENVIRONMENT)%'` + ## v2.2.0 - (2024-06-04) ### Changed - `AbstractAdmin::__construct` params are now all optionnal as we must configure it through tags from what's ask on the next v5 of Sonata Admin diff --git a/assets/styles/_skin.scss b/assets/styles/_skin.scss index e2d9f2a..6e094df 100644 --- a/assets/styles/_skin.scss +++ b/assets/styles/_skin.scss @@ -1,4 +1,14 @@ .skin-smartbooster { + .main-sidebar-under-banner { + .main-sidebar { + padding-top: 79px; + } + } + .main-sidebar { + hr { + margin-bottom: 0; + } + } //Navbar .main-header { .navbar { diff --git a/templates/standard_layout.html.twig b/templates/standard_layout.html.twig index 4bc3730..7479a84 100644 --- a/templates/standard_layout.html.twig +++ b/templates/standard_layout.html.twig @@ -1,9 +1,54 @@ {% extends "@SonataAdmin/standard_layout.html.twig" %} +{% trans_default_domain 'admin' %} {# Disable sonata link and search bar #} {% block side_bar_after_nav %}{% endblock %} {% block sonata_sidebar_search %}{% endblock %} +{% if smart_server_environment is defined and smart_server_environment is not null and smart_server_environment != 'production' %} + {% set display_smart_env_banner = true %} +{% else %} + {% set display_smart_env_banner = false %} +{% endif %} + +{% block sonata_header_noscript_warning %} + {% if display_smart_env_banner %} + {% if smart_server_environment == 'developpement' + or smart_server_environment == 'development' + or smart_server_environment == 'dev' + or smart_server_environment == 'integration' + %} + {% set env_banner_class = 'bg-blue-600 text-white' %} + {% elseif smart_server_environment == 'recette' %} + {% set env_banner_class = 'bg-yellow-400 text-neutral-darker' %} + {% else %} + {% set env_banner_class = 'bg-danger text-white' %} + {% set env_banner_message_not_found = '' ~ smart_server_environment ~ '' ~ ('env_banner_message.unknown')|trans %} + {% endif %} +
+
+ {% if env_banner_message_not_found is defined %} + {{ env_banner_message_not_found|raw }} + {% else %} + {{ ('env_banner_message.' ~ smart_server_environment)|trans|raw }} + {% endif %} +
+
+
+ {% endif %} + {{ parent() }} +{% endblock %} + +{% block sonata_left_side %} + {% if display_smart_env_banner %} +
+ {{ parent() }} +
+ {% else %} + {{ parent() }} + {% endif %} +{% endblock %} + {% block side_bar_before_nav %} {% if app.user and is_granted('ROLE_SONATA_ADMIN') %}
diff --git a/translations/admin.fr.xlf b/translations/admin.fr.xlf index 1d252bd..f686f77 100644 --- a/translations/admin.fr.xlf +++ b/translations/admin.fr.xlf @@ -226,6 +226,32 @@ process.nb_logs_lines lignes de logs au total. + + + + env_banner_message.developpement + Développement - Poste du développeur]]> + + + env_banner_message.development + Développement - Poste du développeur]]> + + + env_banner_message.dev + Développement - Poste du développeur]]> + + + env_banner_message.integration + Intégration - Environnement de validation interne]]> + + + env_banner_message.recette + Recette - Environnement de validation client]]> + + + env_banner_message.unknown + - Environnement inconnu +