mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
ui: Refactor notification delete buttons to avoid repeating code
Tests: - Through code changes, ensure that dist upgrade notification, updated to new release notification, privacy notification, and app installed notification show up. Ensure that they have correct hx- attributes and URL property for dismiss button. Clicking dismiss button works as expected. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
parent
13a575017c
commit
e37d26abee
@ -41,11 +41,5 @@
|
||||
role="button" class="btn btn-primary">
|
||||
{% trans "Go to Distribution Update" %}
|
||||
</a>
|
||||
<a href="{% url 'notification_dismiss' id=id %}?next={{ request.path|iriencode }}"
|
||||
hx-get="{% url 'notification_dismiss' id=id %}"
|
||||
hx-target="#notification-{{ id }}"
|
||||
hx-swap="delete swap:300ms"
|
||||
role="button" class="btn btn-default">
|
||||
{% trans "Dismiss" %}
|
||||
</a>
|
||||
{% include 'notifications-dismiss-button.html' with id=id %}
|
||||
</p>
|
||||
|
||||
@ -17,11 +17,5 @@
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="{% url 'notification_dismiss' id=id %}?next={{ request.path|iriencode }}"
|
||||
hx-get="{% url 'notification_dismiss' id=id %}"
|
||||
hx-target="#notification-{{ id }}"
|
||||
hx-swap="delete swap:300ms"
|
||||
role="button" class="btn btn-default">
|
||||
{% trans "Dismiss" %}
|
||||
</a>
|
||||
{% include 'notifications-dismiss-button.html' with id=id %}
|
||||
</p>
|
||||
|
||||
12
plinth/templates/notifications-dismiss-button.html
Normal file
12
plinth/templates/notifications-dismiss-button.html
Normal file
@ -0,0 +1,12 @@
|
||||
{% comment %}
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
<a href="{% url 'notification_dismiss' id=id %}?next={{ request.path|iriencode }}"
|
||||
hx-get="{% url 'notification_dismiss' id=id %}"
|
||||
hx-target="#notification-{{ id }}" hx-swap="delete swap:300ms" role="button"
|
||||
class="btn btn-default">
|
||||
{% trans "Dismiss" %}
|
||||
</a>
|
||||
@ -54,13 +54,7 @@
|
||||
<div class="btn-toolbar">
|
||||
{% for action in note.actions %}
|
||||
{% if action.type == "dismiss" %}
|
||||
<a href="{% url 'notification_dismiss' id=note.id %}?next={{ request.path|iriencode }}"
|
||||
hx-get="{% url 'notification_dismiss' id=note.id %}"
|
||||
hx-target="#notification-{{ note.id }}"
|
||||
hx-swap="delete swap:300ms"
|
||||
role="button" class="btn btn-default">
|
||||
{% trans "Dismiss" %}
|
||||
</a>
|
||||
{% include 'notifications-dismiss-button.html' with id=note.id %}
|
||||
{% else %}
|
||||
<a href="{% url action.url %}" role="button"
|
||||
class="btn btn-{{ action.class|default:'default' }}">
|
||||
|
||||
@ -18,12 +18,6 @@
|
||||
|
||||
{% if data.state == "completed" %}
|
||||
<div class="btn-toolbar">
|
||||
<a href="{% url 'notification_dismiss' id=id %}?next={{ request.path|iriencode }}"
|
||||
hx-get="{% url 'notification_dismiss' id=id %}"
|
||||
hx-target="#notification-{{ id }}"
|
||||
hx-swap="delete swap:300ms"
|
||||
role="button" class="btn btn-default">
|
||||
{% trans "Dismiss" %}
|
||||
</a>
|
||||
{% include 'notifications-dismiss-button.html' with id=id %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user