Skip to content

Commit 19a0f66

Browse files
feat: History V2 - Event Details parsers (copied from V1) + JSON viewer (#1103)
* Copy Event Details parsers from History Page V1 to History Page V2, with slightly modified types (forceWrap has been replaced with showInPanels) to support the new designs * Add WorkflowHistoryGroupDetailsJson component for rendering JSON in panels Signed-off-by: Adhitya Mamallan <[email protected]>
1 parent a5ae89a commit 19a0f66

9 files changed

+925
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import { createElement } from 'react';
2+
3+
import formatDate from '@/utils/data-formatters/format-date';
4+
import formatDuration from '@/utils/data-formatters/format-duration';
5+
import WorkflowEventDetailsExecutionLink from '@/views/shared/workflow-event-details-execution-link/workflow-event-details-execution-link';
6+
import WorkflowHistoryEventDetailsPlaceholderText from '@/views/workflow-history/workflow-history-event-details-placeholder-text/workflow-history-event-details-placeholder-text';
7+
8+
import WorkflowHistoryEventDetailsTaskListLink from '../../shared/workflow-history-event-details-task-list-link/workflow-history-event-details-task-list-link';
9+
import { type EventDetailsConfig } from '../workflow-history-event-details/workflow-history-event-details.types';
10+
import WorkflowHistoryGroupDetailsJson from '../workflow-history-group-details-json/workflow-history-group-details-json';
11+
12+
const workflowHistoryEventGroupDetailsConfig = [
13+
{
14+
name: 'Filter empty value',
15+
customMatcher: ({ value }) => value === null || value === undefined,
16+
hide: () => true,
17+
},
18+
{
19+
name: 'Filter unneeded values',
20+
pathRegex: '(taskId|eventType)$',
21+
hide: () => true,
22+
},
23+
{
24+
name: 'Not set placeholder',
25+
customMatcher: ({ value, path }) => {
26+
return (
27+
value === 0 &&
28+
new RegExp(
29+
'(heartbeatTimeoutSeconds|retryPolicy\\.(maximumAttempts|expirationIntervalInSeconds))$'
30+
).test(path)
31+
);
32+
},
33+
getLabel: ({ key }) => key.replace(/InSeconds|Seconds|$/, ''), // remove seconds suffix from label as formatted duration can be minutes/hours etc.
34+
valueComponent: () =>
35+
createElement(WorkflowHistoryEventDetailsPlaceholderText),
36+
},
37+
{
38+
name: 'Date object as time string',
39+
customMatcher: ({ value }) => value instanceof Date,
40+
valueComponent: ({ entryValue }) => formatDate(entryValue),
41+
},
42+
{
43+
name: 'Tasklists as links',
44+
key: 'taskList',
45+
valueComponent: ({ entryValue, domain, cluster }) => {
46+
return createElement(WorkflowHistoryEventDetailsTaskListLink, {
47+
domain: domain,
48+
cluster: cluster,
49+
taskList: entryValue,
50+
});
51+
},
52+
},
53+
{
54+
name: 'Json in panels',
55+
pathRegex:
56+
'(input|result|details|failureDetails|Error|lastCompletionResult|heartbeatDetails|lastFailureDetails)$',
57+
showInPanels: true,
58+
valueComponent: WorkflowHistoryGroupDetailsJson,
59+
},
60+
{
61+
name: 'Duration & interval seconds',
62+
pathRegex: '(TimeoutSeconds|BackoffSeconds|InSeconds)$',
63+
getLabel: ({ key }) => key.replace(/InSeconds|Seconds|$/, ''), // remove seconds suffix from label as formatted duration can be minutes/hours etc.
64+
valueComponent: ({ entryValue }) =>
65+
formatDuration({ seconds: entryValue > 0 ? entryValue : 0, nanos: 0 }),
66+
},
67+
{
68+
name: 'WorkflowExecution as link',
69+
pathRegex:
70+
'(parentWorkflowExecution|externalWorkflowExecution|workflowExecution)$',
71+
valueComponent: ({ entryValue, domain, cluster }) => {
72+
return createElement(WorkflowEventDetailsExecutionLink, {
73+
domain,
74+
cluster,
75+
workflowId: entryValue?.workflowId,
76+
runId: entryValue?.runId,
77+
});
78+
},
79+
},
80+
{
81+
name: 'RunIds as link',
82+
pathRegex:
83+
'(firstExecutionRunId|originalExecutionRunId|newExecutionRunId|continuedExecutionRunId)$',
84+
valueComponent: ({ entryValue, domain, cluster, workflowId }) => {
85+
return createElement(WorkflowEventDetailsExecutionLink, {
86+
domain,
87+
cluster,
88+
workflowId,
89+
runId: entryValue,
90+
});
91+
},
92+
},
93+
{
94+
name: 'Retry config attempt as retryAttempt',
95+
key: 'attempt',
96+
getLabel: () => 'retryAttempt',
97+
},
98+
] as const satisfies EventDetailsConfig[];
99+
100+
export default workflowHistoryEventGroupDetailsConfig;

0 commit comments

Comments
 (0)