{% load i18n %}
{% load url from future %}

<h3 class="heading_switcher env_switcher">{% trans "Environment:" %}

    <div id="environment_switcher" class="header dropdown">
        {% with num_of_envs=available_environments|length %}
            {% if environment %}
                <a href="#environment_switcher" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">{{ environment.name }} {% if num_of_envs > 1 %} <b class="caret"></b>{% endif %}</a>
            {% else %}
                <a href="{% url 'horizon:murano:environments:create_environment' %}?next={% url 'horizon:murano:catalog:index' %}" title="{% trans 'Click to create an environment' %}" class="btn btn-default ajax-modal">{% trans "Create Environment" %}</a>
            {% endif %}

            {% if num_of_envs > 1 %}
                 <ul id="environment_list" class="dropdown-menu row_actions clearfix">
                    {% for env in available_environments %}
                        {% if env.id != environment.id %}
                            <li class="clearfix"><a tabindex="-1" href="{% url 'horizon:murano:catalog:switch_env' env.id %}?next={% url 'horizon:murano:catalog:index' %}" class="btn btn-small">{{ env.name }}</a></li>
                        {% endif %}
                    {% endfor %}
                </ul>
            {% endif %}
        {% endwith %}
    </div>
</h3>
