{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% block toolbar %}
    {% if collector.isEasyAdminAction %}
        {% set profiler_markup_version = profiler_markup_version|default(1) %}

        {% set icon %}
            {% set icon_fill_color = profiler_markup_version == 1 ? '#222' : '#AAA' %}
            {% set icon_height = profiler_markup_version == 1 ? '28' : '24' %}
            <span class="icon">{{ include('@EasyAdmin/data_collector/icon.svg.twig', { fill_color: icon_fill_color, height: icon_height }) }}</span>
            <span class="sf-toolbar-value sf-toolbar-status">{{ collector.numEntities }}</span>
        {% endset %}

        {% set text %}
        <div class="sf-toolbar-info-piece">
            <b>EasyAdmin version</b>
            <span class="sf-toolbar-status">{{ constant('EasyCorp\\Bundle\\EasyAdminBundle\\EasyAdminBundle::VERSION') }}</span>
        </div>
        <div class="sf-toolbar-info-piece">
            <b>Managed entities</b>
            <span class="sf-toolbar-status">{{ collector.numEntities }}</span>
        </div>
        {% endset %}

        {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { 'link': true }) }}
    {% endif %}
{% endblock %}

{% block menu %}
    <span class="label {{ not collector.isEasyAdminAction ? 'disabled' }}">
        <span class="icon">{{ include('@EasyAdmin/data_collector/icon.svg.twig', { height: 32 }) }}</span>
        <strong>EasyAdmin</strong>
    </span>
{% endblock %}

{% block panel %}
    {% set profiler_markup_version = profiler_markup_version|default(1) %}

    <h2>EasyAdmin <small>({{ constant('EasyCorp\\Bundle\\EasyAdminBundle\\EasyAdminBundle::VERSION') }})</small></h2>

    {% if not collector.isEasyAdminAction %}

        <div class="empty">
            <p>No information available because this route is not related to EasyAdmin.</p>
        </div>

    {% else %}

        {% if profiler_markup_version == 1 %}

            <h3>Request Parameters</h3>
            {{ include('@WebProfiler/Profiler/table.html.twig', { data: collector.requestParameters }) }}

        {% else %}

            {% if collector.requestParameters %}
            <div class="metrics">
                <div class="metric">
                    <span class="value">{{ collector.requestParameters.action|default('-') }}</span>
                    <span class="label">Action</span>
                </div>

                <div class="metric">
                    <span class="value">{{ collector.requestParameters.entity|default('-') }}</span>
                    <span class="label">Entity Name</span>
                </div>

                {% if collector.requestParameters.id %}
                    <div class="metric">
                        <span class="value">{{ collector.requestParameters.id }}</span>
                        <span class="label">ID</span>
                    </div>
                {% elseif collector.requestParameters.sort_field %}
                    <div class="metric">
                        <span class="value">{{ collector.requestParameters.sort_field }} <span class="unit">({{ collector.requestParameters.sort_direction }})</span></span>
                        <span class="label">Sorting</span>
                    </div>
                {% endif %}
            </div>
            {% endif %}

        {% endif %}

        <div class="sf-tabs">
            <div class="tab">
                <h3 class="tab-title">Current Entity Configuration</h3>
                <div class="tab-content">
                    {{ collector.dump(collector.currentEntityConfig)|raw }}
                </div>

                <br>
            </div>

            <div class="tab">
                <h3 class="tab-title">Full Backend Configuration</h3>
                <div class="tab-content">

                    <h4>Basic Configuration</h4>
                    {{ collector.dump({
                        'site_name': collector.backendConfig['site_name'],
                        'formats': collector.backendConfig['formats']
                    })|raw }}

                    <h4>Design Configuration</h4>
                    {{ collector.dump({
                        'design': collector.backendConfig['design']
                    })|raw }}

                    <h4>Actions Configuration</h4>
                    {{ collector.dump({
                        'disabled_actions': collector.backendConfig['disabled_actions'],
                        'list': collector.backendConfig['list'],
                        'edit': collector.backendConfig['edit'],
                        'new': collector.backendConfig['new'],
                        'show': collector.backendConfig['show'],
                    })|raw }}

                    <h4>Entities Configuration</h4>
                    {{ collector.dump({
                        'entities': collector.backendConfig['entities']
                    })|raw }}

                    <h4>Full Backend Configuration</h4>
                    {{ collector.dump({
                        'easy_admin': collector.backendConfig
                    })|raw }}
                </div>
            </div>
        </div>

    {% endif %}

    <h3>Additional Resources</h3>

    <ul>
        <li><a href="https://github.com/EasyCorp/EasyAdminBundle/issues">Report an issue</a></li>
        <li><a href="https://symfony.com/doc/current/bundles/EasyAdminBundle/index.html">Read documentation</a></li>
        <li><a href="https://github.com/EasyCorp/EasyAdminBundle">Project homepage</a></li>
    </ul>

{% endblock %}
