-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathworkflow-history-event.svelte
56 lines (46 loc) · 1.56 KB
/
workflow-history-event.svelte
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
<script lang="ts">
import { page } from '$app/stores';
import EventSummaryTable from '$lib/components/event/event-summary-table.svelte';
import { groupEvents } from '$lib/models/event-groups';
import { fetchAllEvents } from '$lib/services/events-service';
import { eventFilterSort } from '$lib/stores/event-view';
import { fullEventHistory } from '$lib/stores/events';
import { workflowRun } from '$lib/stores/workflow-run';
$: ({ namespace, workflow: workflowId, run: runId } = $page.params);
const resetFullHistory = () => {
$fullEventHistory = [];
};
const fetchEvents = async (
namespace: string,
workflowId: string,
runId: string,
) => {
if (!$fullEventHistory.length) {
resetFullHistory();
$fullEventHistory = await fetchAllEvents({
namespace,
workflowId,
runId,
});
}
};
$: fetchEvents(namespace, workflowId, runId);
$: updating = !$fullEventHistory.length;
$: ({ workflow } = $workflowRun);
$: pendingActivities = workflow?.pendingActivities;
$: pendingNexusOperations = workflow?.pendingNexusOperations;
$: ascendingGroups = groupEvents(
$fullEventHistory,
'ascending',
pendingActivities,
pendingNexusOperations,
);
$: groups =
$eventFilterSort === 'ascending'
? ascendingGroups
: [...ascendingGroups].reverse();
$: visibleItems = $fullEventHistory.filter((e) => e.id === $page.params.id);
</script>
<div class="px-8" data-testid="event-summary-table">
<EventSummaryTable items={visibleItems} {groups} {updating} openExpanded />
</div>