-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathgroup-details-text.svelte
More file actions
71 lines (65 loc) · 2.11 KB
/
group-details-text.svelte
File metadata and controls
71 lines (65 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<script lang="ts">
import EventDetailsLink from '$lib/components/event/event-details-link.svelte';
import PayloadDecoder from '$lib/components/event/payload-decoder.svelte';
import CodeBlock from '$lib/holocene/code-block.svelte';
import type { CombinedAttributes } from '$lib/utilities/format-event-attributes';
import {
displayLinkType,
getCodeBlockValue,
} from '$lib/utilities/get-single-attribute-for-event';
import { DetailsConfig, staticCodeBlockHeight } from '../constants';
interface Props {
key: string;
value: string | Record<string, unknown>;
attributes: CombinedAttributes;
onDecode?: (decodedValue: string) => void | undefined;
}
let { key, value, attributes, onDecode = undefined }: Props = $props();
const { fontSizeRatio } = DetailsConfig;
const codeBlockValue = $derived(getCodeBlockValue(value));
const linkType = $derived(displayLinkType(key, attributes));
</script>
{#if typeof value === 'object'}
{#if value?.payloads}
<PayloadDecoder {value} key="payloads" {onDecode}>
{#snippet children(decodedValue)}
{#key decodedValue}
<CodeBlock
content={decodedValue}
maxHeight={staticCodeBlockHeight - fontSizeRatio}
/>
{/key}
{/snippet}
</PayloadDecoder>
{:else if key === 'searchAttributes'}
<PayloadDecoder
key="searchAttributes"
value={{ searchAttributes: codeBlockValue }}
{onDecode}
>
{#snippet children(decodedValue)}
{#key decodedValue}
<CodeBlock
content={decodedValue}
maxHeight={staticCodeBlockHeight - fontSizeRatio}
/>
{/key}
{/snippet}
</PayloadDecoder>
{:else}
<PayloadDecoder value={codeBlockValue} {onDecode}>
{#snippet children(decodedValue)}
{#key decodedValue}
<CodeBlock
content={decodedValue}
maxHeight={staticCodeBlockHeight - fontSizeRatio}
/>
{/key}
{/snippet}
</PayloadDecoder>
{/if}
{:else if linkType !== 'none'}
<EventDetailsLink {value} {attributes} type={linkType} />
{:else}
{value}
{/if}