@@ -4,11 +4,17 @@ import { Badge } from "components/Badge/Badge";
4
4
import { Button } from "components/Button/Button" ;
5
5
import { ExternalImage } from "components/ExternalImage/ExternalImage" ;
6
6
import { CoderIcon } from "components/Icons/CoderIcon" ;
7
+ import {
8
+ Tooltip ,
9
+ TooltipContent ,
10
+ TooltipProvider ,
11
+ TooltipTrigger ,
12
+ } from "components/Tooltip/Tooltip" ;
7
13
import type { ProxyContextValue } from "contexts/ProxyContext" ;
8
14
import { useWebpushNotifications } from "contexts/useWebpushNotifications" ;
9
- import { useAuthenticated } from "hooks" ;
10
15
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata" ;
11
16
import { NotificationsInbox } from "modules/notifications/NotificationsInbox/NotificationsInbox" ;
17
+ import type { Task } from "modules/tasks/tasks" ;
12
18
import { data } from "pages/TasksPage/TasksPage" ;
13
19
import type { FC } from "react" ;
14
20
import { useQuery } from "react-query" ;
@@ -21,7 +27,7 @@ import { UserDropdown } from "./UserDropdown/UserDropdown";
21
27
22
28
interface NavbarViewProps {
23
29
logo_url ?:string ;
24
- user ? :TypesGen . User ;
30
+ user :TypesGen . User ;
25
31
buildInfo ?:TypesGen . BuildInfoResponse ;
26
32
supportLinks ?:readonly TypesGen . LinkConfig [ ] ;
27
33
onSignOut :( ) => void ;
@@ -64,7 +70,7 @@ export const NavbarView: FC<NavbarViewProps> = ({
64
70
) }
65
71
</ NavLink >
66
72
67
- < NavItems className = "ml-4" />
73
+ < NavItems className = "ml-4" user = { user } />
68
74
69
75
< div className = "flex items-center gap-3 ml-auto" >
70
76
{ proxyContextValue && (
@@ -113,16 +119,14 @@ export const NavbarView: FC<NavbarViewProps> = ({
113
119
}
114
120
/>
115
121
116
- { user && (
117
- < div className = "hidden md:block" >
118
- < UserDropdown
119
- user = { user }
120
- buildInfo = { buildInfo }
121
- supportLinks = { supportLinks }
122
- onSignOut = { onSignOut }
123
- />
124
- </ div >
125
- ) }
122
+ < div className = "hidden md:block" >
123
+ < UserDropdown
124
+ user = { user }
125
+ buildInfo = { buildInfo }
126
+ supportLinks = { supportLinks }
127
+ onSignOut = { onSignOut }
128
+ />
129
+ </ div >
126
130
127
131
< div className = "md:hidden" >
128
132
< MobileMenu
@@ -144,9 +148,10 @@ export const NavbarView: FC<NavbarViewProps> = ({
144
148
145
149
interface NavItemsProps {
146
150
className ?:string ;
151
+ user :TypesGen . User ;
147
152
}
148
153
149
- const NavItems :FC < NavItemsProps > = ( { className} ) => {
154
+ const NavItems :FC < NavItemsProps > = ( { className, user } ) => {
150
155
const location = useLocation ( ) ;
151
156
152
157
return (
@@ -170,17 +175,20 @@ const NavItems: FC<NavItemsProps> = ({ className }) => {
170
175
>
171
176
Templates
172
177
</ NavLink >
173
- < TasksNavItem />
178
+ < TasksNavItem user = { user } />
174
179
</ nav >
175
180
) ;
176
181
} ;
177
182
178
- const TasksNavItem :FC = ( ) => {
183
+ type TasksNavItemProps = {
184
+ user :TypesGen . User ;
185
+ } ;
186
+
187
+ const TasksNavItem :FC < TasksNavItemProps > = ( { user} ) => {
179
188
const { metadata} = useEmbeddedMetadata ( ) ;
180
189
const canSeeTasks =
181
190
! ! metadata [ "tasks-tab-visible" ] . value ||
182
191
process . env . NODE_ENV === "development" ;
183
- const { user} = useAuthenticated ( ) ;
184
192
const filter = {
185
193
user :{
186
194
label :user . username ,
@@ -202,24 +210,44 @@ const TasksNavItem: FC = () => {
202
210
return null ;
203
211
}
204
212
213
+ const search =
214
+ idleTasks && idleTasks . length > 0
215
+ ?new URLSearchParams ( {
216
+ username :user . username ,
217
+ tab :"waiting-for-input" ,
218
+ } ) . toString ( )
219
+ :undefined ;
220
+
205
221
return (
206
222
< NavLink
223
+ to = { { pathname :"/tasks" , search} }
207
224
className = { ( { isActive} ) => {
208
225
return cn ( linkStyles . default , isActive ?linkStyles . active :"" ) ;
209
226
} }
210
- to = "/tasks"
211
227
>
212
228
Tasks
213
229
{ idleTasks && idleTasks . length > 0 && (
214
- < Badge
215
- variant = "info"
216
- size = "xs"
217
- className = "ml-2"
218
- aria-label = { `You have${ idleTasks . length } tasks waiting for input` }
219
- >
220
- { idleTasks . length }
221
- </ Badge >
230
+ < TooltipProvider >
231
+ < Tooltip >
232
+ < TooltipTrigger asChild >
233
+ < Badge
234
+ variant = "info"
235
+ size = "xs"
236
+ className = "ml-2"
237
+ aria-label = { idleTasksLabel ( idleTasks ) }
238
+ >
239
+ { idleTasks . length }
240
+ </ Badge >
241
+ </ TooltipTrigger >
242
+ < TooltipContent > { idleTasksLabel ( idleTasks ) } </ TooltipContent >
243
+ </ Tooltip >
244
+ </ TooltipProvider >
222
245
) }
223
246
</ NavLink >
224
247
) ;
225
248
} ;
249
+
250
+ function idleTasksLabel ( idleTasks :Task [ ] ) {
251
+ const count = idleTasks . length ;
252
+ return `You have${ count } ${ count === 1 ?"task" :"tasks" } waiting for input` ;
253
+ }