Sunil Mohan Adapa 1f98dfcad1
setup: Perform a check for app availability after the page loads
- Using AJAX request instead of loading the initial page slowly.

Tests:

- Unit tests passes.

- Deluge app is not available in bookworm and is available in Trixie.

- When app is available, no message is shown. Install button is enabled.

- When app is not available a proper warning alert message is shown. Install
button is disabled.

- During check for the availability, the progress message is shown. Install
button is disabled.

- When Javascript is disabled on the page, no availability check is performed.
Install button is enabled.

- When an exception is raised in the is-available view, error message is shown.
Install button is enabled.

- When is-available view return HTML response, error message is shown. Install
button is enabled.

- When is-available view invalid JSON response, error message is shown. Install
button is enabled.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-08-02 21:06:17 +05:30

100 lines
3.1 KiB
HTML

{% extends "base.html" %}
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
{% load static %}
{% block content %}
{% include "app-header.html" with setup=True %}
{% include "toolbar.html" %}
{% if setup_state.value == 'up-to-date' %}
<div class="app-just-installed">
{% trans "Application installed." %}
</div>
{% elif not operations %}
<p>
{% if setup_state.value == 'needs-setup' %}
{% blocktrans trimmed %}
Install this application?
{% endblocktrans %}
{% elif setup_state.value == 'needs-update' %}
{% blocktrans trimmed %}
This application needs an update. Update now?
{% endblocktrans %}
{% endif %}
</p>
<div class="app-unavailable d-none">
<div class="alert alert-warning d-flex align-items-center" role="alert">
<div class="me-2">
<span class="fa fa-exclamation-triangle" aria-hidden="true"></span>
<span class="visually-hidden">{% trans "Caution:" %}</span>
</div>
<div>
{% blocktrans trimmed %}
This application is currently not available in your distribution.
{% endblocktrans %}
</div>
</div>
</div>
<p class="app-checking-availability d-none" data-app-id="{{ app_id }}"
data-setup-state="{{ setup_state.value }}">
{% blocktrans trimmed %}
Checking app availability...
{% endblocktrans %}
<span class="spinner-border spinner-border-sm" role="status"></span>
</p>
<p class="app-checking-availability-error d-none">
{% blocktrans trimmed %}
Error checking app availability. Please refresh page.
{% endblocktrans %}
</p>
<form class="form-install" action="" method="post">
{% csrf_token %}
{% if has_unavailable_packages %}
{% elif package_conflicts and package_conflicts_action.value != 'ignore' %}
<div class="alert alert-warning d-flex align-items-center" role="alert">
<div class="me-2">
<span class="fa fa-exclamation-triangle" aria-hidden="true"></span>
<span class="visually-hidden">{% trans "Caution:" %}</span>
</div>
<div>
{% blocktrans trimmed %}
<strong>Conflicting Packages:</strong> Some packages installed on
the system conflict with the installation of this app. The following
packages will be removed if you proceed:
{% endblocktrans %}
{% for package in package_conflicts %}
{{ package }}
{% endfor %}
</div>
</div>
{% endif %}
<input type="submit" class="btn btn-md btn-primary install-button"
name="install"
{% if setup_state.value == 'needs-setup' %}
value="{% trans "Install" %}"
{% elif setup_state.value == 'needs-update' %}
value="{% trans "Update" %}"
{% endif %} />
</form>
{% else %}
{% include "operations.html" %}
{% endif %}
{% endblock %}