|
1 | 1 | <script lang="ts"> |
| 2 | + import type { Snippet } from 'svelte'; |
| 3 | +
|
2 | 4 | import Alert from '$lib/holocene/alert.svelte'; |
3 | 5 | import Badge from '$lib/holocene/badge.svelte'; |
4 | 6 | import CodeBlock from '$lib/holocene/code-block.svelte'; |
|
12 | 14 |
|
13 | 15 | import EventLink from '../event/event-link.svelte'; |
14 | 16 |
|
15 | | - export let callback: Callback; |
16 | | - export let link: Link | undefined = undefined; |
| 17 | + let { |
| 18 | + callback, |
| 19 | + link, |
| 20 | + children, |
| 21 | + }: { callback: Callback; link?: Link; children?: Snippet } = $props(); |
17 | 22 |
|
18 | | - $: completedTime = formatDate(callback.lastAttemptCompleteTime, $timeFormat); |
19 | | - $: nextTime = formatDate(callback.nextAttemptScheduleTime, $timeFormat); |
20 | | - $: failure = callback?.lastAttemptFailure?.message; |
21 | | - $: blockedReason = callback?.blockedReason; |
22 | | - $: callbackUrl = callback?.callback?.nexus?.url; |
| 23 | + const completedTime = $derived( |
| 24 | + formatDate(callback.lastAttemptCompleteTime, $timeFormat), |
| 25 | + ); |
| 26 | + const nextTime = $derived( |
| 27 | + formatDate(callback.nextAttemptScheduleTime, $timeFormat), |
| 28 | + ); |
| 29 | + const failure = $derived(callback?.lastAttemptFailure?.message); |
| 30 | + const blockedReason = $derived(callback?.blockedReason); |
| 31 | + const callbackUrl = $derived(callback?.callback?.nexus?.url); |
23 | 32 |
|
24 | 33 | const titles = { |
25 | 34 | Standby: translate('nexus.callback.standby'), |
|
30 | 39 | }; |
31 | 40 |
|
32 | 41 | const failedState = 'Failed' as unknown as CallbackState; |
33 | | - $: failed = callback.state === failedState; |
34 | | - $: title = titles[callback.state] || translate('nexus.nexus-callback'); |
| 42 | + const failed = $derived(callback.state === failedState); |
| 43 | + const title = $derived( |
| 44 | + titles[callback.state] || translate('nexus.nexus-callback'), |
| 45 | + ); |
| 46 | + const links = $derived(callback?.callback?.links || []); |
35 | 47 | </script> |
36 | 48 |
|
37 | 49 | <Alert icon="nexus" intent={failed ? 'error' : 'info'} {title}> |
38 | 50 | <div class="flex flex-col gap-2 pt-2"> |
39 | | - {#if link} |
| 51 | + {#if links.length} |
| 52 | + {#each links as link (link.workflowEvent?.eventRef?.eventId || link.workflowEvent?.requestIdRef.requestId)} |
| 53 | + <EventLink {link} /> |
| 54 | + <EventLink |
| 55 | + {link} |
| 56 | + label={translate('nexus.link-namespace')} |
| 57 | + value={link.workflowEvent.namespace} |
| 58 | + href={routeForNamespace({ namespace: link.workflowEvent.namespace })} |
| 59 | + /> |
| 60 | + {/each} |
| 61 | + {:else if link} |
40 | 62 | <EventLink {link} /> |
41 | 63 | <EventLink |
42 | 64 | {link} |
|
92 | 114 | </div> |
93 | 115 | {/if} |
94 | 116 | </div> |
95 | | - <slot /> |
| 117 | + {@render children?.()} |
96 | 118 | </Alert> |
0 commit comments