File tree Expand file tree Collapse file tree 4 files changed +48
-11
lines changed
notifications/NotificationsInbox Expand file tree Collapse file tree 4 files changed +48
-11
lines changed Original file line number Diff line number Diff line change @@ -2388,6 +2388,22 @@ class ApiMethods {
2388
2388
) ;
2389
2389
return res . data ;
2390
2390
} ;
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
+ } ;
2391
2407
}
2392
2408
2393
2409
// This is a hard coded CSRF token/cookie pair for local development. In prod,
Original file line number Diff line number Diff line change
1
+ import { API } from "api/api" ;
1
2
import type * as TypesGen from "api/typesGenerated" ;
2
3
import { ExternalImage } from "components/ExternalImage/ExternalImage" ;
3
4
import { CoderIcon } from "components/Icons/CoderIcon" ;
4
5
import type { ProxyContextValue } from "contexts/ProxyContext" ;
6
+ import { NotificationsInbox } from "modules/notifications/NotificationsInbox/NotificationsInbox" ;
5
7
import type { FC } from "react" ;
6
8
import { NavLink , useLocation } from "react-router-dom" ;
7
9
import { cn } from "utils/cn" ;
@@ -57,6 +59,14 @@ export const NavbarView: FC<NavbarViewProps> = ({
57
59
{ proxyContextValue && (
58
60
< ProxyMenu proxyContextValue = { proxyContextValue } />
59
61
) }
62
+
63
+ { user && (
64
+ < NotificationsInbox
65
+ fetchNotifications = { API . getUserNotifications }
66
+ markAllAsRead = { API . markAllNotificationsAsRead }
67
+ markNotificationAsRead = { API . markNotificationAsRead }
68
+ />
69
+ ) }
60
70
61
71
< DeploymentDropdown
62
72
canViewAuditLog = { canViewAuditLog }
Original file line number Diff line number Diff line change 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" ;
2
3
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 ;
You can’t perform that action at this time.
0 commit comments