{%- if g.current_user.has_permission(AdminPermission.access) %}

  {%- with
    current_page = current_page|default,
    brand = current_page_brand|default,
    site = current_page_site|default,
    party = current_page_party|default
  %}
    {%- include 'layout/admin/_navigation_global.html' %}

    {%- if brand %}
      {%- include 'layout/admin/_navigation_brand.html' %}
    {%- endif %}

    {%- if site %}
      {%- with brand = get_brand_for_site(site) %}
      {%- include 'layout/admin/_navigation_brand.html' %}
      {%- include 'layout/admin/_navigation_site.html' %}
      {%- endwith %}
    {%- endif %}

    {%- if party %}
      {%- with brand = get_brand_for_party(party) %}
      {%- include 'layout/admin/_navigation_brand.html' %}
      {%- include 'layout/admin/_navigation_party.html' %}
      {%- endwith %}
    {%- endif %}

  {%- endwith %}

{%- endif %}

{%- from 'macros/icons.html' import render_icon %}


{%- macro render_navigation_backlink(label, url) %}
<section class="sidebar-section">
  <header class="sidebar-section-header" style="border: 0; padding: 0;">
    <a href="{{ url }}" class="sidebar-section-title button button--clear" style="font-size: 0.875rem; padding-left: 15px; width: 100%;">{{ render_icon('arrow-up') }} <span>{{ label }}</span></a>
  </header>
</section>
{%- endmacro %}


{%- if g.current_user.has_permission(AdminPermission.access) %}

  {%- with
    current_page = current_page|default,
    brand = current_page_brand|default,
    site = current_page_site|default,
    party = current_page_party|default
  %}
    {%- if not brand and not site and not party %}
      {%- include 'layout/admin/_navigation_global.html' %}
    {%- else %}
{{ render_navigation_backlink('Global', url_for('admin_dashboard.view_global')) }}
    {%- endif %}

    {%- if brand %}
      {%- include 'layout/admin/_navigation_brand.html' %}
    {%- endif %}

    {%- if site %}
      {%- with brand = get_brand_for_site(site) %}
{{ render_navigation_backlink(brand.title, url_for('admin_dashboard.view_brand', brand_id=brand.id)) }}
      {%- include 'layout/admin/_navigation_site.html' %}
      {%- endwith %}
    {%- endif %}

    {%- if party %}
      {%- with brand = get_brand_for_party(party) %}
{{ render_navigation_backlink(brand.title, url_for('admin_dashboard.view_brand', brand_id=brand.id)) }}
      {%- include 'layout/admin/_navigation_party.html' %}
      {%- endwith %}
    {%- endif %}

  {%- endwith %}

{%- endif %}

Replace higher-level admin navigation sections with backlinks
Replace higher-level admin navigation sections with backlinks
