toolbar: Factor out the clients buttons into a separate template

- So that it can be reused in frontpage.

Tests performed:

- Go to an app like Gitweb. Both launch web client button and clients apps
button should be visible. Similarly, Deluge should only show launch button.
Infinoted should only show clients button.

- Go to an app like Gitweb where launch web client button is available. Enabling
the app should enable the launch web client button and disabling the app should
disable the launch web client button.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2020-03-17 23:15:06 -07:00 committed by Veiko Aasa
parent 4dc223d233
commit 75bc011fe7
No known key found for this signature in database
GPG Key ID: 478539CAE680674E
2 changed files with 30 additions and 25 deletions

View File

@ -0,0 +1,29 @@
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% load plinth_extras %}
{% if clients %}
{% with client_platforms=clients|clients_get_platforms %}
{% if client_platforms.web|length == 1 %}
<a target='_blank' rel="noopener noreferrer"
class="btn btn-primary" role="button" data-turbolinks="false"
{% if not enabled %} disabled="disabled"
{% else %} href="{{ client_platforms.web.0.url }}"
{% endif %} data-turbolinks="false">
{% trans "Launch web client" %}
<span class="fa fa-external-link"></span>
</a>
{% endif %}
{% if client_platforms.web|length > 1 or client_platforms.other %}
<button type="button" data-toggle="collapse" data-target="#clients"
class="btn btn-default collapsed collapsible-button">
<span class="fa fa-chevron-right fa-fw" aria-hidden="true"></span>
{% trans "Client Apps" %}
</button>
{% endif %}
{% endwith %}
{% endif %}

View File

@ -2,38 +2,14 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
{% load plinth_extras %}
{% load static %}
{% block toolbar %}
<section class="toolbar">
<div class="btn-toolbar" role="toolbar">
{% if app_info.clients %}
{% with client_platforms=app_info.clients|clients_get_platforms %}
{% if client_platforms.web|length == 1 %}
<a target='_blank' rel="noopener noreferrer"
class="btn btn-primary" role="button" data-turbolinks="false"
{% if not enabled %} disabled="disabled"
{% else %} href="{{ client_platforms.web.0.url }}"
{% endif %} data-turbolinks="false">
{% trans "Launch web client" %}
<span class="fa fa-external-link"></span>
</a>
{% endif %}
{% if client_platforms.web|length > 1 or client_platforms.other %}
<button type="button" data-toggle="collapse" data-target="#clients"
class="btn btn-default collapsed collapsible-button">
<span class="fa fa-chevron-right fa-fw" aria-hidden="true"></span>
{% trans "Client Apps" %}
</button>
{% endif %}
{% endwith %}
{% endif %}
{% include "clients-button.html" with clients=app_info.clients enabled=is_enabled %}
{% if has_diagnostics %}
<!-- Single button -->