Skip to content

Commit

Permalink
Add server env banner on standard_layout.html.twig
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-ducrot committed Jun 4, 2024
1 parent 74d79e1 commit 52b3268
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions assets/styles/_skin.scss
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
45 changes: 45 additions & 0 deletions templates/standard_layout.html.twig
Original file line number Diff line number Diff line change
@@ -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 = '<b>' ~ smart_server_environment ~ '</b>' ~ ('env_banner_message.unknown')|trans %}
{% endif %}
<div class="sb-tailwind">
<div class="text-center text-xs leading-6 p-0.5 {{ env_banner_class }}">
{% if env_banner_message_not_found is defined %}
{{ env_banner_message_not_found|raw }}
{% else %}
{{ ('env_banner_message.' ~ smart_server_environment)|trans|raw }}
{% endif %}
</div>
<div class="h-px bg-slate-700"></div>
</div>
{% endif %}
{{ parent() }}
{% endblock %}

{% block sonata_left_side %}
{% if display_smart_env_banner %}
<div class="main-sidebar-under-banner">
{{ parent() }}
</div>
{% else %}
{{ parent() }}
{% endif %}
{% endblock %}

{% block side_bar_before_nav %}
{% if app.user and is_granted('ROLE_SONATA_ADMIN') %}
<div class="user-panel">
Expand Down
26 changes: 26 additions & 0 deletions translations/admin.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,32 @@
<source>process.nb_logs_lines</source>
<target>lignes de logs au total.</target>
</trans-unit>

<!-- Env Banner -->
<trans-unit id="env_banner_message.developpement">
<source>env_banner_message.developpement</source>
<target><![CDATA[<b>Développement</b> - Poste du développeur]]></target>
</trans-unit>
<trans-unit id="env_banner_message.development">
<source>env_banner_message.development</source>
<target><![CDATA[<b>Développement</b> - Poste du développeur]]></target>
</trans-unit>
<trans-unit id="env_banner_message.dev">
<source>env_banner_message.dev</source>
<target><![CDATA[<b>Développement</b> - Poste du développeur]]></target>
</trans-unit>
<trans-unit id="env_banner_message.integration">
<source>env_banner_message.integration</source>
<target><![CDATA[<b>Intégration</b> - Environnement de validation interne]]></target>
</trans-unit>
<trans-unit id="env_banner_message.recette">
<source>env_banner_message.recette</source>
<target><![CDATA[<b>Recette</b> - Environnement de validation client]]></target>
</trans-unit>
<trans-unit id="env_banner_message.unknown">
<source>env_banner_message.unknown</source>
<target> - Environnement inconnu</target>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit 52b3268

Please sign in to comment.