refactor(webui): use central status and action components
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Bell, Check, ExternalLink, RefreshCw, Send, XCircle } from "lucide-react";
|
||||
import { Button, DismissibleAlert, hasScope, type ApiSettings, type AuthInfo } from "@govoplan/core-webui";
|
||||
import { AdminIconButton, Button, DismissibleAlert, SegmentedControl, StatusBadge, hasScope, type ApiSettings, type AuthInfo } from "@govoplan/core-webui";
|
||||
import { deliverPendingNotifications, listNotifications, updateNotification, type NotificationMessage } from "../../api/notifications";
|
||||
import { safeNotificationActionUrl } from "../../security/actionUrl";
|
||||
|
||||
@@ -99,17 +99,16 @@ export default function NotificationCenterPage({ settings, auth }: { settings: A
|
||||
<strong>Notifications</strong>
|
||||
{unreadCount > 0 ? <span className="notifications-count">{unreadCount}</span> : null}
|
||||
</div>
|
||||
<Button className="notifications-icon-button" onClick={() => void load()} title="Refresh" disabled={loading || busy}>
|
||||
<RefreshCw size={16} />
|
||||
</Button>
|
||||
</div>
|
||||
<div className="notifications-filter-row" role="tablist" aria-label="Notification status">
|
||||
{statusFilters.map((status) => (
|
||||
<button key={status} className={status === statusFilter ? "is-active" : ""} type="button" onClick={() => setStatusFilter(status)} role="tab" aria-selected={status === statusFilter}>
|
||||
{status}
|
||||
</button>
|
||||
))}
|
||||
<AdminIconButton label="Refresh" icon={<RefreshCw size={16} aria-hidden="true" />} onClick={() => void load()} disabled={loading || busy} />
|
||||
</div>
|
||||
<SegmentedControl
|
||||
className="notifications-status-filter"
|
||||
options={statusFilters.map((status) => ({ id: status, label: status }))}
|
||||
value={statusFilter}
|
||||
onChange={setStatusFilter}
|
||||
ariaLabel="Notification status"
|
||||
width="fill"
|
||||
/>
|
||||
<div className="notifications-list">
|
||||
{loading ? <div className="notifications-note">Loading notifications</div> : null}
|
||||
{!loading && notifications.length === 0 ? <div className="notifications-note">No notifications in this view.</div> : null}
|
||||
@@ -177,7 +176,7 @@ function NotificationDetails({ notification }: { notification: NotificationMessa
|
||||
<div className="notifications-detail">
|
||||
<section className="notifications-message">
|
||||
<div className="notifications-message-meta">
|
||||
<span className={`notifications-status status-${notification.status}`}>{formatStatus(notification.status)}</span>
|
||||
<StatusBadge status={notification.status} label={formatStatus(notification.status)} />
|
||||
<span>{notification.channel}</span>
|
||||
<span>{formatDate(notification.created_at)}</span>
|
||||
</div>
|
||||
|
||||
@@ -65,40 +65,9 @@
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.notifications-icon-button.btn {
|
||||
width: 34px;
|
||||
min-width: 34px;
|
||||
height: 34px;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.notifications-filter-row {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
padding: 8px;
|
||||
border-bottom: var(--border-line);
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.notifications-filter-row button {
|
||||
min-height: 28px;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
padding: 0 8px;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.notifications-filter-row button:hover,
|
||||
.notifications-filter-row button.is-active {
|
||||
background: var(--sidebar-hover-bg);
|
||||
color: var(--text-strong);
|
||||
.notifications-status-filter {
|
||||
width: calc(100% - 16px);
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.notifications-list {
|
||||
@@ -230,29 +199,6 @@
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.notifications-status {
|
||||
border-radius: 999px;
|
||||
background: var(--panel-soft);
|
||||
color: var(--text);
|
||||
padding: 3px 8px;
|
||||
}
|
||||
|
||||
.notifications-status.status-failed {
|
||||
background: var(--danger-soft);
|
||||
color: var(--danger-text);
|
||||
}
|
||||
|
||||
.notifications-status.status-sent {
|
||||
background: var(--success-soft);
|
||||
color: var(--green);
|
||||
}
|
||||
|
||||
.notifications-status.status-queued,
|
||||
.notifications-status.status-pending {
|
||||
background: var(--warning-bg);
|
||||
color: var(--warning-text);
|
||||
}
|
||||
|
||||
.notifications-action-link {
|
||||
width: max-content;
|
||||
max-width: 100%;
|
||||
|
||||
Reference in New Issue
Block a user