1- import React from 'react' ;
1+ import React , { ReactNode } from 'react' ;
22
33import { useTranslations } from 'next-intl' ;
4+ import Link from 'next/link' ;
45
56import { EuiToolTip } from '@elastic/eui' ;
67
7- import { WfoHeaderBadge } from '@/components' ;
8- import { useOrchestratorTheme } from '@/hooks' ;
9- import { WfoCheckmarkCircleFill } from '@/icons' ;
10- import { WfoXCircleFill } from '@/icons' ;
8+ import { PATH_TASKS , WfoHeaderBadge } from '@/components' ;
9+ import { useOrchestratorTheme , useWithOrchestratorTheme } from '@/hooks' ;
10+ import { WfoCheckmarkCircleFill , WfoXCircleFill } from '@/icons' ;
1111import {
1212 ProcessStatusCounts ,
1313 useProcessStatusCountsQuery ,
1414} from '@/rtk/endpoints/processStatusCounts' ;
1515
16+ import { getTasksBadgeStyles } from './styles' ;
17+
1618type TaskCountsSummary = {
1719 failed : number ;
1820 inconsistentData : number ;
@@ -36,9 +38,22 @@ const getTaskCountsSummary = (
3638 } ;
3739} ;
3840
41+ const WfoTasksLink = ( { children } : { children : ReactNode } ) => (
42+ < Link
43+ href = { `${ PATH_TASKS } ` }
44+ onClick = { ( e ) => {
45+ e . currentTarget . blur ( ) ;
46+ } }
47+ >
48+ { children }
49+ </ Link >
50+ ) ;
51+
3952export const WfoFailedTasksBadge = ( ) => {
4053 const t = useTranslations ( 'common' ) ;
4154 const { theme } = useOrchestratorTheme ( ) ;
55+ const { failedTaskBadgeStyle } =
56+ useWithOrchestratorTheme ( getTasksBadgeStyles ) ;
4257 const { data : processStatusCounts } = useProcessStatusCountsQuery ( ) ;
4358
4459 const taskCountsSummary = getTaskCountsSummary ( processStatusCounts ) ;
@@ -60,15 +75,18 @@ export const WfoFailedTasksBadge = () => {
6075 </ >
6176 }
6277 >
63- < WfoHeaderBadge
64- color = { theme . colors . ghost }
65- textColor = { theme . colors . shadow }
66- iconType = { ( ) => (
67- < WfoXCircleFill color = { theme . colors . danger } />
68- ) }
69- >
70- { taskCountsSummary . total }
71- </ WfoHeaderBadge >
78+ < WfoTasksLink >
79+ < WfoHeaderBadge
80+ css = { failedTaskBadgeStyle }
81+ color = { theme . colors . ghost }
82+ textColor = { theme . colors . shadow }
83+ iconType = { ( ) => (
84+ < WfoXCircleFill color = { theme . colors . danger } />
85+ ) }
86+ >
87+ { taskCountsSummary . total }
88+ </ WfoHeaderBadge >
89+ </ WfoTasksLink >
7290 </ EuiToolTip >
7391 ) ;
7492 } else {
@@ -81,15 +99,20 @@ export const WfoFailedTasksBadge = () => {
8199 </ >
82100 }
83101 >
84- < WfoHeaderBadge
85- color = { theme . colors . ghost }
86- textColor = { theme . colors . shadow }
87- iconType = { ( ) => (
88- < WfoCheckmarkCircleFill color = { theme . colors . success } />
89- ) }
90- >
91- 0
92- </ WfoHeaderBadge >
102+ < WfoTasksLink >
103+ < WfoHeaderBadge
104+ css = { failedTaskBadgeStyle }
105+ color = { theme . colors . ghost }
106+ textColor = { theme . colors . shadow }
107+ iconType = { ( ) => (
108+ < WfoCheckmarkCircleFill
109+ color = { theme . colors . success }
110+ />
111+ ) }
112+ >
113+ 0
114+ </ WfoHeaderBadge >
115+ </ WfoTasksLink >
93116 </ EuiToolTip >
94117 ) ;
95118 }
0 commit comments