app: Add a menu item to trigger uninstallation

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2022-08-18 22:18:22 -07:00 committed by James Valleroy
parent e1b4c2e52b
commit 8513c26855
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 15 additions and 2 deletions

View File

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

View File

@ -257,6 +257,7 @@ class AppView(FormView):
context['has_diagnostics'] = self.app.has_diagnostics()
context['port_forwarding_info'] = get_port_forwarding_info(self.app)
context['app_enable_disable_form'] = self.get_enable_disable_form()
context['show_uninstall'] = not self.app.info.is_essential
context['operations'] = operation.manager.filter(self.app.app_id)
context['refresh_page_sec'] = None
if context['operations']:
@ -278,6 +279,7 @@ class SetupView(TemplateView):
app_id = self.kwargs['app_id']
app = app_module.App.get(app_id)
context['app_id'] = app.app_id
context['app_info'] = app.info
# Report any installed conflicting packages that will be removed.
@ -287,8 +289,12 @@ class SetupView(TemplateView):
context['package_conflicts_action'] = package_conflicts_action
# Reuse the value of setup_state throughout the view for consistency.
context['setup_state'] = app.get_setup_state()
setup_state = app.get_setup_state()
context['setup_state'] = setup_state
context['operations'] = operation.manager.filter(app.app_id)
context['show_uninstall'] = (
not app.info.is_essential
and setup_state != app_module.App.SetupState.NEEDS_SETUP)
# Perform expensive operation only if needed.
if not context['operations']: