-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathworkflow-current-details.svelte
More file actions
94 lines (84 loc) · 2.66 KB
/
workflow-current-details.svelte
File metadata and controls
94 lines (84 loc) · 2.66 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<script lang="ts">
import { onMount } from 'svelte';
import { page } from '$app/state';
import Timestamp from '$lib/components/timestamp.svelte';
import Button from '$lib/holocene/button.svelte';
import Icon from '$lib/holocene/icon/icon.svelte';
import Markdown from '$lib/holocene/markdown-editor/preview.svelte';
import { translate } from '$lib/i18n/translate';
import { getWorkflowMetadata } from '$lib/services/query-service';
import { workflowRun } from '$lib/stores/workflow-run';
const { namespace } = $derived(page.params);
const { workflow } = $derived($workflowRun);
const currentDetails = $derived($workflowRun?.metadata?.currentDetails || '');
let loading = $state(false);
let lastFetched = $state<Date | null>(null);
const fetchCurrentDetails = async () => {
if (!workflow || loading) return;
loading = true;
try {
const { settings } = page.data;
const metadata = await getWorkflowMetadata(
{
namespace,
workflow: {
id: workflow.id,
runId: workflow.runId,
},
},
settings,
);
$workflowRun.metadata = metadata;
lastFetched = new Date();
} catch (error) {
console.error('Error fetching current details:', error);
} finally {
loading = false;
}
};
onMount(() => {
fetchCurrentDetails();
});
const handleKeydown = (event: KeyboardEvent) => {
if (event.key === 'r' || event.key === 'R') {
event.preventDefault();
fetchCurrentDetails();
}
};
</script>
<svelte:window onkeydown={handleKeydown} />
<div class="flex flex-1 flex-col border-l border-subtle">
<div class="surface-information w-full px-6 py-2">
<div class="flex items-center justify-between">
<h3>{translate('workflows.current-details')}</h3>
<div class="flex flex-row items-center gap-2 lg:flex-col xl:flex-row">
<p class="hidden sm:block">
Press the <span
class="mx-1 rounded bg-subtle px-1 text-sm font-medium leading-4"
>R</span
> for freshness
</p>
<div class="flex items-center sm:hidden">
<p>Press for freshness</p>
<Button
variant="ghost"
on:click={fetchCurrentDetails}
disabled={loading}
>
<Icon name="retry" />
</Button>
</div>
{#if lastFetched}
<Timestamp
as="p"
class="text-xs text-secondary"
dateTime={lastFetched}
/>
{/if}
</div>
</div>
</div>
{#key currentDetails}
<Markdown class="p-3" overrideTheme="primary" content={currentDetails} />
{/key}
</div>