From e37d26abeea0dedf24737a7333460ded769a39a3 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 3 Feb 2026 14:18:00 -0800 Subject: [PATCH] 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 Reviewed-by: Joseph Nuthalapati --- .../upgrades-dist-upgrade-notification.html | 8 +------- .../upgrades/templates/upgrades-new-release.html | 8 +------- plinth/templates/notifications-dismiss-button.html | 12 ++++++++++++ plinth/templates/notifications.html | 8 +------- plinth/templates/operation-notification.html | 8 +------- 5 files changed, 16 insertions(+), 28 deletions(-) create mode 100644 plinth/templates/notifications-dismiss-button.html diff --git a/plinth/modules/upgrades/templates/upgrades-dist-upgrade-notification.html b/plinth/modules/upgrades/templates/upgrades-dist-upgrade-notification.html index 0cd66fd3e..6073e1e78 100644 --- a/plinth/modules/upgrades/templates/upgrades-dist-upgrade-notification.html +++ b/plinth/modules/upgrades/templates/upgrades-dist-upgrade-notification.html @@ -41,11 +41,5 @@ role="button" class="btn btn-primary"> {% trans "Go to Distribution Update" %} - - {% trans "Dismiss" %} - + {% include 'notifications-dismiss-button.html' with id=id %}

diff --git a/plinth/modules/upgrades/templates/upgrades-new-release.html b/plinth/modules/upgrades/templates/upgrades-new-release.html index 1cc1b7812..d0a24f524 100644 --- a/plinth/modules/upgrades/templates/upgrades-new-release.html +++ b/plinth/modules/upgrades/templates/upgrades-new-release.html @@ -17,11 +17,5 @@

- - {% trans "Dismiss" %} - + {% include 'notifications-dismiss-button.html' with id=id %}

diff --git a/plinth/templates/notifications-dismiss-button.html b/plinth/templates/notifications-dismiss-button.html new file mode 100644 index 000000000..8b914cdb9 --- /dev/null +++ b/plinth/templates/notifications-dismiss-button.html @@ -0,0 +1,12 @@ +{% comment %} +# SPDX-License-Identifier: AGPL-3.0-or-later +{% endcomment %} + +{% load i18n %} + + + {% trans "Dismiss" %} + diff --git a/plinth/templates/notifications.html b/plinth/templates/notifications.html index 0afd6e549..1880cbb61 100644 --- a/plinth/templates/notifications.html +++ b/plinth/templates/notifications.html @@ -54,13 +54,7 @@