From 553b1a41428ce2627afa55210761884eb1d6a176 Mon Sep 17 00:00:00 2001 From: Juan Denis Date: Mon, 9 Nov 2026 06:20:49 -0500 Subject: [PATCH] feat(ui): show active Notifications filters with clear Reset --- frontend/src/i18n/locales/en.json | 5 ++ frontend/src/pages/Notifications.jsx | 62 +++++++++++++++---- .../styles/pages/_notification-center.scss | 42 ++++++++++++- 3 files changed, 97 insertions(+), 12 deletions(-) diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index b43f6252..926d83c1 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -4159,9 +4159,12 @@ "any": "Any", "apps": "Services", "category": "Category", + "clear": "Clear", + "clearFilters": "Clear filters", "critical": "Critical", "deliveryLog": "Delivery log", "dismiss": "Dismiss {{title}}", + "done": "Done", "filterByCategory": "Filter by category", "filterBySeverity": "Filter by severity", "filterNotifications": "Filter notifications", @@ -4169,9 +4172,11 @@ "loadMore": "Load more", "markAllRead": "Mark all read", "markCategoryRead": "Mark {{category}} read", + "noMatching": "No matching notifications.", "noNotificationsYet": "No notifications yet.", "noUnreadNotifications": "No unread notifications.", "notifications": "Notifications", + "removeFilter": "Remove filter {{label}}", "reset": "Reset", "success": "Success", "unread": "Unread", diff --git a/frontend/src/pages/Notifications.jsx b/frontend/src/pages/Notifications.jsx index 1e16f004..3c41b2c3 100644 --- a/frontend/src/pages/Notifications.jsx +++ b/frontend/src/pages/Notifications.jsx @@ -1,6 +1,6 @@ import { useState, useEffect, useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; -import { Bell, CheckCheck, Filter, ScrollText, X } from 'lucide-react'; +import { Bell, CheckCheck, Filter, RotateCcw, ScrollText, X } from 'lucide-react'; import api from '../services/api'; import PageLayout from '../layouts/PageLayout'; import { Button } from '@/components/ui/button'; @@ -8,7 +8,7 @@ import { useAuth } from '../contexts/useAuth.js'; import { useNotifications } from '../contexts/useNotifications.js'; import { timeAgo } from '../utils/time'; import { useTranslation } from 'react-i18next'; -import { Sheet, SheetTrigger, SheetContent, SheetTitle } from '@/components/ui/sheet'; +import { Sheet, SheetTrigger, SheetClose, SheetContent, SheetTitle } from '@/components/ui/sheet'; import useMediaQuery from '../hooks/useMediaQuery'; const SEVERITY_DOT = { @@ -48,9 +48,15 @@ export default function Notifications() { const [unreadCount, setUnreadCount] = useState(0); const [loading, setLoading] = useState(true); const [hasMore, setHasMore] = useState(false); - const compact = useMediaQuery('(max-width: 1219px)'); + const compact = useMediaQuery('(max-width: 1359px)'); const activeFilters = (category ? 1 : 0) + (severity ? 1 : 0); + const clearFilters = () => { setCategory(''); setSeverity(''); }; + const activePills = [ + category && { key: 'category', set: setCategory, ...CATEGORY_CHIPS.find((c) => c.key === category) }, + severity && { key: 'severity', set: setSeverity, ...SEVERITY_CHIPS.find((c) => c.key === severity) }, + ].filter(Boolean); + const fetchPage = useCallback(async (startOffset, replace) => { setLoading(true); try { @@ -127,6 +133,16 @@ export default function Notifications() { // surface here too, above the bus history. const noticeItems = (ctxItems || []).filter((it) => it.kind === 'notice'); + const emptyState = ( +
0 ? ' sk-notif-page__state--compact' : ''}`}> +
+ ); + return ( } @@ -170,7 +186,7 @@ export default function Notifications() { {compact ? ( - @@ -182,24 +198,46 @@ export default function Notifications() { {categoryChips} {t('common.labels.severity', 'Severity')} {severityChips} - + + + ) : ( -
{chipsets}
+
+ {chipsets} + {activeFilters > 0 && ( + + )} +
+ )} + {compact && activePills.length > 0 && ( +
+ {activePills.map((p) => { + const { label } = p; + return ( + + ); + })} +
)} {loading && items.length === 0 && noticeItems.length === 0 ? (
{t('common.loading', 'Loading…')}
) : items.length === 0 && noticeItems.length === 0 ? ( -
-
+ emptyState ) : ( )} + {!loading && items.length === 0 && noticeItems.length > 0 && activeFilters > 0 && emptyState} + {hasMore && !loading && (