-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathversion-table-row.svelte
75 lines (68 loc) · 2.5 KB
/
version-table-row.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
<script lang="ts">
import { page } from '$app/stores';
import Link from '$lib/holocene/link.svelte';
import { translate } from '$lib/i18n/translate';
import type { ConfigurableTableHeader } from '$lib/stores/configurable-table-columns';
import { relativeTime, timeFormat } from '$lib/stores/time-format';
import type { RoutingConfig, VersionSummary } from '$lib/types/deployments';
import type { DeploymentStatus as Status } from '$lib/types/deployments';
import { formatDate } from '$lib/utilities/format-date';
import { routeForWorkflowsWithQuery } from '$lib/utilities/route-for';
import { fromScreamingEnum } from '$lib/utilities/screaming-enums';
import DeploymentStatus from './deployment-status.svelte';
export let routingConfig: RoutingConfig;
export let version: VersionSummary;
export let columns: ConfigurableTableHeader[];
$: isCurrent = version.version === routingConfig.currentVersion;
$: isRamping = version.version === routingConfig.rampingVersion;
$: drainageStatus = version.drainageStatus;
$: status = (
isCurrent
? translate('deployments.current')
: isRamping
? translate('deployments.ramping')
: drainageStatus
? fromScreamingEnum(drainageStatus, 'VersionDrainageStatus')
: 'Inactive'
) as Status;
$: statusLabel = isCurrent
? translate('deployments.current')
: isRamping
? translate('deployments.ramping', {
percentage: routingConfig.rampingVersionPercentage,
})
: drainageStatus
? fromScreamingEnum(drainageStatus, 'VersionDrainageStatus')
: 'Inactive';
</script>
<tr>
{#each columns as { label } (label)}
{#if label === translate('deployments.version')}
<td class="p-2 text-left">
<DeploymentStatus
{status}
version={version.version}
label={statusLabel}
/>
</td>
{:else if label === translate('deployments.deployed')}
<td class="whitespace-pre-line break-words p-2 text-left"
>{formatDate(version?.createTime, $timeFormat, {
relative: $relativeTime,
})}</td
>
{:else if label === translate('deployments.workflows')}
<td class="whitespace-pre-line break-words p-2 text-center"
><p>
<Link
icon="external-link"
href={routeForWorkflowsWithQuery({
namespace: $page.params.namespace,
query: `TemporalWorkerDeploymentVersion="${version.version}"`,
})}
/>
</p></td
>
{/if}
{/each}
</tr>