From 8e3bbdb089dc86ea3f52fd1efecc1aefd7dfe5c5 Mon Sep 17 00:00:00 2001 From: Alice Kile Date: Thu, 14 Nov 2019 12:14:17 +0530 Subject: [PATCH] clients: implement launch button feature Reviewed-by: Joseph Nuthalapati --- plinth/modules/ejabberd/templates/ejabberd.html | 4 ---- plinth/modules/jsxc/templates/jsxc.html | 5 ----- plinth/modules/roundcube/urls.py | 2 +- plinth/templates/app.html | 15 ++++++++++++++- plinth/templates/clients.html | 2 +- plinth/templatetags/plinth_extras.py | 6 ++++++ plinth/utils.py | 1 - 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/plinth/modules/ejabberd/templates/ejabberd.html b/plinth/modules/ejabberd/templates/ejabberd.html index c6b69389c..566039d10 100644 --- a/plinth/modules/ejabberd/templates/ejabberd.html +++ b/plinth/modules/ejabberd/templates/ejabberd.html @@ -42,10 +42,6 @@ {% endif %}

-

- - {% trans "Launch web client" %} -

{% endblock %} diff --git a/plinth/modules/jsxc/templates/jsxc.html b/plinth/modules/jsxc/templates/jsxc.html index 2cb34f379..093f03f1e 100644 --- a/plinth/modules/jsxc/templates/jsxc.html +++ b/plinth/modules/jsxc/templates/jsxc.html @@ -26,11 +26,6 @@

{{ paragraph|safe }}

{% endfor %} - -

- - {% trans "Launch web client" %} -

{% endblock %} {% block configuration %} diff --git a/plinth/modules/roundcube/urls.py b/plinth/modules/roundcube/urls.py index a9c29fda5..f1ba3a856 100644 --- a/plinth/modules/roundcube/urls.py +++ b/plinth/modules/roundcube/urls.py @@ -29,6 +29,6 @@ urlpatterns = [ AppView.as_view(app_id='roundcube', name=roundcube.name, diagnostics_module_name='roundcube', description=roundcube.description, - show_status_block=False, + show_status_block=False, clients=roundcube.clients, manual_page=roundcube.manual_page), name='index'), ] diff --git a/plinth/templates/app.html b/plinth/templates/app.html index d3077de16..11e65af65 100644 --- a/plinth/templates/app.html +++ b/plinth/templates/app.html @@ -45,7 +45,20 @@

{% endif %} - {% include "clients.html" with clients=clients enabled=is_enabled %} + {% if clients|length == 1 and clients|first|lookup:'platforms'|length == 1 and clients|first|lookup:'platforms'|first|lookup:'type' == 'web' %} + + {% block launch_button %} +

+ + {% trans "Launch web client" %} +

+ {% endblock %} + + {% else %} + + {% include "clients.html" with clients=clients enabled=is_enabled %} + + {% endif %} {% block subsubmenu %} {% if subsubmenu %} diff --git a/plinth/templates/clients.html b/plinth/templates/clients.html index 003c8bac1..1192f4027 100644 --- a/plinth/templates/clients.html +++ b/plinth/templates/clients.html @@ -44,7 +44,7 @@ {{ client.name }} diff --git a/plinth/templatetags/plinth_extras.py b/plinth/templatetags/plinth_extras.py index 42bc2d252..541429b9c 100644 --- a/plinth/templatetags/plinth_extras.py +++ b/plinth/templatetags/plinth_extras.py @@ -67,3 +67,9 @@ def show_subsubmenu(context, menu): def clients_of_type(clients, client_type): """Filter and get clients of a particular type""" return clients_module.of_type(clients, client_type) + + +@register.filter(name='lookup') +def lookup(dictionary, key): + """Get the value in the dictionary at given key""" + return dictionary[key] diff --git a/plinth/utils.py b/plinth/utils.py index 24c1b1176..f77b300cc 100644 --- a/plinth/utils.py +++ b/plinth/utils.py @@ -76,7 +76,6 @@ def is_user_admin(request, cached=False): class YAMLFile(object): """A context management class for updating YAML files""" - def __init__(self, yaml_file): """Return a context object for the YAML file.