@checkstack/notification-frontend 0.2.36 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,192 @@
1
1
  # @checkstack/notification-frontend
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 32d52c6: Bulk notifications affecting multiple systems and collapse lifecycle events into a single card.
8
+
9
+ Notifications now carry an optional `subjects` array (the entities they affect) and an optional `collapseKey` (so related notifications collapse into one row per recipient). Incidents, maintenances, anomalies, healthchecks, and dependency-impact events route through these new fields, so an incident affecting three systems produces one in-app notification + one external send per subscriber instead of three. Lifecycle updates for the same entity (created → updated → resolved) also collapse, with an expandable "+N updates" timeline.
10
+
11
+ Subject kinds are namespaced as `<pluginId>.<localKind>` and built via type-safe helpers exported from each domain's common package (`createSystemSubject`, `incidentCollapseKey`, etc.). The frontend kind registry (`registerSubjectKind`) lets plugins bind icon + label for their kinds; unknown kinds fall back to a generic chip.
12
+
13
+ All notification strategies (SMTP, Slack, Discord, Teams, Telegram, Pushover, Gotify, Webex, Backstage) render the affected subjects natively in their format (HTML cards, Slack blocks, Discord embed fields, adaptive cards, markdown lists, etc.).
14
+
15
+ - 32d52c6: feat: unified notification-subscription manager dialog driven by spec registry
16
+
17
+ Replaces the bell-toggle UX (which only managed a single legacy
18
+ catalog group) with a modal that lists every notification type
19
+ registered against a target — system or group — and exposes both
20
+ per-type toggles and a bulk "Subscribe to all / Unsubscribe from all"
21
+ action. Both surfaces (system detail page header bell, dashboard group
22
+ header bell) now open the same `NotificationSubscriptionsManager`
23
+ component.
24
+
25
+ **Key change vs. the prior slot-based approach**: rows are now driven
26
+ by `notificationClient.listSubscriptionSpecs` — the backend's spec
27
+ registry is the single source of truth. Previously, a row only
28
+ appeared if a frontend plugin had remembered to register a
29
+ `createNotificationSubscriptionExtension`; this caused silent drift
30
+ (healthcheck and dependency registered backend specs without frontend
31
+ extensions, so the dialog counted them but never rendered rows). Now,
32
+ every spec the platform knows about renders a row using the spec's
33
+ `display` metadata (title, description, iconName resolved via
34
+ `DynamicIcon`).
35
+
36
+ **Sub-controls registry** (`@checkstack/notification-frontend`):
37
+ plugins that want sub-granularity (anomaly's per-field mute list,
38
+ future severity / channel filters) call
39
+ `registerSubscriptionSubControls(spec, Component)` at module load —
40
+ the manager looks the component up by `specId` when expanding a row.
41
+
42
+ **Removed (no compat)**:
43
+
44
+ - `createNotificationSubscriptionExtension` (replaced by the
45
+ spec-driven manager + the SubControls registry)
46
+ - `target.slot` field on `NotificationTarget` and the
47
+ `NotificationTargetInput.slot` parameter on
48
+ `defineNotificationTarget`
49
+ - `SystemNotificationSubscriptionsSlot` and
50
+ `GroupNotificationSubscriptionsSlot` from `@checkstack/catalog-common`
51
+ - `SystemNotificationsCard` from the system detail page's main column
52
+ - `SubscribeButton` wiring on dashboard group cards and the system
53
+ detail page header
54
+
55
+ **Migrated frontends**: anomaly (now registers `AnomalyFieldMuteList`
56
+ via the SubControls registry), incident, maintenance — all dropped
57
+ their `createNotificationSubscriptionExtension` calls. healthcheck and
58
+ dependency now show up automatically via the spec registry — no
59
+ frontend changes needed for them to render.
60
+
61
+ The trigger button reflects aggregate state — filled bell when at
62
+ least one spec is subscribed for the resource, ghost bell when none.
63
+
64
+ - 32d52c6: feat: notification target pattern + per-spec subscriptions
65
+
66
+ Replaces the all-or-nothing catalog system/group notification model with a
67
+ platform-level target pattern. Each notification-emitting plugin declares
68
+ _subscription specs_ against typed _target_ objects exported from the
69
+ target's owning plugin (catalog ships `catalogSystemTarget` and
70
+ `catalogGroupTarget`). Notification-backend handles every per-resource
71
+ group lifecycle, parent-edge inheritance, and legacy-subscription seeding
72
+ — plugins never author groupId helpers, lifecycle hooks, or migration
73
+ code again.
74
+
75
+ **Plugin-author surface area is now ~12 lines per emitter:**
76
+
77
+ ```ts
78
+ // <plugin>-common
79
+ const { defineSubscription } = createSubscriptionFactory(pluginMetadata);
80
+ export const fooSystemSubscription = defineSubscription({
81
+ localId: "system",
82
+ target: catalogSystemTarget,
83
+ display: { title: "Foo Alerts", description: "...", iconName: "Bell" },
84
+ });
85
+
86
+ // <plugin>-backend register()
87
+ env.registerSubscriptionSpecs([fooSystemSubscription]);
88
+ // ^ feeds the plugin loader's dependency sorter — each spec's
89
+ // target.ownerPlugin becomes an implicit init-order dep, so this
90
+ // plugin automatically waits for catalog (the target owner) to
91
+ // finish init + afterPluginsReady before its own runs.
92
+
93
+ // <plugin>-backend afterPluginsReady
94
+ await notificationClient.registerSubscriptionSpec(
95
+ specToRegistration(fooSystemSubscription)
96
+ );
97
+ // dispatch
98
+ await notificationClient.notifyForSubscription({
99
+ specId: fooSystemSubscription.specId,
100
+ resourceKeys: [systemId],
101
+ title,
102
+ body,
103
+ importance,
104
+ action,
105
+ collapseKey,
106
+ subjects,
107
+ });
108
+
109
+ // <plugin>-frontend
110
+ createNotificationSubscriptionExtension({ spec: fooSystemSubscription });
111
+ ```
112
+
113
+ **Migrated plugins**: anomaly, incident, maintenance, healthcheck,
114
+ dependency. Each lost its bespoke `notification-groups.ts`,
115
+ `bootstrap*NotificationGroups`, `ensure*Group`, and inheritance walk —
116
+ all of that is now centralized in notification-backend's
117
+ `subscription-engine`.
118
+
119
+ **Plugin loader change** (`@checkstack/backend-api`,
120
+ `@checkstack/backend`): the register-time API gains
121
+ `env.registerSubscriptionSpecs([...specs])`. The dependency sorter
122
+ walks `spec.target.ownerPlugin` for every declared spec and adds the
123
+ target owner as an init-order dependency of the emitting plugin. This
124
+ guarantees that catalog (the owner of the platform's `system` and
125
+ `group` targets) completes init + afterPluginsReady before any
126
+ emitting plugin tries to register its specs against the notification
127
+ service — no string-prefix heuristics, no manual `dependsOnPlugins`
128
+ list, no stub rows. Plugins that fail to declare their specs at
129
+ register time get a clear `Target type X is not registered. Did the
130
+ emitting plugin declare this spec via env.registerSubscriptionSpecs?`
131
+ error from the dispatcher.
132
+
133
+ **Removed** (no backwards compat):
134
+
135
+ - `catalogClient.notifySystemSubscribers` and
136
+ `catalogClient.notifyManySystemSubscribers`
137
+ - `notificationClient.notifyUsers` and `notificationClient.notifyGroups`
138
+ as direct dispatch primitives — replaced by spec-bound
139
+ `notifyForSubscription`
140
+ - catalog's `bootstrapNotificationGroups` (replaced by
141
+ `bootstrapNotificationTargets`)
142
+
143
+ **Enforcement**: the dispatcher rejects calls referencing unregistered
144
+ specIds, specs owned by other plugins, or resourceKeys that haven't been
145
+ pushed via `upsertNotificationResource`. Display metadata for any
146
+ groupId is recoverable via the spec registry, so audit lists render
147
+ correct labels even when an emitter's frontend isn't loaded.
148
+
149
+ **Per-field anomaly mute** keeps working — it now lives inside the
150
+ generic SubscriptionRow's optional `SubControls` panel
151
+ (`AnomalyFieldMuteList`), exposed through the catalog system detail
152
+ page's notifications card.
153
+
154
+ The catalog system detail page renders a "Notifications" card hosting
155
+ `SystemNotificationSubscriptionsSlot`. The matching group surface is
156
+ not yet rendered — group-level subscriptions are wired end-to-end on
157
+ the backend; a follow-up will add the host UI.
158
+
159
+ **Migration of existing subscribers**: target types declare a
160
+ `legacyGroupIdTemplate`; on first registration of each spec,
161
+ notification-backend reads subscribers from the legacy
162
+ `catalog.system.<id>` / `catalog.group.<id>` groups and seeds the new
163
+ spec groups exactly once per (spec × resource) pair, tracked in
164
+ `subscription_migrations`. Anomaly stays opt-in (its target also
165
+ declares the template, but the user-explicit nature of the original
166
+ opt-in flow means the seeding produces the same set of subscribers
167
+ they already had).
168
+
169
+ ### Patch Changes
170
+
171
+ - 32d52c6: Fix several modal/sheet/overlay closing issues:
172
+
173
+ - Replace the custom `DropdownMenu` container with a Radix-based `Popover` (desktop) and `Sheet` (mobile). The previous mobile implementation suppressed outside-click closing, leaving the notification bell's panel only closable by clicking the bell again. `UserMenu` and `NotificationBell` were updated to the new pattern. Leaf primitives `DropdownMenuItem`, `DropdownMenuLabel`, and `DropdownMenuSeparator` are preserved (now backed by a `MenuCloseContext`) so existing call sites continue to work.
174
+ - Fix `Dialog` outside-click closing. The previous structure made `DialogPrimitive.Content` cover the full viewport, so Radix never registered clicks on the dimmed area as "outside" — only ESC could close the modal. The centering wrapper is now a non-Content `<div>` and the actual modal box is the Content, so outside-click closes correctly. A visible X button is now rendered by default; pass `hideCloseButton` to suppress it (e.g. for the search overlay where it would clash with a custom header).
175
+ - Export a standalone `useIsMobile` hook and a new `Popover` primitive.
176
+ - Prevent Radix's auto-focus-return on `NotificationBell` and `UserMenu` overlays. Closing via an item with a `<Link>` (e.g. "View all notifications") would synchronously refocus the trigger via `onCloseAutoFocus`, stealing focus from the link mid-click on pages where another element held focus and requiring a second click to navigate.
177
+
178
+ - Updated dependencies [32d52c6]
179
+ - Updated dependencies [32d52c6]
180
+ - Updated dependencies [32d52c6]
181
+ - Updated dependencies [32d52c6]
182
+ - Updated dependencies [32d52c6]
183
+ - Updated dependencies [32d52c6]
184
+ - Updated dependencies [32d52c6]
185
+ - @checkstack/notification-common@1.0.0
186
+ - @checkstack/frontend-api@0.4.1
187
+ - @checkstack/auth-frontend@0.5.32
188
+ - @checkstack/ui@1.7.0
189
+
3
190
  ## 0.2.36
