-
Notifications
You must be signed in to change notification settings - Fork 125
feat: Show summarized history event details in event group row #1106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adhityamamallan
merged 14 commits into
cadence-workflow:master
from
adhityamamallan:history-single-line-summary
Dec 10, 2025
+962
−7
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f831a6f
Copy utils from v1 to v2
adhityamamallan 54bb041
Add JSON component and allow custom components for panels
adhityamamallan 9a9ed3c
add changes
adhityamamallan 34f3e34
More changes
adhityamamallan 23683ec
Add unit tests and isolate prop types
adhityamamallan f513c7a
address comments
adhityamamallan b0ceb52
Add single-line summary for history events
adhityamamallan ea0f3b7
fix type error in test
adhityamamallan 7d80bde
Fix files and add tests
adhityamamallan e08dedc
address copilot comments
adhityamamallan b2c47cd
Merge branch 'master' into history-single-line-summary
adhityamamallan c146046
Merge branch 'master' into history-single-line-summary
adhityamamallan ce323ff
Merge branch 'master' into history-single-line-summary
adhityamamallan 350bac6
remove negative margins from summary items container
adhityamamallan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/views/workflow-history-v2/config/workflow-history-details-row-parsers.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { | ||
| MdHourglassBottom, | ||
| MdOutlineMonitorHeart, | ||
| MdReplay, | ||
| } from 'react-icons/md'; | ||
|
|
||
| import { type DetailsRowItemParser } from '../workflow-history-details-row/workflow-history-details-row.types'; | ||
| import WorkflowHistoryDetailsRowJson from '../workflow-history-details-row-json/workflow-history-details-row-json'; | ||
| import WorkflowHistoryDetailsRowTooltipJson from '../workflow-history-details-row-tooltip-json/workflow-history-details-row-tooltip-json'; | ||
|
|
||
| const workflowHistoryDetailsRowParsersConfig: Array<DetailsRowItemParser> = [ | ||
| { | ||
| name: 'Heartbeat time', | ||
| matcher: (name) => name === 'lastHeartbeatTime', | ||
| icon: MdOutlineMonitorHeart, | ||
| }, | ||
| { | ||
| name: 'Json as PrettyJson', | ||
| matcher: (name, value) => | ||
| value !== null && | ||
| new RegExp( | ||
| '(input|result|details|failureDetails|Error|lastCompletionResult|heartbeatDetails|lastFailureDetails)$' | ||
| ).test(name), | ||
| icon: null, | ||
| customRenderValue: WorkflowHistoryDetailsRowJson, | ||
| customTooltipContent: WorkflowHistoryDetailsRowTooltipJson, | ||
| invertTooltipColors: true, | ||
| }, | ||
| { | ||
| name: 'Timeouts with timer icon', | ||
| matcher: (name) => | ||
| new RegExp('(TimeoutSeconds|BackoffSeconds|InSeconds)$').test(name), | ||
| icon: MdHourglassBottom, | ||
| }, | ||
| { | ||
| name: '"attempt" greater than 1, as "retries"', | ||
adhityamamallan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| matcher: (name) => name === 'attempt', | ||
| hide: (_, value) => typeof value === 'number' && value <= 0, | ||
| icon: MdReplay, | ||
| customTooltipContent: () => 'retries', | ||
| }, | ||
| ]; | ||
|
|
||
| export default workflowHistoryDetailsRowParsersConfig; | ||
23 changes: 23 additions & 0 deletions
23
...v2/workflow-history-details-row-json/__tests__/workflow-history-details-row-json.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { render, screen } from '@/test-utils/rtl'; | ||
|
|
||
| import WorkflowHistoryDetailsRowJson from '../workflow-history-details-row-json'; | ||
|
|
||
| describe(WorkflowHistoryDetailsRowJson.name, () => { | ||
| it('renders the stringified JSON value', () => { | ||
| render( | ||
| <WorkflowHistoryDetailsRowJson | ||
| value={{ key: 'value', nested: { number: 123 } }} | ||
| isNegative={false} | ||
| label="test-label" | ||
| domain="test-domain" | ||
| cluster="test-cluster" | ||
| workflowId="test-workflow-id" | ||
| runId="test-run-id" | ||
| /> | ||
| ); | ||
|
|
||
| expect( | ||
| screen.getByText('{"key":"value","nested":{"number":123}}') | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); |
15 changes: 15 additions & 0 deletions
15
...-history-v2/workflow-history-details-row-json/workflow-history-details-row-json.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { styled as createStyled } from 'baseui'; | ||
|
|
||
| export const styled = { | ||
| JsonViewContainer: createStyled<'div', { $isNegative: boolean }>( | ||
| 'div', | ||
| ({ $theme, $isNegative }) => ({ | ||
| color: $isNegative ? $theme.colors.contentNegative : '#A964F7', | ||
adhityamamallan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| maxWidth: '360px', | ||
| overflow: 'hidden', | ||
| whiteSpace: 'nowrap', | ||
| textOverflow: 'ellipsis', | ||
| ...$theme.typography.MonoParagraphXSmall, | ||
| }) | ||
| ), | ||
| }; | ||
16 changes: 16 additions & 0 deletions
16
...rkflow-history-v2/workflow-history-details-row-json/workflow-history-details-row-json.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import losslessJsonStringify from '@/utils/lossless-json-stringify'; | ||
|
|
||
| import { type DetailsRowValueComponentProps } from '../workflow-history-details-row/workflow-history-details-row.types'; | ||
|
|
||
| import { styled } from './workflow-history-details-row-json.styles'; | ||
|
|
||
| export default function WorkflowHistoryDetailsRowJson({ | ||
| value, | ||
| isNegative, | ||
| }: DetailsRowValueComponentProps) { | ||
| return ( | ||
| <styled.JsonViewContainer $isNegative={isNegative ?? false}> | ||
| {losslessJsonStringify(value)} | ||
| </styled.JsonViewContainer> | ||
| ); | ||
| } |
3 changes: 3 additions & 0 deletions
3
...w-history-v2/workflow-history-details-row-json/workflow-history-details-row-json.types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { type DetailsRowValueComponentProps } from '../workflow-history-details-row/workflow-history-details-row.types'; | ||
|
|
||
| export type Props = DetailsRowValueComponentProps; |
38 changes: 38 additions & 0 deletions
38
...ory-details-row-tooltip-json/__tests__/workflow-history-details-row-tooltip-json.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { render, screen } from '@/test-utils/rtl'; | ||
|
|
||
| import WorkflowHistoryDetailsRowTooltipJson from '../workflow-history-details-row-tooltip-json'; | ||
|
|
||
| jest.mock( | ||
| '@/views/workflow-history/workflow-history-event-details-json/workflow-history-event-details-json', | ||
| () => | ||
| jest.fn(({ entryValue, isNegative }) => ( | ||
| <div data-testid="event-details-json"> | ||
| Event Details Json: {JSON.stringify(entryValue)} | ||
| {isNegative && ' (negative)'} | ||
| </div> | ||
| )) | ||
| ); | ||
|
|
||
| describe(WorkflowHistoryDetailsRowTooltipJson.name, () => { | ||
| it('renders the label and passes value to WorkflowHistoryEventDetailsJson', () => { | ||
| render( | ||
| <WorkflowHistoryDetailsRowTooltipJson | ||
| value={{ key: 'value', nested: { number: 123 } }} | ||
| label="test-label" | ||
| isNegative={false} | ||
| domain="test-domain" | ||
| cluster="test-cluster" | ||
| workflowId="test-workflow-id" | ||
| runId="test-run-id" | ||
| /> | ||
| ); | ||
|
|
||
| expect(screen.getByText('test-label')).toBeInTheDocument(); | ||
| expect(screen.getByTestId('event-details-json')).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText( | ||
| /Event Details Json: \{"key":"value","nested":\{"number":123\}\}/ | ||
| ) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); |
13 changes: 13 additions & 0 deletions
13
...flow-history-details-row-tooltip-json/workflow-history-details-row-tooltip-json.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { styled as createStyled } from 'baseui'; | ||
|
|
||
| export const styled = { | ||
| JsonPreviewContainer: createStyled('div', ({ $theme }) => ({ | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| alignItems: 'flex-start', | ||
| gap: $theme.sizing.scale200, | ||
| })), | ||
| JsonPreviewLabel: createStyled('div', ({ $theme }) => ({ | ||
| ...$theme.typography.LabelXSmall, | ||
| })), | ||
| }; |
21 changes: 21 additions & 0 deletions
21
...2/workflow-history-details-row-tooltip-json/workflow-history-details-row-tooltip-json.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import WorkflowHistoryEventDetailsJson from '@/views/workflow-history/workflow-history-event-details-json/workflow-history-event-details-json'; | ||
|
|
||
| import { type DetailsRowValueComponentProps } from '../workflow-history-details-row/workflow-history-details-row.types'; | ||
|
|
||
| import { styled } from './workflow-history-details-row-tooltip-json.styles'; | ||
|
|
||
| export default function WorkflowHistoryDetailsRowTooltipJson({ | ||
| value, | ||
| label, | ||
| isNegative, | ||
| }: DetailsRowValueComponentProps) { | ||
| return ( | ||
| <styled.JsonPreviewContainer> | ||
| <styled.JsonPreviewLabel>{label}</styled.JsonPreviewLabel> | ||
| <WorkflowHistoryEventDetailsJson | ||
| entryValue={value} | ||
| isNegative={isNegative} | ||
| /> | ||
| </styled.JsonPreviewContainer> | ||
| ); | ||
| } |
3 changes: 3 additions & 0 deletions
3
...kflow-history-details-row-tooltip-json/workflow-history-details-row-tooltip-json.types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { type DetailsRowValueComponentProps } from '../workflow-history-details-row/workflow-history-details-row.types'; | ||
|
|
||
| export type Props = DetailsRowValueComponentProps; |
136 changes: 136 additions & 0 deletions
136
...w-history-v2/workflow-history-details-row/__tests__/workflow-history-details-row.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| import { render, screen, userEvent } from '@/test-utils/rtl'; | ||
|
|
||
| import type { WorkflowPageParams } from '@/views/workflow-page/workflow-page.types'; | ||
|
|
||
| import { type EventDetailsEntries } from '../../workflow-history-event-details/workflow-history-event-details.types'; | ||
| import WorkflowHistoryDetailsRow from '../workflow-history-details-row'; | ||
| import { type DetailsRowItem } from '../workflow-history-details-row.types'; | ||
|
|
||
| jest.mock('../helpers/get-parsed-details-row-items', () => | ||
| jest.fn((detailsEntries: EventDetailsEntries) => | ||
| detailsEntries.reduce<Array<DetailsRowItem>>((acc, entry) => { | ||
| if (!entry.isGroup) { | ||
| acc.push({ | ||
| path: entry.path, | ||
| label: entry.path, | ||
| value: entry.value, | ||
| icon: ({ size }: any) => ( | ||
| <span data-testid={`icon-${entry.path}`} data-size={size} /> | ||
| ), | ||
| renderValue: ({ value, isNegative }: any) => ( | ||
| <span | ||
| data-testid={`field-${entry.path}`} | ||
| data-negative={isNegative} | ||
| > | ||
| {value} | ||
| </span> | ||
| ), | ||
| renderTooltip: ({ label }: any) => ( | ||
| <span data-testid={`tooltip-${entry.path}`}>{label}</span> | ||
| ), | ||
| invertTooltipColors: acc.length === 1, // Second item has inverted tooltip | ||
| omitWrapping: acc.length === 2, // Third item omits wrapping | ||
| }); | ||
| } | ||
| return acc; | ||
| }, []) | ||
| ) | ||
| ); | ||
|
|
||
| const mockWorkflowPageParams: WorkflowPageParams = { | ||
| cluster: 'test-cluster', | ||
| domain: 'test-domain', | ||
| workflowId: 'test-workflow', | ||
| runId: 'test-run', | ||
| }; | ||
|
|
||
| const mockDetailsEntries: EventDetailsEntries = [ | ||
| { | ||
| key: 'field1', | ||
| path: 'field1', | ||
| isGroup: false, | ||
| value: 'value1', | ||
| isNegative: false, | ||
| renderConfig: null, | ||
| }, | ||
| { | ||
| key: 'field2', | ||
| path: 'field2', | ||
| isGroup: false, | ||
| value: 'value2', | ||
| isNegative: true, | ||
| renderConfig: null, | ||
| }, | ||
| { | ||
| key: 'field3', | ||
| path: 'field3', | ||
| isGroup: false, | ||
| value: 'value3', | ||
| isNegative: false, | ||
| renderConfig: null, | ||
| }, | ||
| ]; | ||
|
|
||
| describe(WorkflowHistoryDetailsRow.name, () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('should render details row items when detailsEntries has items', () => { | ||
| setup(); | ||
|
|
||
| expect(screen.getByTestId('field-field1')).toBeInTheDocument(); | ||
| expect(screen.getByTestId('field-field2')).toBeInTheDocument(); | ||
| expect(screen.getByTestId('field-field3')).toBeInTheDocument(); | ||
| expect(screen.getByText('value1')).toBeInTheDocument(); | ||
| expect(screen.getByText('value2')).toBeInTheDocument(); | ||
| expect(screen.getByText('value3')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should mark negative fields correctly', () => { | ||
| setup(); | ||
|
|
||
| const negativeField = screen.getByTestId('field-field2'); | ||
| expect(negativeField).toHaveAttribute('data-negative', 'true'); | ||
|
|
||
| const positiveField = screen.getByTestId('field-field1'); | ||
| expect(positiveField).toHaveAttribute('data-negative', 'false'); | ||
| }); | ||
|
|
||
| it('should render icons when provided in item config', () => { | ||
| setup(); | ||
|
|
||
| expect(screen.getByTestId('icon-field1')).toBeInTheDocument(); | ||
| expect(screen.getByTestId('icon-field2')).toBeInTheDocument(); | ||
| expect(screen.getByTestId('icon-field3')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should render tooltip content on hover', async () => { | ||
| const { user } = setup(); | ||
|
|
||
| const field1 = screen.getByTestId('field-field1'); | ||
| await user.hover(field1); | ||
|
|
||
| expect(await screen.findByTestId('tooltip-field1')).toBeInTheDocument(); | ||
| expect(screen.getByText('field1')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| function setup({ | ||
| detailsEntries = mockDetailsEntries, | ||
| workflowPageParams = mockWorkflowPageParams, | ||
| }: { | ||
| detailsEntries?: EventDetailsEntries; | ||
| workflowPageParams?: WorkflowPageParams; | ||
| } = {}) { | ||
| const user = userEvent.setup(); | ||
|
|
||
| const renderResult = render( | ||
| <WorkflowHistoryDetailsRow | ||
| detailsEntries={detailsEntries} | ||
| {...workflowPageParams} | ||
| /> | ||
| ); | ||
|
|
||
| return { user, ...renderResult }; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.