Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

feat(frontend): notification center, delivery log, email providers

Juan Denisa33b2f7f38a6
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 3f1f58b7..e7d9de0d 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -5,6 +5,7 @@ import { ToastProvider } from './contexts/ToastContext';
import { ThemeProvider } from './contexts/ThemeContext';
import { LayoutProvider } from './contexts/LayoutContext';
import { ResourceTierProvider } from './contexts/ResourceTierContext';
+import { NotificationsProvider } from './contexts/NotificationsContext';
import { Toaster } from './components/ui/sonner';
import DashboardLayout from './layouts/DashboardLayout';
import Dashboard from './pages/Dashboard';
@@ -70,6 +71,8 @@ import Deployments from './pages/Deployments';
import GpuMonitor from './pages/GpuMonitor';
import DynamicDns from './pages/DynamicDns';
import QueueOperations from './pages/QueueOperations';
+import Notifications from './pages/Notifications';
+import DeliveryLog from './pages/DeliveryLog';
import useExtensionRoutes from './plugins/ExtensionRoutes';
import { useContributions } from './plugins/contributions';
@@ -121,6 +124,8 @@ const PAGE_TITLES = {
'/gpu': 'GPU Monitor',
'/dynamic-dns': 'Dynamic DNS',
'/queue': 'Queue Bus',
+ '/notifications': 'Notifications',
+ '/admin/notifications': 'Notification Delivery Log',
};
function PageTitleUpdater() {
@@ -357,6 +362,8 @@ function AppRoutes() {
<Route path="secrets" element={<SecretsWebhooks />} />
<Route path="secrets/:tab" element={<SecretsWebhooks />} />
<Route path="queue" element={<QueueOperations />} />
+ <Route path="notifications" element={<Notifications />} />
+ <Route path="admin/notifications" element={<DeliveryLog />} />
<Route path="settings" element={<Settings />} />
<Route path="settings/:tab" element={<Settings />} />
{dashboardRoutes}
@@ -374,7 +381,9 @@ function App() {
<AuthProvider>
<ResourceTierProvider>
<ToastProvider>
- <AppRoutes />
+ <NotificationsProvider>
+ <AppRoutes />
+ </NotificationsProvider>
<Toaster />
</ToastProvider>
</ResourceTierProvider>
diff --git a/frontend/src/components/EmailProviders.jsx b/frontend/src/components/EmailProviders.jsx
new file mode 100644
index 00000000..69a952be
--- /dev/null
+++ b/frontend/src/components/EmailProviders.jsx
@@ -0,0 +1,210 @@
+import { useState, useEffect, useCallback } from 'react';
+import { Mail, Plus, Trash2, Check, Star } from 'lucide-react';
+import api from '../services/api';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { useToast } from '../contexts/ToastContext';
+
+const FIELD_LABELS = {
+ host: 'Host', port: 'Port', username: 'Username', password: 'Password', use_tls: 'Use TLS',
+ api_key: 'API key', server_token: 'Server token', access_key: 'Access key ID',
+ secret_key: 'Secret access key', region: 'Region', domain: 'Domain',
+};
+
+function Field({ label, children }) {
+ return (
+ <div className="sk-eprov__field">
+ <Label>{label}</Label>
+ {children}
+ </div>
+ );
+}
+
+export default function EmailProviders() {
+ const toast = useToast();
+ const [providers, setProviders] = useState([]);
+ const [supported, setSupported] = useState({});
+ const [loading, setLoading] = useState(true);
+ const [type, setType] = useState('');
+ const [form, setForm] = useState({});
+ const [busy, setBusy] = useState(false);
+ const [confirmId, setConfirmId] = useState(null);
+
+ const load = useCallback(async () => {
+ try {
+ const data = await api.getEmailProviders();
+ setProviders(data.providers || []);
+ setSupported(data.supported || {});
+ } catch {
+ // leave state as-is
+ } finally {
+ setLoading(false);
+ }
+ }, []);
+
+ useEffect(() => { load(); }, [load]);
+
+ const spec = supported[type];
+ const adding = Boolean(type);
+
+ const startAdd = (key) => { setType(key); setForm({ from_name: 'ServerKit', use_tls: true }); };
+ const cancel = () => { setType(''); setForm({}); };
+ const onField = (key, value) => setForm((f) => ({ ...f, [key]: value }));
+
+ const submit = async () => {
+ setBusy(true);
+ try {
+ const payload = {
+ provider: type,
+ name: form.name || spec.name,
+ from_address: form.from_address,
+ from_name: form.from_name,
+ };
+ (spec.fields || []).forEach((f) => { if (form[f] !== undefined) payload[f] = form[f]; });
+ const res = await api.addEmailProvider(payload);
+ if (res?.test && res.test.success === false) {
+ toast.warning(`Added, but test failed: ${res.test.error || 'check credentials'}`);
+ } else {
+ toast.success('Email provider added');
+ }
+ cancel();
+ load();
+ } catch (e) {
+ toast.error(e?.message || 'Failed to add provider');
+ } finally {
+ setBusy(false);
+ }
+ };
+
+ const onTest = async (id) => {
+ setBusy(true);
+ try {
+ const r = await api.testEmailProvider(id);
+ if (r.success) toast.success('Credentials OK'); else toast.error(r.error || 'Test failed');
+ load();
+ } catch {
+ toast.error('Test failed');
+ } finally {
+ setBusy(false);
+ }
+ };
+
+ const onDefault = async (id) => {
+ try { await api.setDefaultEmailProvider(id); toast.success('Default transport updated'); load(); }
+ catch { toast.error('Failed to set default'); }
+ };
+
+ const onDelete = async (id) => {
+ try { await api.deleteEmailProvider(id); toast.success('Provider removed'); setConfirmId(null); load(); }
+ catch { toast.error('Failed to remove'); }
+ };
+
+ return (
+ <section className="sk-eprov">
+ <header className="sk-eprov__head">
+ <span className="sk-eprov__title"><Mail size={16} /> Email transport</span>
+ <span className="sk-eprov__sub">How notification emails are sent</span>
+ </header>
+
+ {loading ? (
+ <div className="sk-eprov__empty">Loading…</div>
+ ) : (
+ <>
+ {providers.length === 0 ? (
+ <div className="sk-eprov__empty">
+ No provider configured — emails fall back to the SMTP channel settings.
+ </div>
+ ) : (
+ <ul className="sk-eprov__list">
+ {providers.map((p) => (
+ <li key={p.id} className="sk-eprov__item">
+ <div className="sk-eprov__meta">
+ <span className="sk-eprov__name">
+ {p.name}
+ {p.is_default && <span className="sk-eprov__badge">Default</span>}
+ </span>
+ <span className="sk-eprov__type">
+ {p.provider}
+ {p.from_address ? ` · ${p.from_address}` : ''}
+ {p.last_test_ok === true ? ' · ✓ tested' : ''}
+ {p.last_test_ok === false ? ' · ✗ test failed' : ''}
+ </span>
+ </div>
+ <div className="sk-eprov__actions">
+ {!p.is_default && (
+ <Button variant="ghost" size="sm" onClick={() => onDefault(p.id)}>
+ <Star size={14} /> Default
+ </Button>
+ )}
+ <Button variant="ghost" size="sm" disabled={busy} onClick={() => onTest(p.id)}>
+ <Check size={14} /> Test
+ </Button>
+ {confirmId === p.id ? (
+ <Button variant="destructive" size="sm" onClick={() => onDelete(p.id)}>Confirm</Button>
+ ) : (
+ <Button variant="ghost" size="sm" onClick={() => setConfirmId(p.id)} aria-label="Remove">
+ <Trash2 size={14} />
+ </Button>
+ )}
+ </div>
+ </li>
+ ))}
+ </ul>
+ )}
+
+ {!adding ? (
+ <div className="sk-eprov__add">
+ {Object.entries(supported).map(([key, s]) => (
+ <Button key={key} variant="outline" size="sm" onClick={() => startAdd(key)}>
+ <Plus size={14} /> {s.name}
+ </Button>
+ ))}
+ </div>
+ ) : (
+ <div className="sk-eprov__form">
+ <div className="sk-eprov__form-title">Add {spec?.name}</div>
+ <div className="sk-eprov__grid">
+ <Field label="Display name">
+ <Input value={form.name || ''} onChange={(e) => onField('name', e.target.value)} placeholder={spec?.name} />
+ </Field>
+ <Field label="From address">
+ <Input value={form.from_address || ''} onChange={(e) => onField('from_address', e.target.value)} placeholder="[email protected]" />
+ </Field>
+ <Field label="From name">
+ <Input value={form.from_name || ''} onChange={(e) => onField('from_name', e.target.value)} />
+ </Field>
+ {(spec?.fields || []).map((f) => (
+ f === 'use_tls' ? (
+ <Field key={f} label={FIELD_LABELS[f] || f}>
+ <label className="sk-eprov__check">
+ <input
+ type="checkbox"
+ checked={form.use_tls !== false}
+ onChange={(e) => onField('use_tls', e.target.checked)}
+ />
+ STARTTLS
+ </label>
+ </Field>
+ ) : (
+ <Field key={f} label={FIELD_LABELS[f] || f}>
+ <Input
+ type={spec.secrets.includes(f) ? 'password' : (f === 'port' ? 'number' : 'text')}
+ value={form[f] || ''}
+ onChange={(e) => onField(f, e.target.value)}
+ />
+ </Field>
+ )
+ ))}
+ </div>
+ <div className="sk-eprov__form-actions">
+ <Button variant="outline" size="sm" onClick={cancel} disabled={busy}>Cancel</Button>
+ <Button size="sm" onClick={submit} disabled={busy}>{busy ? 'Adding…' : 'Add & test'}</Button>
+ </div>
+ </div>
+ )}
+ </>
+ )}
+ </section>
+ );
+}
diff --git a/frontend/src/components/MobileTopBar.jsx b/frontend/src/components/MobileTopBar.jsx
index 91763888..e2a05f46 100644
--- a/frontend/src/components/MobileTopBar.jsx
+++ b/frontend/src/components/MobileTopBar.jsx
@@ -1,6 +1,7 @@
import { Menu, X } from 'lucide-react';
import { useTheme } from '../contexts/ThemeContext';
import ServerKitLogo from './ServerKitLogo';
+import NotificationBell from './NotificationBell';
// Fixed header shown only on narrow viewports (< 768px). Houses the
// hamburger toggle that opens the sidebar as an off-canvas drawer, since
@@ -36,6 +37,9 @@ const MobileTopBar = ({ navOpen, onToggle }) => {
)}
<span className="mobile-topbar__name">{brandName}</span>
</div>
+ <div className="mobile-topbar__actions">
+ <NotificationBell />
+ </div>
</header>
);
};
diff --git a/frontend/src/components/NotificationBell.jsx b/frontend/src/components/NotificationBell.jsx
new file mode 100644
index 00000000..14c1cb3d
--- /dev/null
+++ b/frontend/src/components/NotificationBell.jsx
@@ -0,0 +1,115 @@
+import { useState, useRef, useEffect } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { Bell, Check } from 'lucide-react';
+import { useNotifications } from '../contexts/NotificationsContext';
+import { timeAgo } from '../utils/timeAgo';
+
+// Severity → dot color, mirroring the email/brand palette.
+const SEVERITY_DOT = {
+ critical: '#fb6f6f',
+ warning: '#f5b945',
+ success: '#3ddc97',
+ info: '#6d7cff',
+ test: '#9aa1b2',
+};
+
+export default function NotificationBell() {
+ const ctx = useNotifications();
+ const [open, setOpen] = useState(false);
+ const ref = useRef(null);
+ const navigate = useNavigate();
+
+ // The provider is only mounted for authenticated users; render nothing otherwise.
+ const { items = [], unreadCount = 0, markRead, markAllRead, refresh } = ctx || {};
+
+ useEffect(() => {
+ if (!open) return undefined;
+ const onDocClick = (e) => {
+ if (ref.current && !ref.current.contains(e.target)) setOpen(false);
+ };
+ const onEsc = (e) => { if (e.key === 'Escape') setOpen(false); };
+ document.addEventListener('mousedown', onDocClick);
+ document.addEventListener('keydown', onEsc);
+ return () => {
+ document.removeEventListener('mousedown', onDocClick);
+ document.removeEventListener('keydown', onEsc);
+ };
+ }, [open]);
+
+ if (!ctx) return null;
+
+ const toggle = () => {
+ const next = !open;
+ setOpen(next);
+ if (next && refresh) refresh();
+ };
+
+ const onItemClick = (item) => {
+ if (!item.read && markRead) markRead(item.delivery_id);
+ };
+
+ const badge = unreadCount > 99 ? '99+' : unreadCount;
+
+ return (
+ <div className="sk-notif" ref={ref}>
+ <button
+ type="button"
+ className="sk-notif__bell"
+ onClick={toggle}
+ aria-label={unreadCount ? `Notifications, ${unreadCount} unread` : 'Notifications'}
+ aria-haspopup="true"
+ aria-expanded={open}
+ >
+ <Bell size={16} aria-hidden="true" />
+ {unreadCount > 0 && <span className="sk-notif__badge">{badge}</span>}
+ </button>
+
+ {open && (
+ <div className="sk-notif__panel" role="menu" aria-label="Notifications">
+ <div className="sk-notif__head">
+ <span className="sk-notif__heading">Notifications</span>
+ {unreadCount > 0 && (
+ <button type="button" className="sk-notif__markall" onClick={markAllRead}>
+ <Check size={13} aria-hidden="true" /> Mark all read
+ </button>
+ )}
+ </div>
+
+ <div className="sk-notif__list">
+ {items.length === 0 ? (
+ <div className="sk-notif__empty">You&rsquo;re all caught up.</div>
+ ) : (
+ items.map((item) => (
+ <button
+ key={item.delivery_id}
+ type="button"
+ className={`sk-notif__item${item.read ? '' : ' is-unread'}`}
+ onClick={() => onItemClick(item)}
+ >
+ <span
+ className="sk-notif__dot"
+ style={{ background: SEVERITY_DOT[item.severity] || SEVERITY_DOT.info }}
+ aria-hidden="true"
+ />
+ <span className="sk-notif__content">
+ <span className="sk-notif__title">{item.title}</span>
+ {item.body && <span className="sk-notif__text">{item.body}</span>}
+ <span className="sk-notif__time">{timeAgo(item.created_at)}</span>
+ </span>
+ </button>
+ ))
+ )}
+ </div>
+
+ <button
+ type="button"
+ className="sk-notif__seeall"
+ onClick={() => { setOpen(false); navigate('/notifications'); }}
+ >
+ See all notifications
+ </button>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsx
index fdd471b1..3c159134 100644
--- a/frontend/src/components/Sidebar.jsx
+++ b/frontend/src/components/Sidebar.jsx
@@ -6,6 +6,7 @@ import { useLayout } from '../contexts/LayoutContext';
import { Star, Settings, LogOut, Sun, Moon, Monitor, ChevronRight, ChevronDown, ChevronUp, Layers, Palette, PanelLeft, PanelLeftClose, PanelTop, Check, X, Server } from 'lucide-react';
import { api } from '../services/api';
import WorkspaceSwitcher from './WorkspaceSwitcher';
+import NotificationBell from './NotificationBell';
import { SIDEBAR_CATEGORIES, CATEGORY_LABELS, SIDEBAR_PRESETS, getHiddenItemIds, getVisibleItems, applyWorkspaceNavPermissions } from './sidebarItems';
import { useContributions } from '../plugins/contributions';
@@ -493,6 +494,9 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
</button>
</div>
)}
+ <div className="sidebar-footer__row">
+ <NotificationBell />
+ </div>
<button
type="button"
className="user-mini"
diff --git a/frontend/src/contexts/NotificationsContext.jsx b/frontend/src/contexts/NotificationsContext.jsx
new file mode 100644
index 00000000..c8847032
--- /dev/null
+++ b/frontend/src/contexts/NotificationsContext.jsx
@@ -0,0 +1,83 @@
+import { createContext, useContext, useState, useEffect, useCallback } from 'react';
+import api from '../services/api';
+import socketService from '../services/socket';
+import { useAuth } from './AuthContext';
+
+// Global in-app notification state: the bell's unread badge + recent list, kept
+// live via the Socket.IO 'notification' push (see services/socket.js). The full
+// history page paginates independently; this context holds only the recent slice.
+const NotificationsContext = createContext(null);
+
+const RECENT_LIMIT = 12;
+const MAX_BUFFERED = 30;
+
+export function useNotifications() {
+ return useContext(NotificationsContext);
+}
+
+export function NotificationsProvider({ children }) {
+ const { isAuthenticated } = useAuth();
+ const [items, setItems] = useState([]);
+ const [unreadCount, setUnreadCount] = useState(0);
+ const [loading, setLoading] = useState(false);
+
+ const refresh = useCallback(async () => {
+ if (!isAuthenticated) return;
+ setLoading(true);
+ try {
+ const data = await api.getInbox({ limit: RECENT_LIMIT });
+ setItems(data.items || []);
+ setUnreadCount(data.unread_count || 0);
+ } catch {
+ // Non-fatal: the bell just stays at its last known state.
+ } finally {
+ setLoading(false);
+ }
+ }, [isAuthenticated]);
+
+ useEffect(() => {
+ if (!isAuthenticated) {
+ setItems([]);
+ setUnreadCount(0);
+ return undefined;
+ }
+ refresh();
+ socketService.connect();
+ const off = socketService.on('notification', (n) => {
+ setItems((prev) => [{ ...n, read: false }, ...prev].slice(0, MAX_BUFFERED));
+ setUnreadCount((count) => count + 1);
+ });
+ return off;
+ }, [isAuthenticated, refresh]);
+
+ const markRead = useCallback(async (deliveryId) => {
+ setItems((prev) => prev.map((it) => (
+ it.delivery_id === deliveryId ? { ...it, read: true } : it
+ )));
+ try {
+ const res = await api.markNotificationRead(deliveryId);
+ if (res && typeof res.unread_count === 'number') setUnreadCount(res.unread_count);
+ } catch {
+ // ignore — the next refresh reconciles
+ }
+ }, []);
+
+ const markAllRead = useCallback(async () => {
+ setItems((prev) => prev.map((it) => ({ ...it, read: true })));
+ setUnreadCount(0);
+ try {
+ await api.markAllNotificationsRead();
+ } catch {
+ // ignore — the next refresh reconciles
+ }
+ }, []);
+
+ const value = { items, unreadCount, loading, refresh, markRead, markAllRead };
+ return (
+ <NotificationsContext.Provider value={value}>
+ {children}
+ </NotificationsContext.Provider>
+ );
+}
+
+export default NotificationsContext;
diff --git a/frontend/src/pages/DeliveryLog.jsx b/frontend/src/pages/DeliveryLog.jsx
new file mode 100644
index 00000000..65d3103c
--- /dev/null
+++ b/frontend/src/pages/DeliveryLog.jsx
@@ -0,0 +1,153 @@
+import { useState, useEffect, useCallback, useRef } from 'react';
+import { Send, RefreshCw, Inbox } from 'lucide-react';
+import api from '../services/api';
+import { PageTopbar, MetricCard } from '@/components/ds';
+import { Button } from '@/components/ui/button';
+import { useAuth } from '../contexts/AuthContext';
+import { useToast } from '../contexts/ToastContext';
+import { timeAgo } from '../utils/timeAgo';
+import EmailProviders from '../components/EmailProviders';
+
+const STATUSES = ['all', 'pending', 'sent', 'failed', 'skipped'];
+const CHANNELS = ['all', 'inapp', 'email', 'discord', 'slack', 'telegram', 'webhook'];
+const POLL_MS = 5000;
+
+export default function DeliveryLog() {
+ const { isAdmin } = useAuth();
+ const toast = useToast();
+ const [deliveries, setDeliveries] = useState([]);
+ const [stats, setStats] = useState(null);
+ const [status, setStatus] = useState('all');
+ const [channel, setChannel] = useState('all');
+ const [loading, setLoading] = useState(true);
+ const pollRef = useRef(null);
+
+ const load = useCallback(async () => {
+ try {
+ const params = {};
+ if (status !== 'all') params.status = status;
+ if (channel !== 'all') params.channel = channel;
+ const data = await api.getDeliveryLog(params);
+ setDeliveries(data.deliveries || []);
+ setStats(data.stats || null);
+ } catch {
+ // leave the last good state on screen
+ } finally {
+ setLoading(false);
+ }
+ }, [status, channel]);
+
+ useEffect(() => {
+ if (!isAdmin) return undefined;
+ load();
+ pollRef.current = setInterval(load, POLL_MS);
+ return () => clearInterval(pollRef.current);
+ }, [isAdmin, load]);
+
+ const onRetry = async (id) => {
+ try {
+ await api.retryDelivery(id);
+ toast.success('Delivery re-queued');
+ load();
+ } catch {
+ toast.error('Retry failed');
+ }
+ };
+
+ if (!isAdmin) {
+ return (
+ <>
+ <PageTopbar icon={<Send size={18} />} title="Notification Delivery Log" />
+ <div className="sk-dlog"><div className="sk-dlog__empty">Admins only.</div></div>
+ </>
+ );
+ }
+
+ const byStatus = stats?.by_status || {};
+
+ return (
+ <>
+ <PageTopbar
+ icon={<Send size={18} />}
+ title="Notification Delivery Log"
+ meta="Outbound deliveries across all channels"
+ actions={(
+ <Button variant="outline" size="sm" onClick={load}>
+ <RefreshCw size={14} /> Refresh
+ </Button>
+ )}
+ />
+
+ <div className="sk-dlog">
+ <EmailProviders />
+
+ <div className="sk-dlog__stats">
+ <MetricCard label="Total" value={stats?.total ?? 0} tone="accent" />
+ <MetricCard label="Sent" value={byStatus.sent ?? 0} tone="green" />
+ <MetricCard label="Pending" value={byStatus.pending ?? 0} tone="amber" />
+ <MetricCard label="Failed" value={byStatus.failed ?? 0} tone="red" />
+ </div>
+
+ <div className="sk-dlog__filters">
+ <label>
+ Status
+ <select value={status} onChange={(e) => setStatus(e.target.value)}>
+ {STATUSES.map((s) => <option key={s} value={s}>{s}</option>)}
+ </select>
+ </label>
+ <label>
+ Channel
+ <select value={channel} onChange={(e) => setChannel(e.target.value)}>
+ {CHANNELS.map((c) => <option key={c} value={c}>{c}</option>)}
+ </select>
+ </label>
+ </div>
+
+ {loading && deliveries.length === 0 ? (
+ <div className="sk-dlog__empty">Loading…</div>
+ ) : deliveries.length === 0 ? (
+ <div className="sk-dlog__empty">
+ <Inbox size={24} aria-hidden="true" />
+ <p>No deliveries match these filters.</p>
+ </div>
+ ) : (
+ <div className="sk-dlog__table-wrap">
+ <table className="sk-dlog__table">
+ <thead>
+ <tr>
+ <th>Status</th>
+ <th>Channel</th>
+ <th>To</th>
+ <th>Notification</th>
+ <th>Tries</th>
+ <th>When</th>
+ <th aria-label="Actions" />
+ </tr>
+ </thead>
+ <tbody>
+ {deliveries.map((d) => (
+ <tr key={d.id}>
+ <td><span className={`sk-dlog__status is-${d.status}`}>{d.status}</span></td>
+ <td>{d.channel}</td>
+ <td className="sk-dlog__target">{d.target || '—'}</td>
+ <td>
+ <div className="sk-dlog__title">{d.title || d.event_key}</div>
+ {d.error && <div className="sk-dlog__error" title={d.error}>{d.error}</div>}
+ </td>
+ <td>{d.attempts}</td>
+ <td className="sk-dlog__when">{timeAgo(d.created_at)}</td>
+ <td>
+ {(d.status === 'failed' || d.status === 'skipped') && d.channel !== 'inapp' && (
+ <Button variant="ghost" size="sm" onClick={() => onRetry(d.id)}>Retry</Button>
+ )}
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ )}
+ </div>
+ </>
+ );
+}
diff --git a/frontend/src/pages/Notifications.jsx b/frontend/src/pages/Notifications.jsx
new file mode 100644
index 00000000..526109ac
--- /dev/null
+++ b/frontend/src/pages/Notifications.jsx
@@ -0,0 +1,147 @@
+import { useState, useEffect, useCallback } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { Bell, CheckCheck, ScrollText } from 'lucide-react';
+import api from '../services/api';
+import { PageTopbar } from '@/components/ds';
+import { Button } from '@/components/ui/button';
+import { useAuth } from '../contexts/AuthContext';
+import { useNotifications } from '../contexts/NotificationsContext';
+import { timeAgo } from '../utils/timeAgo';
+
+const SEVERITY_DOT = {
+ critical: '#fb6f6f',
+ warning: '#f5b945',
+ success: '#3ddc97',
+ info: '#6d7cff',
+ test: '#9aa1b2',
+};
+
+const PAGE_SIZE = 25;
+
+export default function Notifications() {
+ const navigate = useNavigate();
+ const { isAdmin } = useAuth();
+ const { refresh: refreshBell } = useNotifications() || {};
+ const [items, setItems] = useState([]);
+ const [unreadOnly, setUnreadOnly] = useState(false);
+ const [unreadCount, setUnreadCount] = useState(0);
+ const [loading, setLoading] = useState(true);
+ const [hasMore, setHasMore] = useState(false);
+
+ const fetchPage = useCallback(async (startOffset, replace) => {
+ setLoading(true);
+ try {
+ const data = await api.getInbox({ limit: PAGE_SIZE, offset: startOffset, unread: unreadOnly });
+ const fresh = data.items || [];
+ setItems((prev) => (replace ? fresh : [...prev, ...fresh]));
+ setUnreadCount(data.unread_count || 0);
+ setHasMore(fresh.length === PAGE_SIZE);
+ } catch {
+ setHasMore(false);
+ } finally {
+ setLoading(false);
+ }
+ }, [unreadOnly]);
+
+ useEffect(() => { fetchPage(0, true); }, [fetchPage]);
+
+ const onItemClick = async (item) => {
+ if (item.read) return;
+ setItems((prev) => prev.map((it) => (
+ it.delivery_id === item.delivery_id ? { ...it, read: true } : it
+ )));
+ setUnreadCount((c) => Math.max(0, c - 1));
+ try { await api.markNotificationRead(item.delivery_id); } catch { /* reconciled on reload */ }
+ if (refreshBell) refreshBell();
+ };
+
+ const onMarkAll = async () => {
+ setItems((prev) => prev.map((it) => ({ ...it, read: true })));
+ setUnreadCount(0);
+ try { await api.markAllNotificationsRead(); } catch { /* reconciled on reload */ }
+ if (refreshBell) refreshBell();
+ };
+
+ return (
+ <>
+ <PageTopbar
+ icon={<Bell size={18} />}
+ title="Notifications"
+ meta={unreadCount ? `${unreadCount} unread` : 'All caught up'}
+ actions={(
+ <>
+ {isAdmin && (
+ <Button variant="ghost" size="sm" onClick={() => navigate('/admin/notifications')}>
+ <ScrollText size={15} /> Delivery log
+ </Button>
+ )}
+ <Button variant="outline" size="sm" onClick={onMarkAll} disabled={!unreadCount}>
+ <CheckCheck size={15} /> Mark all read
+ </Button>
+ </>
+ )}
+ />
+
+ <div className="sk-notif-page">
+ <div className="sk-notif-page__filters" role="tablist" aria-label="Filter notifications">
+ <button
+ type="button"
+ role="tab"
+ aria-selected={!unreadOnly}
+ className={!unreadOnly ? 'is-active' : ''}
+ onClick={() => setUnreadOnly(false)}
+ >
+ All
+ </button>
+ <button
+ type="button"
+ role="tab"
+ aria-selected={unreadOnly}
+ className={unreadOnly ? 'is-active' : ''}
+ onClick={() => setUnreadOnly(true)}
+ >
+ Unread
+ </button>
+ </div>
+
+ {loading && items.length === 0 ? (
+ <div className="sk-notif-page__state">Loading…</div>
+ ) : items.length === 0 ? (
+ <div className="sk-notif-page__state">
+ <Bell size={26} aria-hidden="true" />
+ <p>{unreadOnly ? 'No unread notifications.' : 'No notifications yet.'}</p>
+ </div>
+ ) : (
+ <ul className="sk-notif-page__list">
+ {items.map((item) => (
+ <li
+ key={item.delivery_id}
+ className={`sk-notif-row${item.read ? '' : ' is-unread'}`}
+ onClick={() => onItemClick(item)}
+ >
+ <span
+ className="sk-notif-row__dot"
+ style={{ background: SEVERITY_DOT[item.severity] || SEVERITY_DOT.info }}
+ aria-hidden="true"
+ />
+ <div className="sk-notif-row__body">
+ <div className="sk-notif-row__title">{item.title}</div>
+ {item.body && <div className="sk-notif-row__text">{item.body}</div>}
+ </div>
+ <span className="sk-notif-row__time">{timeAgo(item.created_at)}</span>
+ </li>
+ ))}
+ </ul>
+ )}
+
+ {hasMore && !loading && (
+ <div className="sk-notif-page__more">
+ <Button variant="outline" size="sm" onClick={() => fetchPage(items.length, false)}>
+ Load more
+ </Button>
+ </div>
+ )}
+ </div>
+ </>
+ );
+}
diff --git a/frontend/src/services/api/index.js b/frontend/src/services/api/index.js
index 9ef1833c..9949c3c0 100644
--- a/frontend/src/services/api/index.js
+++ b/frontend/src/services/api/index.js
@@ -19,6 +19,7 @@ import * as tunnelMethods from './tunnels.js';
import * as secretsWebhooksMethods from './secretsWebhooks.js';
import * as containerOpsMethods from './containerOps.js';
import * as queueBusMethods from './queueBus.js';
+import * as notificationMethods from './notifications.js';
class ApiService extends ApiClient {
constructor() {
@@ -45,6 +46,7 @@ class ApiService extends ApiClient {
secretsWebhooksMethods,
containerOpsMethods,
queueBusMethods,
+ notificationMethods,
];
for (const mod of modules) {
for (const [key, fn] of Object.entries(mod)) {
diff --git a/frontend/src/services/api/notifications.js b/frontend/src/services/api/notifications.js
new file mode 100644
index 00000000..2be38cbd
--- /dev/null
+++ b/frontend/src/services/api/notifications.js
@@ -0,0 +1,66 @@
+// Notification Bus API methods. Mixed into ApiService (see ./index.js) so each
+// function runs with `this` bound to the client and calls `this.request(...)`.
+
+// --- In-app notification center (the bell + history) ---
+
+export async function getInbox(params = {}) {
+ const query = new URLSearchParams();
+ if (params.limit) query.append('limit', params.limit);
+ if (params.offset) query.append('offset', params.offset);
+ if (params.unread) query.append('unread', '1');
+ const suffix = query.toString() ? `?${query}` : '';
+ return this.request(`/notifications/inbox${suffix}`);
+}
+
+export async function getNotificationUnreadCount() {
+ return this.request('/notifications/inbox/unread-count');
+}
+
+export async function markNotificationRead(deliveryId) {
+ return this.request(`/notifications/inbox/${deliveryId}/read`, { method: 'POST' });
+}
+
+export async function markAllNotificationsRead() {
+ return this.request('/notifications/inbox/read-all', { method: 'POST' });
+}
+
+// --- Delivery log / ops (admin) ---
+
+export async function getDeliveryLog(params = {}) {
+ const query = new URLSearchParams();
+ if (params.status) query.append('status', params.status);
+ if (params.channel) query.append('channel', params.channel);
+ if (params.limit) query.append('limit', params.limit);
+ if (params.offset) query.append('offset', params.offset);
+ const suffix = query.toString() ? `?${query}` : '';
+ return this.request(`/notifications/admin/deliveries${suffix}`);
+}
+
+export async function retryDelivery(deliveryId) {
+ return this.request(`/notifications/admin/deliveries/${deliveryId}/retry`, { method: 'POST' });
+}
+
+// --- Email provider integrations (admin) ---
+
+export async function getEmailProviders() {
+ return this.request('/notifications/admin/email-providers');
+}
+
+export async function addEmailProvider(data) {
+ return this.request('/notifications/admin/email-providers', {
+ method: 'POST',
+ body: JSON.stringify(data),
+ });
+}
+
+export async function testEmailProvider(providerId) {
+ return this.request(`/notifications/admin/email-providers/${providerId}/test`, { method: 'POST' });
+}
+
+export async function setDefaultEmailProvider(providerId) {
+ return this.request(`/notifications/admin/email-providers/${providerId}/default`, { method: 'POST' });
+}
+
+export async function deleteEmailProvider(providerId) {
+ return this.request(`/notifications/admin/email-providers/${providerId}`, { method: 'DELETE' });
+}
diff --git a/frontend/src/services/socket.js b/frontend/src/services/socket.js
index c4121af1..28b0c281 100644
--- a/frontend/src/services/socket.js
+++ b/frontend/src/services/socket.js
@@ -58,6 +58,11 @@ class SocketService {
this.socket.on('log_error', (data) => {
this.emit('log_error', data);
});
+
+ // New in-app notification pushed to this user's room by the bus.
+ this.socket.on('notification', (data) => {
+ this.emit('notification', data);
+ });
}
disconnect() {
diff --git a/frontend/src/styles/components/_notification-center.scss b/frontend/src/styles/components/_notification-center.scss
new file mode 100644
index 00000000..e70272ae
--- /dev/null
+++ b/frontend/src/styles/components/_notification-center.scss
@@ -0,0 +1,187 @@
+// In-app notification bell + dropdown (sk-notif namespace). Lives in the
+// sidebar footer (opens upward) and the mobile top bar (opens downward).
+
+.sk-notif {
+ position: relative;
+ display: flex;
+
+ &__bell {
+ position: relative;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 34px;
+ height: 34px;
+ border: 1px solid $border-subtle;
+ border-radius: 9px;
+ background: $bg-card;
+ color: $text-secondary;
+ cursor: pointer;
+ transition: background 0.15s, color 0.15s, border-color 0.15s;
+
+ &:hover {
+ background: $bg-hover;
+ color: $text-primary;
+ border-color: $border-default;
+ }
+ }
+
+ &__badge {
+ position: absolute;
+ top: -5px;
+ right: -5px;
+ min-width: 17px;
+ height: 17px;
+ padding: 0 4px;
+ border-radius: 999px;
+ background: $danger;
+ color: #fff;
+ font-size: 10px;
+ font-weight: 700;
+ line-height: 17px;
+ text-align: center;
+ box-shadow: 0 0 0 2px $bg-card;
+ }
+
+ &__panel {
+ position: absolute;
+ bottom: calc(100% + 10px); // open upward (sidebar footer)
+ right: 0;
+ width: 340px;
+ max-width: calc(100vw - 32px);
+ background: $bg-elevated;
+ border: 1px solid $border-default;
+ border-radius: 12px;
+ box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
+ z-index: 1000;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ }
+
+ &__head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 12px 14px;
+ border-bottom: 1px solid $border-subtle;
+ }
+
+ &__heading {
+ font-weight: 600;
+ font-size: 14px;
+ color: $text-primary;
+ }
+
+ &__markall {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ border: none;
+ background: none;
+ cursor: pointer;
+ color: $accent-primary;
+ font-size: 12px;
+ font-weight: 500;
+
+ &:hover { text-decoration: underline; }
+ }
+
+ &__list {
+ max-height: 380px;
+ overflow-y: auto;
+ }
+
+ &__empty {
+ padding: 28px 14px;
+ text-align: center;
+ color: $text-secondary;
+ font-size: 13px;
+ }
+
+ &__item {
+ display: flex;
+ gap: 10px;
+ width: 100%;
+ padding: 11px 14px;
+ border: none;
+ background: none;
+ cursor: pointer;
+ text-align: left;
+ border-bottom: 1px solid $border-subtle;
+
+ &:hover { background: $bg-hover; }
+ &.is-unread { background: $accent-bg; }
+ &:last-child { border-bottom: none; }
+ }
+
+ &__dot {
+ flex: 0 0 auto;
+ width: 8px;
+ height: 8px;
+ margin-top: 6px;
+ border-radius: 50%;
+ }
+
+ &__content {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ min-width: 0;
+ }
+
+ &__title {
+ font-size: 13px;
+ font-weight: 600;
+ color: $text-primary;
+ }
+
+ &__text {
+ font-size: 12px;
+ color: $text-secondary;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ }
+
+ &__time {
+ font-size: 11px;
+ color: $text-secondary;
+ opacity: 0.8;
+ }
+
+ &__seeall {
+ padding: 11px 14px;
+ border: none;
+ background: none;
+ cursor: pointer;
+ color: $accent-primary;
+ font-size: 13px;
+ font-weight: 500;
+ border-top: 1px solid $border-subtle;
+
+ &:hover { background: $bg-hover; }
+ }
+}
+
+// In the sidebar footer, give the bell its own row above the user button.
+.sidebar-footer__row {
+ display: flex;
+ justify-content: flex-start;
+ margin-bottom: 8px;
+}
+
+// In the mobile top bar the bell sits at the top, so the panel opens downward.
+.mobile-topbar__actions {
+ margin-left: auto;
+ display: flex;
+ align-items: center;
+}
+
+.mobile-topbar .sk-notif__panel {
+ top: calc(100% + 10px);
+ bottom: auto;
+ right: 8px;
+}
diff --git a/frontend/src/styles/main.scss b/frontend/src/styles/main.scss
index 8f09da0c..d8c1a55d 100644
--- a/frontend/src/styles/main.scss
+++ b/frontend/src/styles/main.scss
@@ -50,6 +50,7 @@
@import 'components/_private-url';
@import 'components/_two-factor';
@import 'components/_notifications';
+@import 'components/_notification-center';
@import 'components/_query-runner';
@import 'components/_deploy';
@import 'components/_git-connect';
@@ -81,6 +82,7 @@
@import 'pages/_deployments';
@import 'pages/_terminal';
@import 'pages/_settings';
+@import 'pages/_notification-center';
@import 'pages/_connections';
@import 'pages/_file-manager';
@import 'pages/_ftp-server';
diff --git a/frontend/src/styles/pages/_notification-center.scss b/frontend/src/styles/pages/_notification-center.scss
new file mode 100644
index 00000000..44f8222d
--- /dev/null
+++ b/frontend/src/styles/pages/_notification-center.scss
@@ -0,0 +1,373 @@
+// Notifications history page (sk-notif-page).
+
+.sk-notif-page {
+ max-width: 760px;
+ margin: 0 auto;
+ padding: 20px 24px 40px;
+
+ &__filters {
+ display: inline-flex;
+ gap: 4px;
+ margin-bottom: 16px;
+ background: $bg-card;
+ border: 1px solid $border-subtle;
+ border-radius: 9px;
+ padding: 3px;
+
+ button {
+ border: none;
+ background: none;
+ cursor: pointer;
+ padding: 6px 14px;
+ border-radius: 7px;
+ font-size: 13px;
+ font-weight: 500;
+ color: $text-secondary;
+
+ &:hover { color: $text-primary; }
+ &.is-active {
+ background: $accent-bg;
+ color: $accent-primary;
+ }
+ }
+ }
+
+ &__state {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 10px;
+ padding: 60px 20px;
+ color: $text-secondary;
+
+ svg { opacity: 0.5; }
+ p { margin: 0; font-size: 14px; }
+ }
+
+ &__list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ border: 1px solid $border-subtle;
+ border-radius: 12px;
+ overflow: hidden;
+ background: $bg-card;
+ }
+
+ &__more {
+ display: flex;
+ justify-content: center;
+ margin-top: 16px;
+ }
+}
+
+.sk-notif-row {
+ display: flex;
+ align-items: flex-start;
+ gap: 12px;
+ padding: 14px 16px;
+ cursor: pointer;
+ border-bottom: 1px solid $border-subtle;
+
+ &:last-child { border-bottom: none; }
+ &:hover { background: $bg-hover; }
+ &.is-unread { background: $accent-bg; }
+
+ &__dot {
+ flex: 0 0 auto;
+ width: 9px;
+ height: 9px;
+ margin-top: 5px;
+ border-radius: 50%;
+ }
+
+ &__body {
+ flex: 1;
+ min-width: 0;
+ }
+
+ &__title {
+ font-size: 14px;
+ font-weight: 600;
+ color: $text-primary;
+ }
+
+ &__text {
+ margin-top: 2px;
+ font-size: 13px;
+ color: $text-secondary;
+ }
+
+ &__time {
+ flex: 0 0 auto;
+ font-size: 12px;
+ color: $text-secondary;
+ opacity: 0.8;
+ white-space: nowrap;
+ }
+}
+
+// Admin delivery log (sk-dlog).
+.sk-dlog {
+ max-width: 1000px;
+ margin: 0 auto;
+ padding: 20px 24px 40px;
+
+ &__stats {
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ gap: 12px;
+ margin-bottom: 18px;
+ }
+
+ &__filters {
+ display: flex;
+ gap: 16px;
+ margin-bottom: 14px;
+
+ label {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 13px;
+ color: $text-secondary;
+ }
+
+ select {
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: 8px;
+ color: $text-primary;
+ padding: 6px 10px;
+ font-size: 13px;
+ text-transform: capitalize;
+ }
+ }
+
+ &__empty {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 10px;
+ padding: 50px 20px;
+ color: $text-secondary;
+
+ svg { opacity: 0.5; }
+ p { margin: 0; }
+ }
+
+ &__table-wrap {
+ border: 1px solid $border-subtle;
+ border-radius: 12px;
+ overflow: hidden;
+ background: $bg-card;
+ }
+
+ &__table {
+ width: 100%;
+ border-collapse: collapse;
+ font-size: 13px;
+
+ th {
+ text-align: left;
+ padding: 10px 14px;
+ font-size: 11px;
+ font-weight: 600;
+ text-transform: uppercase;
+ letter-spacing: 0.4px;
+ color: $text-secondary;
+ border-bottom: 1px solid $border-subtle;
+ }
+
+ td {
+ padding: 11px 14px;
+ border-bottom: 1px solid $border-subtle;
+ color: $text-primary;
+ vertical-align: top;
+ }
+
+ tr:last-child td { border-bottom: none; }
+ }
+
+ &__status {
+ display: inline-block;
+ padding: 2px 9px;
+ border-radius: 999px;
+ font-size: 11px;
+ font-weight: 600;
+ text-transform: capitalize;
+
+ &.is-sent { background: rgba(61, 220, 151, 0.15); color: #1f9d6b; }
+ &.is-pending { background: rgba(109, 124, 255, 0.15); color: #5560d6; }
+ &.is-failed { background: rgba(251, 111, 111, 0.15); color: #d2544f; }
+ &.is-skipped { background: rgba(154, 161, 178, 0.18); color: $text-secondary; }
+ }
+
+ &__target {
+ font-family: 'SFMono-Regular', ui-monospace, Consolas, monospace;
+ font-size: 12px;
+ color: $text-secondary;
+ max-width: 220px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__title { font-weight: 600; }
+
+ &__error {
+ margin-top: 3px;
+ font-size: 12px;
+ color: #d2544f;
+ max-width: 320px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__when {
+ color: $text-secondary;
+ white-space: nowrap;
+ }
+}
+
+@media (max-width: 720px) {
+ .sk-dlog__stats { grid-template-columns: repeat(2, 1fr); }
+}
+
+// Email transport / provider management (sk-eprov).
+.sk-eprov {
+ background: $bg-card;
+ border: 1px solid $border-subtle;
+ border-radius: 12px;
+ padding: 16px 18px;
+ margin-bottom: 18px;
+
+ &__head {
+ display: flex;
+ align-items: baseline;
+ gap: 10px;
+ margin-bottom: 12px;
+ }
+
+ &__title {
+ display: inline-flex;
+ align-items: center;
+ gap: 7px;
+ font-size: 14px;
+ font-weight: 600;
+ color: $text-primary;
+ }
+
+ &__sub { font-size: 12px; color: $text-secondary; }
+
+ &__empty {
+ font-size: 13px;
+ color: $text-secondary;
+ padding: 6px 0 12px;
+ }
+
+ &__list {
+ list-style: none;
+ margin: 0 0 12px;
+ padding: 0;
+ }
+
+ &__item {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 10px 0;
+ border-bottom: 1px solid $border-subtle;
+
+ &:last-child { border-bottom: none; }
+ }
+
+ &__meta {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ min-width: 0;
+ }
+
+ &__name {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 13px;
+ font-weight: 600;
+ color: $text-primary;
+ }
+
+ &__badge {
+ font-size: 10px;
+ font-weight: 700;
+ text-transform: uppercase;
+ letter-spacing: 0.4px;
+ padding: 1px 7px;
+ border-radius: 999px;
+ background: $accent-bg;
+ color: $accent-primary;
+ }
+
+ &__type { font-size: 12px; color: $text-secondary; }
+
+ &__actions {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ flex: 0 0 auto;
+ }
+
+ &__add {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+ }
+
+ &__form {
+ border-top: 1px solid $border-subtle;
+ margin-top: 6px;
+ padding-top: 14px;
+ }
+
+ &__form-title {
+ font-size: 13px;
+ font-weight: 600;
+ color: $text-primary;
+ margin-bottom: 10px;
+ }
+
+ &__grid {
+ display: grid;
+ grid-template-columns: repeat(2, 1fr);
+ gap: 12px;
+ }
+
+ &__field {
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+ }
+
+ &__check {
+ display: inline-flex;
+ align-items: center;
+ gap: 7px;
+ font-size: 13px;
+ color: $text-secondary;
+ padding-top: 6px;
+ }
+
+ &__form-actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ margin-top: 14px;
+ }
+}
+
+@media (max-width: 720px) {
+ .sk-eprov__grid { grid-template-columns: 1fr; }
+}
diff --git a/frontend/src/utils/timeAgo.js b/frontend/src/utils/timeAgo.js
new file mode 100644
index 00000000..ecac0b70
--- /dev/null
+++ b/frontend/src/utils/timeAgo.js
@@ -0,0 +1,17 @@
+// Compact relative time, e.g. "just now", "4m", "3h", "2d", else a date.
+export function timeAgo(iso) {
+ if (!iso) return '';
+ const then = new Date(iso).getTime();
+ if (Number.isNaN(then)) return '';
+ const seconds = Math.floor((Date.now() - then) / 1000);
+ if (seconds < 45) return 'just now';
+ const minutes = Math.floor(seconds / 60);
+ if (minutes < 60) return `${minutes}m`;
+ const hours = Math.floor(minutes / 60);
+ if (hours < 24) return `${hours}h`;
+ const days = Math.floor(hours / 24);
+ if (days < 7) return `${days}d`;
+ return new Date(then).toLocaleDateString();
+}
+
+export default timeAgo;