mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
setup: Handle showing setup page after app completes installation
- During the rendering of the view, the state of installation may keep changing. This may lead to inconsistencies in the page. Avoid that by collecting the state once and then reusing that throughout the rendering process. - During the time that setup middleware's checked of setup state of an app and rendering of app's setup view, if the setup process could get completed. This will lead to setup page being shown even after the application is installed. Handle this case and show a proper page instead of 'Submit Query' button on the page. Fixes #1360. This can be easily replicated by introducing a 10 second sleep after setup middle checks of the application is 'up-to-date'. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
1faee11d4d
commit
de82f5002d
@ -23,7 +23,7 @@
|
||||
{% load static %}
|
||||
|
||||
{% block page_head %}
|
||||
{% if setup_helper.current_operation %}
|
||||
{% if setup_current_operation or setup_state == 'up-to-date' %}
|
||||
<noscript>
|
||||
<meta http-equiv="refresh" content="3" />
|
||||
</noscript>
|
||||
@ -48,14 +48,18 @@
|
||||
|
||||
{% include "clients.html" with clients=setup_helper.module.clients %}
|
||||
|
||||
{% if not setup_helper.current_operation %}
|
||||
{% if setup_state == 'up-to-date' %}
|
||||
|
||||
{% trans "Application installated." %}
|
||||
|
||||
{% elif not setup_current_operation %}
|
||||
|
||||
<p>
|
||||
{% if setup_helper.get_state == 'needs-setup' %}
|
||||
{% if setup_state == 'needs-setup' %}
|
||||
{% blocktrans trimmed %}
|
||||
Install this application?
|
||||
{% endblocktrans %}
|
||||
{% elif setup_helper.get_state == 'needs-update' %}
|
||||
{% elif setup_state == 'needs-update' %}
|
||||
{% blocktrans trimmed %}
|
||||
This application needs an update. Update now?
|
||||
{% endblocktrans %}
|
||||
@ -87,27 +91,26 @@
|
||||
{% if package_manager_is_busy or setup_helper.has_unavailable_packages %}
|
||||
disabled="disabled"
|
||||
{% endif %}
|
||||
{% if setup_helper.get_state == 'needs-setup' %}
|
||||
{% if setup_state == 'needs-setup' %}
|
||||
value="{% trans "Install" %}"
|
||||
{% elif setup_helper.get_state == 'needs-upgrade' %}
|
||||
{% elif setup_state == 'needs-upgrade' %}
|
||||
value="{% trans "Update" %}"
|
||||
{% endif %} />
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
{% else %}
|
||||
|
||||
{% if setup_helper.current_operation.step == 'pre' %}
|
||||
{% if setup_current_operation.step == 'pre' %}
|
||||
<div class="install-state-pre">
|
||||
{% trans "Performing pre-install operation" %}
|
||||
</div>
|
||||
{% elif setup_helper.current_operation.step == 'post' %}
|
||||
{% elif setup_current_operation.step == 'post' %}
|
||||
<div class="install-state-post">
|
||||
{% trans "Performing post-install operation" %}
|
||||
</div>
|
||||
{% elif setup_helper.current_operation.step == 'install' %}
|
||||
{% with transaction=setup_helper.current_operation.transaction %}
|
||||
{% elif setup_current_operation.step == 'install' %}
|
||||
{% with transaction=setup_current_operation.transaction %}
|
||||
<div class="install-state-installing">
|
||||
{% blocktrans trimmed with package_names=transaction.package_names|join:", " status=transaction.status_string %}
|
||||
Installing {{ package_names }}: {{ status }}
|
||||
@ -135,7 +138,7 @@
|
||||
|
||||
{% block page_js %}
|
||||
|
||||
{% if setup_helper.current_operation %}
|
||||
{% if setup_current_operation or setup_state == 'up-to-date' %}
|
||||
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
|
||||
{% endif %}
|
||||
|
||||
|
||||
@ -177,7 +177,13 @@ class SetupView(TemplateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Return the context data rendering the template."""
|
||||
context = super(SetupView, self).get_context_data(**kwargs)
|
||||
context['setup_helper'] = self.kwargs['setup_helper']
|
||||
setup_helper = self.kwargs['setup_helper']
|
||||
context['setup_helper'] = setup_helper
|
||||
|
||||
# Reuse the value of setup_state throughout the view for consistency.
|
||||
context['setup_state'] = setup_helper.get_state()
|
||||
context['setup_current_operation'] = setup_helper.current_operation
|
||||
|
||||
context['package_manager_is_busy'] = package.is_package_manager_busy()
|
||||
return context
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user