Skip to content
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

Show multiple callbacks and WorkflowExecutionUpdateOptions attributes #2574

Merged
merged 7 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = {
$$Generic: 'readonly',
},
rules: {
'@typescript-eslint/ban-ts-comment': 'warn',
quotes: ['error', 'single', { avoidEscape: true }],
'@typescript-eslint/no-unused-vars': [
'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
import Badge from '$lib/holocene/badge.svelte';
import CodeBlock from '$lib/holocene/code-block.svelte';
import { translate } from '$lib/i18n/translate';
import { fullEventHistory } from '$lib/stores/events';
import { timeFormat } from '$lib/stores/time-format';
import type { CallbackState } from '$lib/types';
import type { EventLink as Link } from '$lib/types/events';
import type { Callback } from '$lib/types/nexus';
import { formatDate } from '$lib/utilities/format-date';
import { routeForNamespace } from '$lib/utilities/route-for';

import EventLink from '../event/event-link.svelte';

export let callback: Callback;
export let link: Link | undefined = undefined;

$: completedTime = formatDate(callback.lastAttemptCompleteTime, $timeFormat);
$: nextTime = formatDate(callback.nextAttemptScheduleTime, $timeFormat);
$: failure = callback?.lastAttemptFailure?.message;
$: blockedReason = callback?.blockedReason;
$: callbackUrl = callback?.callback?.nexus?.url;

const titles = {
Standby: translate('nexus.callback.standby'),
Expand All @@ -26,8 +28,6 @@
Failed: translate('nexus.callback.failed'),
Succeeded: translate('nexus.callback.succeeded'),
};
$: initialEvent = $fullEventHistory[0];
$: link = initialEvent?.links[0];

const failedState = 'Failed' as unknown as CallbackState;
$: failed = callback.state === failedState;
Expand Down Expand Up @@ -68,6 +68,12 @@
</p>
{/if}
</div>
{#if !link}
<p class="flex items-center gap-2">
{translate('nexus.callback-url')}
<Badge type="subtle">{callbackUrl}</Badge>
</p>
{/if}
{#if blockedReason}
<p class="flex items-center gap-2">
{translate('nexus.blocked-reason')}
Expand All @@ -86,4 +92,5 @@
</div>
{/if}
</div>
<slot />
</Alert>
33 changes: 33 additions & 0 deletions src/lib/components/workflow/workflow-callbacks.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<script lang="ts">
import AccordionLight from '$lib/holocene/accordion/accordion-light.svelte';
import { fullEventHistory } from '$lib/stores/events';
import type { Callback } from '$lib/types/nexus';

import WorkflowCallback from './workflow-callback.svelte';

export let callbacks: Callback[];

$: initialEvent = $fullEventHistory[0];
$: link = initialEvent?.links?.[0];

$: firstCallback = callbacks[0];
</script>

<WorkflowCallback callback={firstCallback} {link}>
{#if callbacks.length > 1}
<div class="py-2">
<AccordionLight let:open>
<p class="p-1" slot="title">
View {callbacks.length - 1} other Callbacks
</p>
{#if open}
<div class="flex flex-col gap-2">
{#each callbacks.slice(1) as callback}
<WorkflowCallback {callback} />
{/each}
</div>
{/if}
</AccordionLight>
</div>
{/if}
</WorkflowCallback>
2 changes: 1 addition & 1 deletion src/lib/holocene/accordion/accordion-light.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
};
</script>

<div class="w-full" {...$$restProps}>
<div class="w-full {$$restProps.class}">
<button
id="{id}-trigger"
aria-expanded={open}
Expand Down
1 change: 1 addition & 0 deletions src/lib/i18n/locales/en/nexus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const Strings = {
failed: 'Nexus Callback has failed.',
succeeded: 'Nexus Callback has succeeded.',
},
'callback-url': 'Callback URL',
'last-attempt-completed-time': 'Last Attempt Completed Time',
'next-attempt-scheduled-time': 'Next Attempt Scheduled Time',
'last-attempt-failure': 'Last Attempt Failure',
Expand Down
4 changes: 2 additions & 2 deletions src/lib/layouts/workflow-history-layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import EventSummary from '$lib/components/event/event-summary.svelte';
import InputAndResults from '$lib/components/lines-and-dots/input-and-results.svelte';
import TimelineGraph from '$lib/components/lines-and-dots/svg/timeline-graph.svelte';
import WorkflowCallback from '$lib/components/lines-and-dots/workflow-callback.svelte';
import WorkflowError from '$lib/components/lines-and-dots/workflow-error.svelte';
import WorkflowCallStackError from '$lib/components/workflow/workflow-call-stack-error.svelte';
import WorkflowCallbacks from '$lib/components/workflow/workflow-callbacks.svelte';
import { translate } from '$lib/i18n/translate';
import { groupEvents } from '$lib/models/event-groups';
import { clearActives } from '$lib/stores/active-events';
Expand Down Expand Up @@ -69,7 +69,7 @@
/>
{/if}
{#if workflow?.callbacks?.length}
<WorkflowCallback callback={workflow.callbacks[0]} />
<WorkflowCallbacks callbacks={workflow.callbacks} />
{/if}
<div
class="flex flex-col items-center gap-2 py-2 xl:flex-row xl:justify-between xl:gap-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('Event Category Data Structures', () => {
"WorkflowExecutionCompleted": "workflow",
"WorkflowExecutionContinuedAsNew": "workflow",
"WorkflowExecutionFailed": "workflow",
"WorkflowExecutionOptionsUpdated": "workflow",
"WorkflowExecutionSignaled": "signal",
"WorkflowExecutionStarted": "workflow",
"WorkflowExecutionTerminated": "workflow",
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/event-history/get-event-categorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const eventTypeCategorizations: Readonly<
WorkflowExecutionStarted: CATEGORIES.WORKFLOW,
WorkflowExecutionTerminated: CATEGORIES.WORKFLOW,
WorkflowExecutionTimedOut: CATEGORIES.WORKFLOW,
WorkflowExecutionOptionsUpdated: CATEGORIES.WORKFLOW,
WorkflowTaskCompleted: CATEGORIES.WORKFLOW,
WorkflowTaskFailed: CATEGORIES.WORKFLOW,
WorkflowTaskScheduled: CATEGORIES.WORKFLOW,
Expand Down
4 changes: 4 additions & 0 deletions src/lib/utilities/is-event-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
'WorkflowExecutionStarted',
'WorkflowExecutionTerminated',
'WorkflowExecutionTimedOut',
'WorkflowExecutionOptionsUpdated',
'WorkflowTaskCompleted',
'WorkflowTaskFailed',
'WorkflowTaskScheduled',
Expand All @@ -141,11 +142,14 @@
'WorkflowPropertiesModified',
] as const;

// Remove ts-ignore when TS SDK adds workflowExecutionOptionsUpdatedEventAttributes
export const eventAttributeKeys: Readonly<EventAttributeKey[]> = [
'workflowExecutionStartedEventAttributes',
'workflowExecutionCompletedEventAttributes',
'workflowExecutionFailedEventAttributes',
'workflowExecutionTimedOutEventAttributes',
// @ts-ignore

Check warning on line 151 in src/lib/utilities/is-event-type.ts

View workflow job for this annotation

GitHub Actions / lint

Do not use "@ts-ignore" because it alters compilation errors
'workflowExecutionOptionsUpdatedEventAttributes',
'workflowTaskStartedEventAttributes',
'workflowTaskScheduledEventAttributes',
'workflowTaskCompletedEventAttributes',
Expand Down
Loading