1
1
import { API } from "api/api" ;
2
+ import { experiments } from "api/queries/experiments" ;
2
3
import type * as TypesGen from "api/typesGenerated" ;
4
+ import { Button } from "components/Button/Button" ;
3
5
import { ExternalImage } from "components/ExternalImage/ExternalImage" ;
4
6
import { CoderIcon } from "components/Icons/CoderIcon" ;
5
7
import type { ProxyContextValue } from "contexts/ProxyContext" ;
8
+ import { useWebpushNotifications } from "contexts/useWebpushNotifications" ;
9
+ import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata" ;
6
10
import { NotificationsInbox } from "modules/notifications/NotificationsInbox/NotificationsInbox" ;
7
11
import type { FC } from "react" ;
12
+ import { useQuery } from "react-query" ;
8
13
import { NavLink , useLocation } from "react-router-dom" ;
9
14
import { cn } from "utils/cn" ;
10
15
import { DeploymentDropdown } from "./DeploymentDropdown" ;
@@ -43,6 +48,9 @@ export const NavbarView: FC<NavbarViewProps> = ({
43
48
canViewAuditLog,
44
49
proxyContextValue,
45
50
} ) => {
51
+ const { subscribed, enabled, loading, subscribe, unsubscribe } =
52
+ useWebpushNotifications ( ) ;
53
+
46
54
return (
47
55
< div className = "border-0 border-b border-solid h-[72px] flex items-center leading-none px-6" >
48
56
< NavLink to = "/workspaces" >
@@ -55,7 +63,7 @@ export const NavbarView: FC<NavbarViewProps> = ({
55
63
56
64
< NavItems className = "ml-4" />
57
65
58
- < div className = "flex items-center gap-3 ml-auto" >
66
+ < div className = " hidden md: flex items-center gap-3 ml-auto" >
59
67
{ proxyContextValue && (
60
68
< div className = "hidden md:block" >
61
69
< ProxyMenu proxyContextValue = { proxyContextValue } />
@@ -71,6 +79,18 @@ export const NavbarView: FC<NavbarViewProps> = ({
71
79
/>
72
80
</ div >
73
81
82
+ { enabled ? (
83
+ subscribed ? (
84
+ < Button variant = "outline" disabled = { loading } onClick = { unsubscribe } >
85
+ Disable WebPush
86
+ </ Button >
87
+ ) : (
88
+ < Button variant = "outline" disabled = { loading } onClick = { subscribe } >
89
+ Enable WebPush
90
+ </ Button >
91
+ )
92
+ ) : null }
93
+
74
94
< NotificationsInbox
75
95
fetchNotifications = { API . getInboxNotifications }
76
96
markAllAsRead = { API . markAllInboxNotificationsAsRead }
0 commit comments