app: Add backup and restore menu items to toolbar menu

Closes: #2316.

Tests:

- Go to to power app. There is no menu.

- Go to firewall app. There is a menu item but no backup and restore items present.

- Go to bepasty app. There are backup and restore menu items in menu. Clicking
backup items takes us to create backup page with only Bepasty app selected.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
[jvalleroy: Fix CSS classes for new menu items]
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2023-02-09 08:43:29 -08:00 committed by James Valleroy
parent 8f2520b327
commit f1060fbf6b
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 19 additions and 1 deletions

View File

@ -21,7 +21,7 @@
</a>
{% endif %}
{% if has_diagnostics or show_uninstall %}
{% if has_diagnostics or show_uninstall or has_backup_restore %}
<!-- Single button -->
<div class="btn-group button-secondary">
<button type="button" class="btn btn-default dropdown-toggle"
@ -33,6 +33,18 @@
{% if has_diagnostics %}
{% include "diagnostics_button.html" with app_id=app_id enabled=is_enabled %}
{% endif %}
{% if has_backup_restore %}
<a class="dropdown-item backup-item"
href="{% url 'backups:create' app_id=app_id %}"
title="{% trans "Backup" %}">
{% trans "Backup" %}
</a>
<a class="dropdown-item restore-item"
href="{% url 'backups:index' %}"
title="{% trans "Restore" %}">
{% trans "Restore" %}
</a>
{% endif %}
{% if show_uninstall %}
<a class="dropdown-item uninstall-item"
href="{% url 'uninstall' app_id=app_id %}"

View File

@ -272,6 +272,12 @@ class AppView(FormView):
from plinth.modules.firewall.components import Firewall
context['firewall'] = self.app.get_components_of_type(Firewall)
from plinth.modules.backups.components import BackupRestore
context['has_backup_restore'] = any([
component.has_data
for component in self.app.get_components_of_type(BackupRestore)
])
return context