Skip to content

Commit 7bbf2af

Browse files
Update components/event components to Svelte 5 syntax
1 parent 3d0ec56 commit 7bbf2af

5 files changed

Lines changed: 102 additions & 47 deletions

File tree

src/lib/components/event/event-category-multiselect-filter.svelte

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { page } from '$app/stores';
2+
import { page } from '$app/state';
33
44
import MultiSelect from '$lib/holocene/select/multi-select.svelte';
55
import { translate } from '$lib/i18n/translate';
@@ -12,28 +12,37 @@
1212
import { updateQueryParameters } from '$lib/utilities/update-query-parameters';
1313
import { isVersionNewer } from '$lib/utilities/version-check';
1414
15-
export let compact = false;
15+
interface Props {
16+
compact?: boolean;
17+
}
18+
19+
let { compact = false }: Props = $props();
20+
21+
const label = $derived(
22+
compact
23+
? translate('events.event-type')
24+
: translate('events.workflow-events'),
25+
);
1626
17-
$: label = compact
18-
? translate('events.event-type')
19-
: translate('events.workflow-events');
27+
const parameter = 'category';
2028
21-
let parameter = 'category';
22-
let options = (compact ? compactEventTypeOptions : allEventTypeOptions).map(
23-
(o) => ({
29+
const options = $derived.by(() => {
30+
const baseOptions = (
31+
compact ? compactEventTypeOptions : allEventTypeOptions
32+
).map((o) => ({
2433
...o,
2534
label: translate(o.label),
26-
}),
27-
);
35+
}));
36+
return isVersionNewer('1.21', $temporalVersion)
37+
? baseOptions.filter(({ value }) => value !== 'update')
38+
: baseOptions;
39+
});
2840
29-
$: {
30-
if (isVersionNewer('1.21', $temporalVersion)) {
31-
options = options.filter(({ value }) => value !== 'update');
32-
}
33-
}
34-
$: initialSelected = $eventCategoryFilter
35-
? options.filter((o) => $eventCategoryFilter.includes(o.value))
36-
: [];
41+
const initialSelected = $derived(
42+
$eventCategoryFilter
43+
? options.filter((o) => $eventCategoryFilter.includes(o.value))
44+
: [],
45+
);
3746
3847
const onOptionClick = (_options) => {
3948
if (_options.length === options.length) {
@@ -44,7 +53,7 @@
4453
updateQueryParameters({
4554
parameter: parameter,
4655
value,
47-
url: $page.url,
56+
url: page.url,
4857
});
4958
};
5059
</script>

src/lib/components/event/event-details-link.svelte

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { page } from '$app/stores';
2+
import { page } from '$app/state';
33
44
import Link from '$lib/holocene/link.svelte';
55
import type { CombinedAttributes } from '$lib/utilities/format-event-attributes';
@@ -10,11 +10,23 @@
1010
routeForWorkflow,
1111
} from '$lib/utilities/route-for';
1212
13-
export let value: string;
14-
export let attributes: CombinedAttributes;
15-
export let type: EventLinkType;
13+
interface Props {
14+
value: string;
15+
attributes: CombinedAttributes;
16+
type: EventLinkType;
17+
class?: string;
18+
}
19+
20+
let {
21+
value,
22+
attributes,
23+
type,
24+
class: className = '',
25+
...rest
26+
}: Props = $props();
1627
17-
$: ({ workflow, namespace } = $page.params);
28+
const workflow = $derived(page.params.workflow);
29+
const namespace = $derived(page.params.namespace);
1830
1931
function getHref(
2032
ns: string,
@@ -40,9 +52,9 @@
4052
}
4153
}
4254
43-
$: href = getHref(namespace, workflow, attributes, value, type);
55+
const href = $derived(getHref(namespace, workflow, attributes, value, type));
4456
</script>
4557

46-
<Link class={$$restProps.class} {href}>
58+
<Link class={className} {href} {...rest}>
4759
{value}
4860
</Link>

