{% set enabledChannels = product.channels|filter(channel => channel.enabled == true) %}

{% if sylius_bundle_loaded_checker('SyliusShopBundle') %}
    {% if not product.enabled or enabledChannels|length < 1 %}
        <a class="ui labeled icon button disabled" href="#">
            <i class="angle right icon"></i>
            {{ 'sylius.ui.show_product_in_shop_page'|trans }}
        </a>
    {% elseif enabledChannels|length > 1 %}
        <div class="ui floating dropdown labeled icon button">
            <i class="share alternate icon"></i>
            <span class="text">
                {{ 'sylius.ui.show_product_in_shop_page'|trans }}
            </span>
            <div class="menu">
                <div class="scrolling menu">
                    {% for channel in enabledChannels %}
                        {% set url = channel.hostname is not null ? 'http://' ~ channel.hostname ~ path('sylius_shop_product_show', {'slug': product.slug, '_locale': channel.defaultLocale.code}) : url('sylius_shop_product_show', {'slug': product.slug, '_locale': channel.defaultLocale.code}) %}
                        <a href="{{ url|raw }}" class="item">
                            <i class="angle right icon"></i>
                            {{ 'sylius.ui.show_in'|trans }}
                            {{ channel.name }} ({{ channel.code }})
                        </a>
                    {% endfor %}
                </div>
            </div>
        </div>
    {% else %}
        {% for channel in enabledChannels %}
            {% set url = channel.hostname is not null ? 'http://' ~ channel.hostname ~ path('sylius_shop_product_show', {'slug': product.slug, '_locale': channel.defaultLocale.code}) : url('sylius_shop_product_show', {'slug': product.slug, '_locale': channel.defaultLocale.code}) %}
            <a class="ui labeled icon button" href="{{ url|raw }}">
                <i class="angle right icon"></i>
                {{ 'sylius.ui.show_product_in_shop_page'|trans }}
            </a>
        {% endfor %}
    {% endif %}
{% endif %}
