Skip to content

Commit 3d62cfc

Browse files
authored
Nexus Links tab (#2821)
* Add Nexus Links tab and show table of unique links from history * Fix title of Nexus Links * Update logic to find requestId from workflowExtendedInfos * Update outbound table * Comment out rows for now * Fix undefined issues, check for nexus type for outbound links * Fix type imports, update tables * Update column order and add links * Remove handler event in inbound table * Remove console.log * Use event history for inbound links * Use more specific attributes for nexus scheduled events * Remove inspect, add try/catch for links, fix nexus active icon logic to be more precise
1 parent 956e152 commit 3d62cfc

15 files changed

Lines changed: 367 additions & 54 deletions

File tree

src/lib/i18n/locales/en/common.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export const Strings = {
6868
'workflow-type': 'Workflow Type',
6969
'workflow-id': 'Workflow ID',
7070
'run-id': 'Run ID',
71+
'event-id': 'Event ID',
72+
'event-type': 'Event Type',
73+
'request-id': 'Request ID',
7174
'task-queue': 'Task Queue',
7275
preview: 'Preview',
7376
status: 'Status',

src/lib/i18n/locales/en/nexus.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,19 @@ export const Strings = {
6060
'last-attempt-failure': 'Last Attempt Failure',
6161
'blocked-reason': 'Blocked Reason',
6262
link: 'Link',
63+
'links-empty-state': 'No Nexus Links found.',
6364
'link-namespace': 'Link Namespace',
65+
'nexus-service': 'Nexus Service',
66+
'nexus-endpoint-simple': 'Nexus Endpoint',
67+
'nexus-operation': 'Nexus Operation',
68+
'caller-event': 'Caller Event',
69+
'caller-link': 'Caller Link',
70+
'caller-workflow': 'Caller Workflow',
71+
'source-event': 'Source Event',
72+
'caller-namespace': 'Caller Namespace',
73+
'handler-namespace': 'Handler Namespace',
74+
'handler-workflow': 'Handler Workflow',
75+
'handler-event': 'Handler Event',
6476
service: 'Service',
6577
operation: 'Operation',
6678
'operation-token': 'Operation Token',

src/lib/i18n/locales/en/workflows.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export const Strings = {
125125
'workflow-history': 'Workflow History',
126126
'workers-tab': 'Workers',
127127
'pending-activities-tab': 'Pending Activities',
128+
'nexus-links-tab': 'Nexus Links',
128129
'call-stack-tab': 'Call Stack',
129130
'queries-tab': 'Queries',
130131
'metadata-tab': 'Metadata',

src/lib/layouts/workflow-header.svelte

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,23 @@
1818
import Tab from '$lib/holocene/tab/tab.svelte';
1919
import Tabs from '$lib/holocene/tab/tabs.svelte';
2020
import { translate } from '$lib/i18n/translate';
21+
import { getInboundNexusLinkEvents } from '$lib/runes/inbound-nexus-links.svelte';
2122
import { getWorkflowPollersWithVersions } from '$lib/runes/workflow-versions.svelte';
2223
import { fullEventHistory } from '$lib/stores/events';
2324
import { namespaces } from '$lib/stores/namespaces';
2425
import { resetWorkflows } from '$lib/stores/reset-workflows';
2526
import { workflowRun } from '$lib/stores/workflow-run';
2627
import { workflowsSearchParams } from '$lib/stores/workflows';
2728
import { isCancelInProgress } from '$lib/utilities/cancel-in-progress';
28-
import { getWorkflowRelationships } from '$lib/utilities/get-workflow-relationships';
29+
import {
30+
getWorkflowNexusLinksFromHistory,
31+
getWorkflowRelationships,
32+
} from '$lib/utilities/get-workflow-relationships';
2933
import { pathMatches } from '$lib/utilities/path-matches';
3034
import {
3135
routeForCallStack,
3236
routeForEventHistory,
37+
routeForNexusLinks,
3338
routeForPendingActivities,
3439
routeForRelationships,
3540
routeForWorkers,
@@ -64,6 +69,10 @@
6469
$fullEventHistory,
6570
$namespaces,
6671
);
72+
$: outboundLinks =
73+
getWorkflowNexusLinksFromHistory($fullEventHistory)?.length || 0;
74+
$: inboundLinks = getInboundNexusLinkEvents($fullEventHistory)?.length || 0;
75+
$: linkCount = outboundLinks + inboundLinks;
6776
</script>
6877

6978
<div class="flex items-center justify-between pb-4">
@@ -204,6 +213,21 @@
204213
{workflowRelationships.relationshipCount}
205214
</Badge></Tab
206215
>
216+
{#if linkCount > 0}
217+
<Tab
218+
label={translate('workflows.nexus-links-tab')}
219+
id="nexus-links-tab"
220+
href={routeForNexusLinks(routeParameters)}
221+
active={pathMatches(
222+
$page.url.pathname,
223+
routeForNexusLinks(routeParameters),
224+
)}
225+
>
226+
<Badge type="primary" class="px-2 py-0">
227+
{linkCount}
228+
</Badge>
229+
</Tab>
230+
{/if}
207231
<Tab
208232
label={translate('workflows.workers-tab')}
209233
id="workers-tab"
@@ -232,7 +256,8 @@
232256
class="px-2 py-0"
233257
>
234258
<div class="flex items-center gap-1">
235-
{#if activitiesCanceled}<Icon name="canceled" />
259+
{#if activitiesCanceled}
260+
<Icon name="canceled" />
236261
{/if}
237262
{workflow?.pendingActivities?.length}
238263
</div>

src/lib/models/event-groups/event-groups.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { Payload } from '$lib/types';
1+
import type { EventLink, Payload } from '$lib/types';
22
import type {
3-
EventLink,
43
PendingActivity,
54
PendingNexusOperation,
65
WorkflowEvent,

src/lib/pages/workflow-history-event.svelte

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<script lang="ts">
2-
import { page } from '$app/stores';
2+
import { onMount } from 'svelte';
3+
4+
import { page } from '$app/state';
35
46
import EventSummaryRow from '$lib/components/event/event-summary-row.svelte';
57
import Button from '$lib/holocene/button.svelte';
@@ -9,16 +11,15 @@
911
import { eventFilterSort } from '$lib/stores/event-view';
1012
import { fullEventHistory } from '$lib/stores/events';
1113
import { workflowRun } from '$lib/stores/workflow-run';
12-
import { isNexusOperationScheduledEvent } from '$lib/utilities/is-event-type';
1314
14-
$: ({
15+
const {
1516
id: eventId,
1617
namespace,
1718
workflow: workflowId,
1819
run: runId,
19-
} = $page.params);
20+
} = $derived(page.params);
2021
21-
$: ids = [eventId];
22+
let ids = $derived([eventId]);
2223
2324
const resetFullHistory = () => {
2425
$fullEventHistory = [];
@@ -39,33 +40,46 @@
3940
}
4041
};
4142
42-
$: fetchEvents(namespace, workflowId, runId);
43-
44-
$: ({ workflow } = $workflowRun);
45-
$: pendingActivities = workflow?.pendingActivities;
46-
$: pendingNexusOperations = workflow?.pendingNexusOperations;
47-
48-
$: ascendingGroups = groupEvents(
49-
$fullEventHistory,
50-
'ascending',
51-
pendingActivities,
52-
pendingNexusOperations,
43+
onMount(() => {
44+
fetchEvents(namespace, workflowId, runId);
45+
});
46+
47+
const { workflow } = $derived($workflowRun);
48+
const pendingActivities = $derived(workflow?.pendingActivities);
49+
const pendingNexusOperations = $derived(workflow?.pendingNexusOperations);
50+
51+
const ascendingGroups = $derived(
52+
groupEvents(
53+
$fullEventHistory,
54+
'ascending',
55+
pendingActivities,
56+
pendingNexusOperations,
57+
),
5358
);
54-
$: groups =
59+
const groups = $derived(
5560
$eventFilterSort === 'ascending'
5661
? ascendingGroups
57-
: [...ascendingGroups].reverse();
62+
: [...ascendingGroups].reverse(),
63+
);
5864
59-
$: initialEvent = $fullEventHistory.find(
60-
(e) =>
61-
eventId === e.id ||
62-
(isNexusOperationScheduledEvent(e) &&
63-
eventId === e.attributes?.requestId),
65+
const initialEvent = $derived(
66+
$fullEventHistory.find(
67+
(e) =>
68+
e.id === eventId ||
69+
e.id ===
70+
workflow.workflowExtendedInfo?.requestIdInfos?.[eventId]?.eventId,
71+
),
6472
);
65-
$: visibleItems = $fullEventHistory.filter(
66-
(e) => ids.includes(e.id) || e.id === initialEvent?.id,
73+
74+
const visibleItems = $derived(
75+
$fullEventHistory.filter(
76+
(e) => ids.includes(e.id) || e.id === initialEvent?.id,
77+
),
78+
);
79+
const loading = $derived(!visibleItems.length);
80+
const lastEventId = $derived(
81+
$fullEventHistory[$fullEventHistory.length - 1]?.id,
6782
);
68-
$: loading = !visibleItems.length;
6983
7084
const loadPrevious = () => {
7185
const firstId = parseInt(ids[0]);
@@ -94,8 +108,6 @@
94108
95109
ids = [...ids, ...nextTen];
96110
};
97-
98-
$: lastEventId = $fullEventHistory[$fullEventHistory.length - 1]?.id;
99111
</script>
100112

101113
<div

0 commit comments

Comments
 (0)