Skip to content

Commit cdb9c83

Browse files
authored
Add link to task list page when clicking on tasks count icon (#1565)
* Add link to task list page when clicking on tasks count icon * resolved comments
1 parent a442a0b commit cdb9c83

File tree

3 files changed

+61
-23
lines changed

3 files changed

+61
-23
lines changed

.changeset/gorgeous-beers-grow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@orchestrator-ui/orchestrator-ui-components': patch
3+
---
4+
5+
1530 Navigate to task list page when clicking on the tasks count icon

packages/orchestrator-ui-components/src/components/WfoBadges/WfoFailedTasksBadge/WfoFailedTasksBadge.tsx

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import React from 'react';
1+
import React, { ReactNode } from 'react';
22

33
import { useTranslations } from 'next-intl';
4+
import Link from 'next/link';
45

56
import { 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';
1111
import {
1212
ProcessStatusCounts,
1313
useProcessStatusCountsQuery,
1414
} from '@/rtk/endpoints/processStatusCounts';
1515

16+
import { getTasksBadgeStyles } from './styles';
17+
1618
type 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+
3952
export 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
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { css } from '@emotion/react';
2+
3+
export const getTasksBadgeStyles = () => {
4+
const failedTaskBadgeStyle = css({
5+
cursor: 'pointer',
6+
'&:hover': { textDecoration: 'underline' },
7+
});
8+
9+
return { failedTaskBadgeStyle };
10+
};

0 commit comments

Comments
 (0)