Add a "clear all" option to the user notifications dropdown #11592

Closed
opened 2025-12-29 21:47:18 +01:00 by adam · 6 comments
Owner

Originally created by @jeremystretch on GitHub (Sep 9, 2025).

Originally assigned to: @pheus on GitHub.

NetBox version

v4.4.0

Feature type

New functionality

Proposed functionality

Within the notifications dropdown next to the user menu at top right, add a link or button to bulk delete all notifications.

Use case

The bulk deletion functionality already exists under the "notifications" tab of the user view, however this requires several steps to complete. A "clear all" button within the menu itself provides a one-click option for clearing all notifications.

Database changes

N/A

External dependencies

N/A

Originally created by @jeremystretch on GitHub (Sep 9, 2025). Originally assigned to: @pheus on GitHub. ### NetBox version v4.4.0 ### Feature type New functionality ### Proposed functionality Within the notifications dropdown next to the user menu at top right, add a link or button to bulk delete all notifications. ### Use case The bulk deletion functionality already exists under the "notifications" tab of the user view, however this requires several steps to complete. A "clear all" button within the menu itself provides a one-click option for clearing all notifications. ### Database changes N/A ### External dependencies N/A
adam added the status: acceptedtype: featurenetboxcomplexity: low labels 2025-12-29 21:47:18 +01:00
adam closed this issue 2025-12-29 21:47:18 +01:00
Author
Owner

@ramonasuncion commented on GitHub (Sep 19, 2025):

I'll like to take on this issue.

@ramonasuncion commented on GitHub (Sep 19, 2025): I'll like to take on this issue.
Author
Owner

@pheus commented on GitHub (Oct 15, 2025):

Hi @ramonasuncion, I just noticed your earlier comment about taking this on (sorry I missed it). I don’t want to take the work from you. I’ve worked a prototype with two screenshots to show the UI. If you’re still planning to work on it, I’m happy to step back or collaborate; if you’re busy, I can open a PR and iterate based on feedback. Thanks!

Notification Menu:
Image

Confirmation Dialog (using Firefox/Mac):
Image

@pheus commented on GitHub (Oct 15, 2025): Hi @ramonasuncion, I just noticed your earlier comment about taking this on (sorry I missed it). I don’t want to take the work from you. I’ve worked a prototype with two screenshots to show the UI. If you’re still planning to work on it, I’m happy to step back or collaborate; if you’re busy, I can open a PR and iterate based on feedback. Thanks! **Notification Menu**: <img width="302" height="245" alt="Image" src="https://github.com/user-attachments/assets/53ad0b37-66d5-48c9-918e-567bd6b1ce41" /> **Confirmation Dialog** (using Firefox/Mac): <img width="372" height="128" alt="Image" src="https://github.com/user-attachments/assets/975c648c-d906-4e76-a9a4-47d3181c085a" />
Author
Owner

@ramonasuncion commented on GitHub (Oct 15, 2025):

You're fine! I ended up being too busy to work on it.

@ramonasuncion commented on GitHub (Oct 15, 2025): You're fine! I ended up being too busy to work on it.
Author
Owner

@pheus commented on GitHub (Oct 15, 2025):

Thanks for the handoff, @ramonasuncion!

I put together a "clear all" prototype and kept the dropdown wiring as GET to match the existing dismiss flow. Two implementation variants seem reasonable:

Variant 1: reuse NotificationDismissView with ?all=1

Add a small branch in the current dismiss view: when all=1 is present, delete all unread notifications for request.user; otherwise keep the existing single-item behavior. The benefit is minimal surface area and no new route. The only minor wart is passing a placeholder pk (e.g., pk=0) to satisfy the detail URL.

Variant 2: new NotificationDismissAllView (detail=False)

Register a dedicated model view at dismiss-all that clears unread notifications for request.user. This avoids the placeholder pk and makes the URL intent explicit at the cost of one tiny new route.

In both variants I:

  • Filter strictly by request.user and call .unread().delete() (the dropdown shows unread items).
  • Return the same HTMX partial (htmx/notifications.html) so the menu re-renders in place, with a regular redirect fallback to the notifications page.
  • Keep the anchor as hx-get with hx-target="closest .notifications" and an i18n'd confirm prompt.

Happy to open a PR with either approach. I slightly prefer Variant 2 for clarity, but I'm also fine with Variant 1 if you'd like to keep the URL surface as small as possible. If you'd rather "clear all" include read items as well, I can drop the .unread() filter.