src/lib/components/event/event-details-row.svelte

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,23 @@
1212
import EventDetailsLink from './event-details-link.svelte';
1313
import PayloadDecoder from './payload-decoder.svelte';
1414
15-
export let key: string;
16-
export let value: string | Record<string, unknown> | Payloads;
17-
export let attributes: CombinedAttributes;
18-
export let showKey = true;
15+
interface Props {
16+
key: string;
17+
value: string | Record<string, unknown> | Payloads;
18+
attributes: CombinedAttributes;
19+
showKey?: boolean;
20+
class?: string;
21+
}
22+
23+
let {
24+
key,
25+
value,
26+
attributes,
27+
showKey = true,
28+
class: className = '',
29+
}: Props = $props();
1930
20-
$: linkType = displayLinkType(key, attributes);
31+
const linkType = $derived(displayLinkType(key, attributes));
2132
</script>
2233

2334
{#if key}
@@ -35,7 +46,7 @@
3546
>
3647
<PayloadDecoder {value} key="payloads">
3748
{#snippet children(decodedValue)}
38-
<div class={merge('payload', $$props.class)}>
49+
<div class={merge('payload', className)}>
3950
<code>
4051
<pre class="truncate">{decodedValue.slice(0, 60)}</pre>
4152
</code>

src/lib/components/event/event-empty-row.svelte

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44
import { translate } from '$lib/i18n/translate';
55
import { isCloud } from '$lib/stores/advanced-visibility';
66
7-
export let loading = false;
8-
export let title = translate('events.empty-state-title');
9-
export let content = translate('events.empty-state-description');
7+
interface Props {
8+
loading?: boolean;
9+
title?: string;
10+
content?: string;
11+
}
12+
13+
let {
14+
loading = false,
15+
title = translate('events.empty-state-title'),
16+
content = translate('events.empty-state-description'),
17+
}: Props = $props();
1018
</script>
1119

1220
<tr class="bg-primary">

src/lib/components/event/event-link.svelte

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,41 @@
44
import type { EventLink } from '$lib/types';
55
import { getEventLinkHref } from '$lib/utilities/event-link-href';
66
7-
export let link: EventLink;
8-
export let value = link.workflowEvent.workflowId;
9-
export let label = translate('nexus.link');
10-
export let href: string | undefined = undefined;
11-
12-
$: if (!href) {
13-
href = getEventLinkHref(link);
14-
value = href.split('workflows/')?.[1] || href;
7+
interface Props {
8+
link: EventLink;
9+
value?: string;
10+
label?: string;
11+
href?: string;
12+
class?: string;
13+
linkClass?: string;
1514
}
15+
16+
let {
17+
link,
18+
value,
19+
label = translate('nexus.link'),
20+
href,
21+
class: className = '',
22+
linkClass = '',
23+
}: Props = $props();
24+
25+
const resolvedHref = $derived(href ?? getEventLinkHref(link));
26+
const resolvedValue = $derived(
27+
value ??
28+
(resolvedHref.split('workflows/')?.[1] || resolvedHref) ??
29+
link.workflowEvent.workflowId,
30+
);
1631
</script>
1732

1833
<div
19-
class="flex flex-row items-center gap-2 overflow-hidden first:pt-0 last:border-b-0 {$$props.class}"
34+
class="flex flex-row items-center gap-2 overflow-hidden first:pt-0 last:border-b-0 {className}"
2035
>
2136
<p class="max-w-fit whitespace-nowrap text-right text-sm">
2237
{label}
2338
</p>
24-
<div class="overflow-hidden {$$props.linkClass}">
25-
<Link {href}>
26-
{value}
39+
<div class="overflow-hidden {linkClass}">
40+
<Link href={resolvedHref}>
41+
{resolvedValue}
2742
</Link>
2843
</div>
2944
</div>

0 commit comments

Comments
 (0)