Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add retries to summary fields
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
  • Loading branch information
adhityamamallan committed Dec 3, 2025
commit ad922a4482e7f4cafc734b9abaf25ce1867e07f3
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { MdOutlineMonitorHeart, MdOutlineTimer } from 'react-icons/md';
import {
MdHourglassBottom,
MdOutlineMonitorHeart,
MdReplay,
} from 'react-icons/md';

import { type WorkflowHistoryEventSummaryFieldParser } from '../workflow-history-event-summary/workflow-history-event-summary.types';
import WorkflowHistoryEventSummaryJson from '../workflow-history-event-summary-json/workflow-history-event-summary-json';
Expand All @@ -25,7 +29,14 @@ const workflowHistoryEventSummaryFieldParsersConfig: Array<WorkflowHistoryEventS
name: 'Timeouts with timer icon',
matcher: (name) =>
new RegExp('(TimeoutSeconds|BackoffSeconds|InSeconds)$').test(name),
icon: MdOutlineTimer,
icon: MdHourglassBottom,
},
{
name: 'Retries with retry icon',
matcher: (name) => name === 'attempt',
shouldHide: (_, value) => typeof value === 'number' && value <= 0,
icon: MdReplay,
tooltipLabel: 'retries',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,38 @@ jest.mock(
isGroup: true,
groupEntries: [],
},
{
key: 'hiddenField',
path: 'hiddenField',
value: 'hide-me',
renderConfig: {
name: 'Test Config',
key: 'test',
getLabel: ({ path }) => `Label: ${path}`,
},
isGroup: false,
},
{
key: 'tooltipField',
path: 'tooltipField',
value: 'test-value',
renderConfig: {
name: 'Test Config',
key: 'test',
getLabel: ({ path }) => `Label: ${path}`,
},
isGroup: false,
},
{
key: 'defaultPathField',
path: 'defaultPathField',
value: 'test-value',
renderConfig: {
name: 'Test Config',
key: 'test',
},
isGroup: false,
},
] satisfies WorkflowHistoryEventDetailsEntries
)
);
Expand Down Expand Up @@ -112,6 +144,18 @@ jest.mock(
matcher: (path) => path === 'firstExecutionRunId',
icon: jest.fn(),
},
{
name: 'Hidden Field Parser',
matcher: (path) => path === 'hiddenField',
icon: jest.fn(),
shouldHide: jest.fn((_, value) => value === 'hide-me'),
},
{
name: 'Tooltip Label Parser',
matcher: (path) => path === 'tooltipField',
icon: jest.fn(),
tooltipLabel: 'Custom Tooltip Label',
},
] satisfies Array<WorkflowHistoryEventSummaryFieldParser>
);

Expand Down Expand Up @@ -279,4 +323,46 @@ describe(getHistoryEventSummaryItems.name, () => {
expect(result[0].path).toBe('workflowExecution');
expect(result[0].renderValue).toBeDefined();
});

it('should exclude fields when shouldHide returns true', () => {
const details = { hiddenField: 'hide-me' };
const summaryFields = ['hiddenField'];

const result = getHistoryEventSummaryItems({ details, summaryFields });

expect(result).toHaveLength(0);
});

it('should use tooltipLabel from parser config when set', () => {
const details = { tooltipField: 'test-value' };
const summaryFields = ['tooltipField'];

const result = getHistoryEventSummaryItems({ details, summaryFields });

expect(result).toHaveLength(1);
expect(result[0].path).toBe('tooltipField');
expect(result[0].label).toBe('Custom Tooltip Label');
});

it('should use getLabel from renderConfig when tooltipLabel is not set in parser config', () => {
const details = { input: { data: 'test' } };
const summaryFields = ['input'];

const result = getHistoryEventSummaryItems({ details, summaryFields });

expect(result).toHaveLength(1);
expect(result[0].path).toBe('input');
expect(result[0].label).toBe('Label: input');
});

it('should default to path when neither tooltipLabel nor getLabel is available', () => {
const details = { defaultPathField: 'test-value' };
const summaryFields = ['defaultPathField'];

const result = getHistoryEventSummaryItems({ details, summaryFields });

expect(result).toHaveLength(1);
expect(result[0].path).toBe('defaultPathField');
expect(result[0].label).toBe('defaultPathField');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default function getHistoryEventSummaryItems({
);

let renderValue: ComponentType<EventSummaryValueComponentProps>;
if (summaryFieldParserConfig?.customRenderValue) {
if (summaryFieldParserConfig?.shouldHide?.(path, value)) {
return acc;
} else if (summaryFieldParserConfig?.customRenderValue) {
renderValue = summaryFieldParserConfig.customRenderValue;
} else if (renderConfig?.valueComponent) {
const detailsRenderValue = renderConfig?.valueComponent;
Expand All @@ -49,9 +51,15 @@ export default function getHistoryEventSummaryItems({
renderValue = ({ value }) => String(value);
}

let tooltipLabel = path;
if (summaryFieldParserConfig?.tooltipLabel) {
tooltipLabel = summaryFieldParserConfig.tooltipLabel;
} else if (renderConfig?.getLabel)
tooltipLabel = renderConfig.getLabel({ key, path, value });

acc.push({
path,
label: renderConfig?.getLabel?.({ key, path, value }) ?? path,
label: tooltipLabel,
value,
icon: summaryFieldParserConfig?.icon ?? null,
renderValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export type WorkflowHistoryEventSummaryFieldParser = {
size?: IconProps['size'];
color?: IconProps['color'];
}> | null;
shouldHide?: (path: string, value: unknown) => boolean;
tooltipLabel?: string;
customRenderValue?: ComponentType<EventSummaryValueComponentProps>;
hideDefaultTooltip?: boolean;
};
Expand Down