Skip to content

Commit 380bf63

Browse files
Coder Userclaude
andcommitted
feat: implement notification inbox system
- Add API methods for getting notifications and marking them as read - Add TypeScript types for the notification inbox API - Update notification components to use the official API types - Integrate NotificationsInbox component into the navbar Closes #16804 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f6382fd commit 380bf63

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed

site/src/api/api.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,6 +2388,22 @@ class ApiMethods {
23882388
);
23892389
return res.data;
23902390
};
2391+
2392+
// Notification inbox API methods
2393+
getUserNotifications = async () => {
2394+
const response = await this.axios.get<TypesGen.UserNotificationsResponse>(
2395+
"/api/v2/users/me/notifications"
2396+
);
2397+
return response.data;
2398+
};
2399+
2400+
markAllNotificationsAsRead = async (): Promise<void> => {
2401+
await this.axios.post("/api/v2/users/me/notifications/read");
2402+
};
2403+
2404+
markNotificationAsRead = async (notificationId: string): Promise<void> => {
2405+
await this.axios.post(`/api/v2/users/me/notifications/${notificationId}/read`);
2406+
};
23912407
}
23922408

23932409
// This is a hard coded CSRF token/cookie pair for local development. In prod,

site/src/api/typesGenerated.ts

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/modules/dashboard/Navbar/NavbarView.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { API } from "api/api";
12
import type * as TypesGen from "api/typesGenerated";
23
import { ExternalImage } from "components/ExternalImage/ExternalImage";
34
import { CoderIcon } from "components/Icons/CoderIcon";
45
import type { ProxyContextValue } from "contexts/ProxyContext";
6+
import { NotificationsInbox } from "modules/notifications/NotificationsInbox/NotificationsInbox";
57
import type { FC } from "react";
68
import { NavLink, useLocation } from "react-router-dom";
79
import { cn } from "utils/cn";
@@ -57,6 +59,14 @@ export const NavbarView: FC<NavbarViewProps> = ({
5759
{proxyContextValue && (
5860
<ProxyMenu proxyContextValue={proxyContextValue} />
5961
)}
62+
63+
{user && (
64+
<NotificationsInbox
65+
fetchNotifications={API.getUserNotifications}
66+
markAllAsRead={API.markAllNotificationsAsRead}
67+
markNotificationAsRead={API.markNotificationAsRead}
68+
/>
69+
)}
6070

6171
<DeploymentDropdown
6272
canViewAuditLog={canViewAuditLog}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
// TODO: Remove this file when the types from API are available
1+
// This file uses the official API types
2+
import type { InboxNotification } from "api/typesGenerated";
23

3-
export type Notification = {
4-
id: string;
5-
read_status: "read" | "unread";
6-
content: string;
7-
created_at: string;
8-
actions: {
9-
label: string;
10-
url: string;
11-
}[];
12-
};
4+
// Reexport the InboxNotification type for backward compatibility
5+
export type Notification = InboxNotification;

0 commit comments

Comments
 (0)