4
191
 
5
192
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/notification-frontend",
3
- "version": "0.2.36",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "src/index.tsx",
6
6
  "checkstack": {
@@ -12,12 +12,12 @@
12
12
  "lint:code": "eslint . --max-warnings 0"
13
13
  },
14
14
  "dependencies": {
15
- "@checkstack/notification-common": "0.2.9",
16
- "@checkstack/frontend-api": "0.3.11",
17
- "@checkstack/auth-frontend": "0.5.30",
18
- "@checkstack/signal-frontend": "0.0.16",
15
+ "@checkstack/notification-common": "0.3.0",
16
+ "@checkstack/frontend-api": "0.4.0",
17
+ "@checkstack/auth-frontend": "0.5.31",
18
+ "@checkstack/signal-frontend": "0.1.0",
19
19
  "@checkstack/common": "0.7.0",
20
- "@checkstack/ui": "1.6.0",
20
+ "@checkstack/ui": "1.6.1",
21
21
  "react": "^18.2.0",
22
22
  "react-router-dom": "^6.22.0",
23
23
  "lucide-react": "^0.344.0"
@@ -0,0 +1,63 @@
1
+ import { stripMarkdown } from "@checkstack/ui";
2
+ import type { Notification } from "@checkstack/notification-common";
3
+
4
+ interface CollapsedGroupTimelineProps {
5
+ /**
6
+ * The full chronological list of notifications in the group, newest
7
+ * first. The first item (the representative) is rendered above the
8
+ * timeline by the parent, so this component skips it.
9
+ */
10
+ notifications: Notification[];
11
+ variant?: "bell" | "page";
12
+ }
13
+
14
+ /**
15
+ * Compact timeline of older entries in a collapsed notification group.
16
+ * Each row shows the relative time, title, and a one-line body excerpt.
17
+ * The representative (newest) entry is rendered separately by the parent
18
+ * card; this component only renders the historical tail.
19
+ */
20
+ export function CollapsedGroupTimeline({
21
+ notifications,
22
+ variant = "bell",
23
+ }: CollapsedGroupTimelineProps) {
24
+ const older = notifications.slice(1);
25
+ if (older.length === 0) return <></>;
26
+
27
+ const sizeClass = variant === "page" ? "text-sm" : "text-xs";
28
+
29
+ return (
30
+ <div
31
+ className={`mt-2 border-l-2 border-border pl-3 space-y-2 ${sizeClass}`}
32
+ >
33
+ {older.map((n) => (
34
+ <div key={n.id} className="flex flex-col gap-0.5">
35
+ <span className="text-muted-foreground">{formatRelative(n.createdAt)}</span>
36
+ <span className="font-medium text-foreground line-clamp-1">
37
+ {n.title}
38
+ </span>
39
+ {n.body && (
40
+ <span className="text-muted-foreground line-clamp-2">
41
+ {stripMarkdown(n.body)}
42
+ </span>
43
+ )}
44
+ </div>
45
+ ))}
46
+ </div>
47
+ );
48
+ }
49
+
50
+ const RTF = new Intl.RelativeTimeFormat(undefined, { numeric: "auto" });
51
+
52
+ function formatRelative(input: Date | string): string {
53
+ const date = typeof input === "string" ? new Date(input) : input;
54
+ const diffMs = date.getTime() - Date.now();
55
+ const absMin = Math.round(Math.abs(diffMs) / 60_000);
56
+
57
+ if (absMin < 1) return "just now";
58
+ if (absMin < 60) return RTF.format(Math.round(diffMs / 60_000), "minute");
59
+ const absHr = Math.round(absMin / 60);
60
+ if (absHr < 24) return RTF.format(Math.round(diffMs / 3_600_000), "hour");
61
+ const absDay = Math.round(absHr / 24);
62
+ return RTF.format(Math.round(diffMs / 86_400_000), absDay < 30 ? "day" : "month");
63
+ }
@@ -1,16 +1,20 @@
1
- import { useState, useCallback } from "react";
1
+ import { useState, useCallback, type ReactNode } from "react";
2
2
  import { Link } from "react-router-dom";
3
3
  import { Bell, CheckCheck } from "lucide-react";
4
4
  import {
5
5
  Badge,
6
- DropdownMenu,
7
- DropdownMenuContent,
8
- DropdownMenuItem,
9
- DropdownMenuTrigger,
10
- DropdownMenuSeparator,
6
+ Popover,
7
+ PopoverContent,
8
+ PopoverTrigger,
9
+ Sheet,
10
+ SheetContent,
11
+ SheetTrigger,
12
+ SheetHeader,
13
+ SheetTitle,
11
14
  Button,
12
15
  stripMarkdown,
13
16
  useToast,
17
+ useIsMobile,
14
18
  } from "@checkstack/ui";
15
19
  import { useApi, usePluginClient } from "@checkstack/frontend-api";
16
20
  import { resolveRoute } from "@checkstack/common";
@@ -18,6 +22,10 @@ import {
18
22
  NotificationApi,
19
23
  notificationRoutes,
20
24
  } from "@checkstack/notification-common";
25
+ import { NotificationSubjects } from "./NotificationSubjects";
26
+ import { groupByCollapseKey, type CollapsedNotification } from "./collapse";
27
+ import { CollapsedGroupTimeline } from "./CollapsedGroupTimeline";
28
+ import { ChevronDown, ChevronUp } from "lucide-react";
21
29
  import { authApiRef } from "@checkstack/auth-frontend/api";
22
30
 
23
31
  export const NotificationBell = () => {
@@ -25,8 +33,24 @@ export const NotificationBell = () => {
25
33
  const { data: session, isPending: isAuthLoading } = authApi.useSession();
26
34
  const notificationClient = usePluginClient(NotificationApi);
27
35
  const toast = useToast();
36
+ const isMobile = useIsMobile();
28
37
 
29
38
  const [isOpen, setIsOpen] = useState(false);
39
+ const [expandedGroups, setExpandedGroups] = useState<Set<string>>(
40
+ () => new Set(),
41
+ );
42
+
43
+ const toggleExpanded = useCallback((key: string) => {
44
+ setExpandedGroups((prev) => {
45
+ const next = new Set(prev);
46
+ if (next.has(key)) {
47
+ next.delete(key);
48
+ } else {
49
+ next.add(key);
50
+ }
51
+ return next;
52
+ });
53
+ }, []);
30
54
 
31
55
  // Realtime updates arrive via SignalAutoInvalidator on `[["notification"]]`,
32
56
  // so both queries stay fresh without per-component signal handlers.
@@ -62,7 +86,6 @@ export const NotificationBell = () => {
62
86
  setIsOpen(false);
63
87
  }, []);
64
88
 
65
- // Hide notification bell for unauthenticated users
66
89
  if (isAuthLoading || !session) {
67
90
  return;
68
91
  }
@@ -77,119 +100,174 @@ export const NotificationBell = () => {
77
100
  );
78
101
  }
79
102
 
80
- return (
81
- <DropdownMenu>
82
- <DropdownMenuTrigger
103
+ const trigger = (
104
+ <Button variant="ghost" size="icon" className="relative group">
105
+ <Bell className="h-5 w-5 transition-transform group-hover:scale-110" />
106
+ {unreadCount > 0 && (
107
+ <span className="absolute -top-1 -right-1 flex h-5 min-w-[20px] items-center justify-center">
108
+ <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-destructive opacity-75" />
109
+ <Badge
110
+ variant="destructive"
111
+ className="relative h-5 min-w-[20px] flex items-center justify-center p-0 text-xs font-bold"
112
+ >
113
+ {unreadCount > 99 ? "99+" : unreadCount}
114
+ </Badge>
115
+ </span>
116
+ )}
117
+ </Button>
118
+ );
119
+
120
+ const headerActions =
121
+ unreadCount > 0 ? (
122
+ <Button
123
+ variant="ghost"
124
+ size="sm"
125
+ className="h-7 text-xs"
83
126
  onClick={() => {
84
- setIsOpen(!isOpen);
127
+ void handleMarkAllAsRead();
85
128
  }}
86
129
  >
87
- <Button variant="ghost" size="icon" className="relative group">
88
- <Bell className="h-5 w-5 transition-transform group-hover:scale-110" />
89
- {unreadCount > 0 && (
90
- <span className="absolute -top-1 -right-1 flex h-5 min-w-[20px] items-center justify-center">
91
- <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-destructive opacity-75" />
130
+ <CheckCheck className="h-3 w-3 mr-1" />
131
+ Mark all read
132
+ </Button>
133
+ ) : undefined;
134
+
135
+ const renderItem = (group: CollapsedNotification): ReactNode => {
136
+ const notification = group.representative;
137
+ const isExpanded = expandedGroups.has(group.key);
138
+ return (
139
+ <div
140
+ key={group.key}
141
+ className={`flex flex-col items-start gap-1 px-3 py-2 hover:bg-accent transition-colors ${
142
+ notification.importance === "critical"
143
+ ? "border-l-2 border-l-destructive"
144
+ : notification.importance === "warning"
145
+ ? "border-l-2 border-l-warning"
146
+ : ""
147
+ }`}
148
+ >
149
+ <div className="flex items-center gap-2 w-full">
150
+ <div
151
+ className={`font-medium text-sm flex-1 truncate ${
152
+ notification.importance === "critical"
153
+ ? "text-destructive"
154
+ : notification.importance === "warning"
155
+ ? "text-warning"
156
+ : "text-foreground"
157
+ }`}
158
+ >
159
+ {notification.title}
160
+ </div>
161
+ {group.collapsed && (
162
+ <button
163
+ type="button"
164
+ className="inline-flex items-center gap-0.5 shrink-0"
165
+ onClick={(e: React.MouseEvent) => {
166
+ e.stopPropagation();
167
+ toggleExpanded(group.key);
168
+ }}
169
+ aria-label={
170
+ isExpanded
171
+ ? "Collapse update history"
172
+ : "Show update history"
173
+ }
174
+ >
92
175
  <Badge
93
- variant="destructive"
94
- className="relative h-5 min-w-[20px] flex items-center justify-center p-0 text-xs font-bold"
176
+ variant="secondary"
177
+ className="text-[10px] h-5 cursor-pointer hover:bg-accent"
95
178
  >
96
- {unreadCount > 99 ? "99+" : unreadCount}
179
+ +{group.count - 1} updates
180
+ {isExpanded ? (
181
+ <ChevronUp className="ml-0.5 h-3 w-3" />
182
+ ) : (
183
+ <ChevronDown className="ml-0.5 h-3 w-3" />
184
+ )}
97
185
  </Badge>
98
- </span>
186
+ </button>
99
187
  )}
100
- </Button>
101
- </DropdownMenuTrigger>
102
- <DropdownMenuContent
103
- isOpen={isOpen}
104
- onClose={handleClose}
105
- className="w-80"
106
- >
107
- {/* Header */}
108
- <div className="flex items-center justify-between px-3 py-2 border-b border-border">
109
- <span className="font-semibold text-sm">Notifications</span>
110
- {unreadCount > 0 && (
111
- <Button
112
- variant="ghost"
113
- size="sm"
114
- className="h-6 text-xs"
115
- onClick={() => {
116
- void handleMarkAllAsRead();
188
+ </div>
189
+ <div className="text-xs text-muted-foreground line-clamp-2">
190
+ {stripMarkdown(notification.body)}
191
+ </div>
192
+ {notification.subjects && notification.subjects.length > 0 && (
193
+ <NotificationSubjects subjects={notification.subjects} />
194
+ )}
195
+ {notification.action && (
196
+ <div className="flex gap-2 mt-1">
197
+ <Link
198
+ to={notification.action.url}
199
+ className="text-xs text-primary hover:underline"
200
+ onClick={(e: React.MouseEvent) => {
201
+ e.stopPropagation();
117
202
  }}
118
203
  >
119
- <CheckCheck className="h-3 w-3 mr-1" />
120
- Mark all read
121
- </Button>
122
- )}
123
- </div>
204
+ {notification.action.label}
205
+ </Link>
206
+ </div>
207
+ )}
208
+ {group.collapsed && isExpanded && (
209
+ <CollapsedGroupTimeline notifications={group.notifications} />
210
+ )}
211
+ </div>
212
+ );
213
+ };
124
214
 
125
- {/* Notification List */}
126
- <div className="max-h-[400px] overflow-y-auto">
127
- {recentNotifications.length === 0 ? (
128
- <div className="px-3 py-6 text-center text-sm text-muted-foreground">
129
- No unread notifications
130
- </div>
131
- ) : (
132
- <>
133
- {recentNotifications.map((notification) => (
134
- <DropdownMenuItem
135
- key={notification.id}
136
- className={`flex flex-col items-start gap-1 px-3 py-2 cursor-pointer ${
137
- notification.importance === "critical"
138
- ? "border-l-2 border-l-destructive"
139
- : notification.importance === "warning"
140
- ? "border-l-2 border-l-warning"
141
- : ""
142
- }`}
143
- >
144
- <div
145
- className={`font-medium text-sm ${
146
- notification.importance === "critical"
147
- ? "text-destructive"
148
- : notification.importance === "warning"
149
- ? "text-warning"
150
- : "text-foreground"
151
- }`}
152
- >
153
- {notification.title}
154
- </div>
155
- <div className="text-xs text-muted-foreground line-clamp-2">
156
- {stripMarkdown(notification.body)}
157
- </div>
158
- {notification.action && (
159
- <div className="flex gap-2 mt-1">
160
- <Link
161
- to={notification.action.url}
162
- className="text-xs text-primary hover:underline"
163
- onClick={(e: React.MouseEvent) => {
164
- e.stopPropagation();
165
- }}
166
- >
167
- {notification.action.label}
168
- </Link>
169
- </div>
170
- )}
171
- </DropdownMenuItem>
172
- ))}
173
- </>
174
- )}
175
- </div>
215
+ const collapsedGroups = groupByCollapseKey(recentNotifications);
176
216
 
177
- <DropdownMenuSeparator />
217
+ const list =
218
+ collapsedGroups.length === 0 ? (
219
+ <div className="px-3 py-6 text-center text-sm text-muted-foreground">
220
+ No unread notifications
221
+ </div>
222
+ ) : (
223
+ <>{collapsedGroups.map((g) => renderItem(g))}</>
224
+ );
178
225
 
179
- {/* Footer */}
180
- <DropdownMenuItem
181
- onClick={() => {
182
- handleClose();
183
- }}
226
+ const footer = (
227
+ <Link
228
+ to={resolveRoute(notificationRoutes.routes.home)}
229
+ className="block w-full text-center text-sm text-primary hover:bg-accent transition-colors px-3 py-2"
230
+ onClick={handleClose}
231
+ >
232
+ View all notifications
233
+ </Link>
234
+ );
235
+
236
+ if (isMobile) {
237
+ return (
238
+ <Sheet open={isOpen} onOpenChange={setIsOpen}>
239
+ <SheetTrigger asChild>{trigger}</SheetTrigger>
240
+ <SheetContent
241
+ size="full"
242
+ className="flex flex-col p-0"
243
+ onCloseAutoFocus={(e) => e.preventDefault()}
184
244
  >
185
- <Link
186
- to={resolveRoute(notificationRoutes.routes.home)}
187
- className="w-full text-center text-sm text-primary"
188
- >
189
- View all notifications
190
- </Link>
191
- </DropdownMenuItem>
192
- </DropdownMenuContent>
193
- </DropdownMenu>
245
+ <SheetHeader className="flex flex-row items-center justify-between gap-2 px-4 py-3 border-b border-border space-y-0">
246
+ <SheetTitle className="text-base">Notifications</SheetTitle>
247
+ <div className="pr-8">{headerActions}</div>
248
+ </SheetHeader>
249
+ <div className="flex-1 overflow-y-auto">{list}</div>
250
+ <div className="border-t border-border">{footer}</div>
251
+ </SheetContent>
252
+ </Sheet>
253
+ );
254
+ }
255
+
256
+ return (
257
+ <Popover open={isOpen} onOpenChange={setIsOpen}>
258
+ <PopoverTrigger asChild>{trigger}</PopoverTrigger>
259
+ <PopoverContent
260
+ className="w-80 p-0"
261
+ align="end"
262
+ onCloseAutoFocus={(e) => e.preventDefault()}
263
+ >
264
+ <div className="flex items-center justify-between px-3 py-2 border-b border-border">
265
+ <span className="font-semibold text-sm">Notifications</span>
266
+ {headerActions}
267
+ </div>
268
+ <div className="max-h-[400px] overflow-y-auto">{list}</div>
269
+ <div className="border-t border-border">{footer}</div>
270
+ </PopoverContent>
271
+ </Popover>
194
272
  );
195
273
  };