mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +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 %}
|
{% load static %}
|
||||||
|
|
||||||
{% block page_head %}
|
{% block page_head %}
|
||||||
{% if setup_helper.current_operation %}
|
{% if setup_current_operation or setup_state == 'up-to-date' %}
|
||||||
<noscript>
|
<noscript>
|
||||||
<meta http-equiv="refresh" content="3" />
|
<meta http-equiv="refresh" content="3" />
|
||||||
</noscript>
|
</noscript>
|
||||||
@ -48,14 +48,18 @@
|
|||||||
|
|
||||||
{% include "clients.html" with clients=setup_helper.module.clients %}
|
{% 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>
|
<p>
|
||||||
{% if setup_helper.get_state == 'needs-setup' %}
|
{% if setup_state == 'needs-setup' %}
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
Install this application?
|
Install this application?
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
{% elif setup_helper.get_state == 'needs-update' %}
|
{% elif setup_state == 'needs-update' %}
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
This application needs an update. Update now?
|
This application needs an update. Update now?
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
@ -87,27 +91,26 @@
|
|||||||
{% if package_manager_is_busy or setup_helper.has_unavailable_packages %}
|
{% if package_manager_is_busy or setup_helper.has_unavailable_packages %}
|
||||||
disabled="disabled"
|
disabled="disabled"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if setup_helper.get_state == 'needs-setup' %}
|
{% if setup_state == 'needs-setup' %}
|
||||||
value="{% trans "Install" %}"
|
value="{% trans "Install" %}"
|
||||||
{% elif setup_helper.get_state == 'needs-upgrade' %}
|
{% elif setup_state == 'needs-upgrade' %}
|
||||||
value="{% trans "Update" %}"
|
value="{% trans "Update" %}"
|
||||||
{% endif %} />
|
{% endif %} />
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
{% if setup_helper.current_operation.step == 'pre' %}
|
{% if setup_current_operation.step == 'pre' %}
|
||||||
<div class="install-state-pre">
|
<div class="install-state-pre">
|
||||||
{% trans "Performing pre-install operation" %}
|
{% trans "Performing pre-install operation" %}
|
||||||
</div>
|
</div>
|
||||||
{% elif setup_helper.current_operation.step == 'post' %}
|
{% elif setup_current_operation.step == 'post' %}
|
||||||
<div class="install-state-post">
|
<div class="install-state-post">
|
||||||
{% trans "Performing post-install operation" %}
|
{% trans "Performing post-install operation" %}
|
||||||
</div>
|
</div>
|
||||||
{% elif setup_helper.current_operation.step == 'install' %}
|
{% elif setup_current_operation.step == 'install' %}
|
||||||
{% with transaction=setup_helper.current_operation.transaction %}
|
{% with transaction=setup_current_operation.transaction %}
|
||||||
<div class="install-state-installing">
|
<div class="install-state-installing">
|
||||||
{% blocktrans trimmed with package_names=transaction.package_names|join:", " status=transaction.status_string %}
|
{% blocktrans trimmed with package_names=transaction.package_names|join:", " status=transaction.status_string %}
|
||||||
Installing {{ package_names }}: {{ status }}
|
Installing {{ package_names }}: {{ status }}
|
||||||
@ -135,7 +138,7 @@
|
|||||||
|
|
||||||
{% block page_js %}
|
{% 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>
|
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@ -177,7 +177,13 @@ class SetupView(TemplateView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
"""Return the context data rendering the template."""
|
"""Return the context data rendering the template."""
|
||||||
context = super(SetupView, self).get_context_data(**kwargs)
|
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()
|
context['package_manager_is_busy'] = package.is_package_manager_busy()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user