@pheus commented on GitHub (Oct 15, 2025): Thanks for the handoff, @ramonasuncion! I put together a "clear all" prototype and kept the dropdown wiring as **GET** to match the existing dismiss flow. Two implementation variants seem reasonable: ### Variant 1: reuse `NotificationDismissView` with `?all=1` Add a small branch in the current dismiss view: when `all=1` is present, delete all **unread** notifications for `request.user`; otherwise keep the existing single-item behavior. The benefit is minimal surface area and no new route. The only minor wart is passing a placeholder `pk` (e.g., `pk=0`) to satisfy the detail URL. ### Variant 2: new `NotificationDismissAllView` (`detail=False`) Register a dedicated model view at `dismiss-all` that clears **unread** notifications for `request.user`. This avoids the placeholder `pk` and makes the URL intent explicit at the cost of one tiny new route. In both variants I: - Filter strictly by `request.user` and call `.unread().delete()` (the dropdown shows unread items). - Return the same HTMX partial (`htmx/notifications.html`) so the menu re-renders in place, with a regular redirect fallback to the notifications page. - Keep the anchor as `hx-get` with `hx-target="closest .notifications"` and an i18n'd confirm prompt. Happy to open a PR with either approach. I slightly prefer **Variant 2** for clarity, but I'm also fine with **Variant 1** if you'd like to keep the URL surface as small as possible. If you'd rather "clear all" include read items as well, I can drop the `.unread()` filter.
Author
Owner

@jeremystretch commented on GitHub (Oct 16, 2025):

Thanks @pheus! I think I also have a slight preference for variant 2. Assigning this to you.

@jeremystretch commented on GitHub (Oct 16, 2025): Thanks @pheus! I think I also have a slight preference for variant 2. Assigning this to you.
Author
Owner

@pheus commented on GitHub (Oct 17, 2025):

Thanks!

I’ve completed the Django side for Variant 2 (GET-based dismiss-all) and did a pass on the dropdown UI to keep the action discoverable without adding noise. Screenshots below.

UX notes

  • Only shown when needed: “Clear all” appears only when there are unread items, as a button.
  • Consistent look & feel: Uses the existing mdi-delete-sweep-outline icon and an i18n’d confirm prompt: “Clear all unread notifications?”
  • No full reload: The link issues a GET to extras:notification_dismiss_all and re-renders the dropdown via the existing htmx/notifications.html partial.

Screenshots (notifications present)

Dropdown with unread notifications and a 'Clear all' action at the bottom Confirm prompt: 'Clear all unread notifications?'

Screenshots (no notifications)

Dropdown empty state with no 'Clear all' action shown Dropdown empty state hover/interaction example

Open to any tweaks on copy (“Clear all” vs “Clear all unread”), icon placement, or spacing. If this direction looks good, I can open a PR with the implementation so it’s easy to try out.

@pheus commented on GitHub (Oct 17, 2025): Thanks! I’ve completed the Django side for **Variant 2** (GET-based `dismiss-all`) and did a pass on the dropdown UI to keep the action discoverable without adding noise. Screenshots below. **UX notes** - **Only shown when needed:** “Clear all” appears only when there are unread items, as a button. - **Consistent look & feel:** Uses the existing `mdi-delete-sweep-outline` icon and an i18n’d confirm prompt: _“Clear all unread notifications?”_ - **No full reload:** The link issues a GET to `extras:notification_dismiss_all` and re-renders the dropdown via the existing `htmx/notifications.html` partial. **Screenshots (notifications present)** <img width="302" height="193" alt="Dropdown with unread notifications and a 'Clear all' action at the bottom" src="https://github.com/user-attachments/assets/38734d8a-ddac-4b78-9a3d-d1daadd0f28d" /> <img width="302" height="193" alt="Confirm prompt: 'Clear all unread notifications?'" src="https://github.com/user-attachments/assets/da16c160-594f-42dd-af4e-22ee3ce70243" /> **Screenshots (no notifications)** <img width="302" height="78" alt="Dropdown empty state with no 'Clear all' action shown" src="https://github.com/user-attachments/assets/f0c45fa7-20fc-4a64-bacb-3635fdbf936e" /> <img width="302" height="78" alt="Dropdown empty state hover/interaction example" src="https://github.com/user-attachments/assets/410fe62b-3909-46a2-97f3-20b6fe964ba0" /> Open to any tweaks on copy (“Clear all” vs “Clear all unread”), icon placement, or spacing. If this direction looks good, I can open a PR with the implementation so it’s easy to try out.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11592