-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathworker-table.svelte
90 lines (86 loc) · 3.11 KB
/
worker-table.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
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
<script lang="ts">
import Badge from '$lib/holocene/badge.svelte';
import EmptyState from '$lib/holocene/empty-state.svelte';
import TableHeaderRow from '$lib/holocene/table/table-header-row.svelte';
import TableRow from '$lib/holocene/table/table-row.svelte';
import Table from '$lib/holocene/table/table.svelte';
import { translate } from '$lib/i18n/translate';
import { type GetPollersResponse } from '$lib/services/pollers-service';
import { isCloud } from '$lib/stores/advanced-visibility';
import { relativeTime, timeFormat } from '$lib/stores/time-format';
import { formatDate } from '$lib/utilities/format-date';
import PollerIcon from './poller-icon.svelte';
export let workers: GetPollersResponse;
const getDeploymentName = (poller) => {
const deployment = poller?.workerVersionCapabilities?.deploymentSeriesName;
return deployment ?? '';
};
</script>
<h2 class="flex items-center gap-2" data-testid="workers">
{translate('workers.workers')}
<Badge type="count">{workers?.pollers?.length || 0}</Badge>
</h2>
<Table class="mb-6 w-full min-w-[600px] table-fixed">
<caption class="sr-only" slot="caption"
>{translate('workflows.workers-tab')}</caption
>
<TableHeaderRow slot="headers">
<th class={'w-4/12'}>{translate('common.id')}</th>
<th class={'w-3/12'}>{translate('workers.buildId')}</th>
{#if !$isCloud}
<th class={'w-3/12'}>{translate('deployments.deployment')}</th>
{/if}
<th class="w-2/12">{translate('workflows.last-accessed')}</th>
<th class="w-2/12">
<p class="text-center">
{translate('workflows.workflow-task-handler')}
</p>
</th>
<th class="w-2/12 text-center">
<p class="text-center">{translate('workflows.activity-handler')}</p>
</th>
</TableHeaderRow>
{#each workers?.pollers as poller}
<TableRow data-testid="worker-row">
<td class="text-left" data-testid="worker-identity">
<p class="select-all">{poller.identity}</p>
</td>
<td class="text-left" data-testid="worker-build-id">
<p class="select-all break-all">
{poller?.workerVersionCapabilities?.buildId ?? ''}
</p>
</td>
{#if !$isCloud}
{@const deployment = getDeploymentName(poller)}
<td class="text-left" data-testid="worker-build-id">
<p class="select-all break-all">
{deployment ?? ''}
</p>
</td>
{/if}
<td class="text-left" data-testid="worker-last-access-time">
<p class="select-all">
{formatDate(poller.lastAccessTime, $timeFormat, {
relative: $relativeTime,
})}
</p>
</td>
<td data-testid="workflow-poller">
<PollerIcon
includesTaskQueueType={poller.taskQueueTypes.includes('WORKFLOW')}
/>
</td>
<td data-testid="activity-poller">
<PollerIcon
includesTaskQueueType={poller.taskQueueTypes.includes('ACTIVITY')}
/>
</td>
</TableRow>
{:else}
<tr class="w-full">
<td colspan="5">
<EmptyState title={translate('workflows.workers-empty-state')} />
</td>
</tr>
{/each}
</Table>