Skip to content

Commit 56e259a

Browse files
Link to workflow search from Workflow ID breadcrumb (#706)
* Add workflow link in breadcrumb * Add a type annotation * Add another type annotation
1 parent e76050b commit 56e259a

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

src/views/workflow-page/workflow-page-header/__tests__/workflow-page-header.test.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import React from 'react';
22

33
import { render } from '@/test-utils/rtl';
44

5-
import WorkflowPageHeader from '../workflow-page-header'; // Import the component
5+
import WorkflowPageHeader from '../workflow-page-header';
66
import type { Props } from '../workflow-page-header.types';
77

8+
jest.mock('query-string', () => ({
9+
stringifyUrl: jest.fn(() => 'mock-stringified-api-url'),
10+
}));
11+
812
jest.mock(
913
'../../workflow-page-status-tag/workflow-page-status-tag',
1014
() =>
@@ -29,14 +33,17 @@ describe('WorkflowPageHeader', () => {
2933
);
3034
});
3135

32-
it('renders breadcrumbs with correct workflowId content and link', () => {
36+
it('renders breadcrumbs with correct workflowId content and query-string stringified link', () => {
3337
const workflowId = 'test-workflowId';
3438
const { getByText } = setup({ workflowId });
3539

3640
// Verify workflowId breadcrumb
3741
const workflowIdBreadcrumb = getByText(workflowId);
3842
expect(workflowIdBreadcrumb).toBeInTheDocument();
39-
expect(workflowIdBreadcrumb).toHaveAttribute('href', `/#`);
43+
expect(workflowIdBreadcrumb).toHaveAttribute(
44+
'href',
45+
'/mock-stringified-api-url'
46+
);
4047
});
4148

4249
it('renders breadcrumbs with correct runId and status tag', () => {

src/views/workflow-page/workflow-page-header/workflow-page-header.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ import { Breadcrumbs } from 'baseui/breadcrumbs';
55
import { StyledLink } from 'baseui/link';
66
import Image from 'next/image';
77
import Link from 'next/link';
8+
import queryString from 'query-string';
89

910
import cadenceLogoBlack from '@/assets/cadence-logo-black.svg';
1011
import ErrorBoundary from '@/components/error-boundary/error-boundary';
1112
import PageSection from '@/components/page-section/page-section';
13+
import { type PageQueryParamSetterValues } from '@/hooks/use-page-query-params/use-page-query-params.types';
1214
import useStyletronClasses from '@/hooks/use-styletron-classes';
15+
import type domainPageQueryParamsConfig from '@/views/domain-page/config/domain-page-query-params.config';
16+
import type domainPageTabsConfig from '@/views/domain-page/config/domain-page-tabs.config';
1317

1418
import WorkflowPageStatusTag from '../workflow-page-status-tag/workflow-page-status-tag';
1519

@@ -23,6 +27,7 @@ export default function WorkflowPageHeader({
2327
cluster,
2428
}: Props) {
2529
const { cls } = useStyletronClasses(cssStyles);
30+
const domainLink = `/domains/${encodeURIComponent(domain)}/${encodeURIComponent(cluster)}`;
2631
return (
2732
<PageSection>
2833
<Breadcrumbs
@@ -36,15 +41,26 @@ export default function WorkflowPageHeader({
3641
alt="Cadence Icon"
3742
src={cadenceLogoBlack}
3843
/>
39-
<StyledLink
40-
$as={Link}
41-
href={`/domains/${encodeURIComponent(domain)}/${encodeURIComponent(cluster)}`}
42-
>
44+
<StyledLink $as={Link} href={domainLink}>
4345
{domain}
4446
</StyledLink>
4547
</div>
46-
{/** TODO: @assem.hafez change those to actual links */}
47-
<StyledLink $as={Link} href="#">
48+
<StyledLink
49+
$as={Link}
50+
href={queryString.stringifyUrl({
51+
url:
52+
domainLink +
53+
'/' +
54+
// ensuring that this tab exists in config
55+
('workflows' satisfies (typeof domainPageTabsConfig)[number]['key']),
56+
// ensuring that these query params exist in config
57+
query: {
58+
search: workflowId,
59+
} satisfies Partial<
60+
PageQueryParamSetterValues<typeof domainPageQueryParamsConfig>
61+
>,
62+
})}
63+
>
4864
{workflowId}
4965
</StyledLink>
5066
<div className={cls.breadcrumbItemContainer}>

0 commit comments

Comments
 (0)