|
24 | 24 | } from '@appwrite.io/pink-svelte'; |
25 | 25 | import { capitalize } from '$lib/helpers/string'; |
26 | 26 | import { formatTimeDetailed } from '$lib/helpers/timeConversion'; |
| 27 | + import { getEffectiveBuildStatus } from '$lib/helpers/buildTimeout'; |
| 28 | + import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store'; |
27 | 29 | import { timer } from '$lib/actions/timer'; |
28 | 30 | import { app } from '$lib/stores/app'; |
29 | 31 | import { IconDotsHorizontal, IconRefresh, IconTrash } from '@appwrite.io/pink-icons-svelte'; |
|
36 | 38 | import { readOnly } from '$lib/stores/billing'; |
37 | 39 | import RedeployModal from '../(modals)/redeployModal.svelte'; |
38 | 40 |
|
39 | | - export let data; |
| 41 | + let { data } = $props(); |
40 | 42 |
|
41 | | - let showDelete = false; |
42 | | - let showCancel = false; |
43 | | - let showActivate = false; |
44 | | - let showRedeploy = false; |
| 43 | + let effectiveStatus = $derived( |
| 44 | + getEffectiveBuildStatus( |
| 45 | + data.deployment.status, |
| 46 | + data.deployment.$createdAt, |
| 47 | + $regionalConsoleVariables |
| 48 | + ) |
| 49 | + ); |
| 50 | + let showDelete = $state(false); |
| 51 | + let showCancel = $state(false); |
| 52 | + let showActivate = $state(false); |
| 53 | + let showRedeploy = $state(false); |
45 | 54 |
|
46 | 55 | onMount(() => { |
47 | | - return realtime.forProject(page.params.region, 'console', (response) => { |
| 56 | + return realtime.forConsole(page.params.region, 'console', (message) => { |
48 | 57 | if ( |
49 | | - response.events.includes( |
| 58 | + message.events.includes( |
50 | 59 | `functions.${page.params.function}.deployments.${page.params.deployment}.update` |
51 | 60 | ) |
52 | 61 | ) { |
53 | | - const payload = response.payload as Models.Deployment; |
54 | | - if (payload.status === 'ready') { |
| 62 | + const payload = message.payload as Models.Deployment; |
| 63 | + if (['ready', 'failed'].includes(payload.status)) { |
55 | 64 | invalidate(Dependencies.DEPLOYMENT); |
56 | 65 | } |
57 | 66 | } |
|
78 | 87 | <DeploymentCard proxyRuleList={data.proxyRuleList} deployment={data.deployment}> |
79 | 88 | {#snippet footer()} |
80 | 89 | <Layout.Stack direction="row" alignItems="center" inline> |
81 | | - {#if data.deployment.status === 'processing' || data.deployment.status === 'building' || data.deployment.status === 'waiting'} |
| 90 | + {#if effectiveStatus === 'processing' || effectiveStatus === 'building' || effectiveStatus === 'waiting'} |
82 | 91 | <Button |
83 | 92 | text |
84 | 93 | on:click={() => { |
|
152 | 161 | <Card.Base padding="s"> |
153 | 162 | <Accordion |
154 | 163 | title="Deployment logs" |
155 | | - badge={capitalize(data.deployment.status)} |
| 164 | + badge={capitalize(effectiveStatus)} |
156 | 165 | open |
157 | | - badgeType={badgeTypeDeployment(data.deployment.status)} |
| 166 | + badgeType={badgeTypeDeployment(effectiveStatus)} |
158 | 167 | hideDivider> |
159 | 168 | <Layout.Stack gap="xl"> |
160 | 169 | {#key data.deployment.buildLogs} |
|
167 | 176 |
|
168 | 177 | <svelte:fragment slot="end"> |
169 | 178 | <Layout.Stack direction="row" alignItems="center" inline> |
170 | | - {#if ['processing', 'building'].includes(data.deployment.status)} |
| 179 | + {#if ['processing', 'building'].includes(effectiveStatus)} |
171 | 180 | <Typography.Code color="--fgcolor-neutral-secondary"> |
172 | 181 | <Layout.Stack direction="row" alignItems="center" inline> |
173 | 182 | <p use:timer={{ start: data.deployment.$createdAt }}></p> |
|
0 commit comments