-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathDeploymentStatus.tsx
More file actions
151 lines (142 loc) · 3.82 KB
/
DeploymentStatus.tsx
File metadata and controls
151 lines (142 loc) · 3.82 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import {
CheckCircleIcon,
ExclamationTriangleIcon,
NoSymbolIcon,
XCircleIcon,
} from "@heroicons/react/20/solid";
import type { WorkerDeploymentStatus } from "@trigger.dev/database";
import assertNever from "assert-never";
import { Spinner } from "~/components/primitives/Spinner";
import { cn } from "~/utils/cn";
export function DeploymentStatus({
status,
isBuilt,
className,
}: {
status: WorkerDeploymentStatus;
isBuilt: boolean;
className?: string;
}) {
return (
<span className={cn("flex items-center gap-1", className)}>
<DeploymentStatusIcon status={status} className="h-4 w-4" />
<DeploymentStatusLabel status={status} isBuilt={isBuilt} />
</span>
);
}
export function DeploymentStatusLabel({
status,
isBuilt,
}: {
status: WorkerDeploymentStatus;
isBuilt: boolean;
}) {
return (
<span className={deploymentStatusClassNameColor(status)}>
{deploymentStatusTitle(status, isBuilt)}
</span>
);
}
export function DeploymentStatusIcon({
status,
className,
}: {
status: WorkerDeploymentStatus;
className: string;
}) {
switch (status) {
case "PENDING":
case "BUILDING":
case "DEPLOYING":
return <Spinner className={cn(deploymentStatusClassNameColor(status), className)} />;
case "DEPLOYED":
return <CheckCircleIcon className={cn(deploymentStatusClassNameColor(status), className)} />;
case "CANCELED":
return <NoSymbolIcon className={cn(deploymentStatusClassNameColor(status), className)} />;
case "FAILED":
return <XCircleIcon className={cn(deploymentStatusClassNameColor(status), className)} />;
case "TIMED_OUT":
return (
<ExclamationTriangleIcon
className={cn(deploymentStatusClassNameColor(status), className)}
/>
);
default: {
assertNever(status);
}
}
}
export function deploymentStatusClassNameColor(status: WorkerDeploymentStatus): string {
switch (status) {
case "PENDING":
case "BUILDING":
case "DEPLOYING":
return "text-pending";
case "TIMED_OUT":
case "CANCELED":
return "text-charcoal-500";
case "DEPLOYED":
return "text-success";
case "FAILED":
return "text-error";
default: {
assertNever(status);
}
}
}
export function deploymentStatusTitle(status: WorkerDeploymentStatus, isBuilt: boolean): string {
switch (status) {
case "PENDING":
return "Pending…";
case "BUILDING":
return "Building…";
case "DEPLOYING":
return "Deploying…";
case "DEPLOYED":
return "Deployed";
case "CANCELED":
return "Canceled";
case "TIMED_OUT":
if (!isBuilt) {
return "Build timed out";
}
return "Indexing timed out";
case "FAILED":
if (!isBuilt) {
return "Build failed";
}
return "Indexing failed";
default: {
assertNever(status);
}
}
}
// PENDING and CANCELED are not used so are ommited from the UI
export const deploymentStatuses: WorkerDeploymentStatus[] = [
"BUILDING",
"DEPLOYING",
"DEPLOYED",
"FAILED",
"TIMED_OUT",
];
export function deploymentStatusDescription(status: WorkerDeploymentStatus): string {
switch (status) {
case "PENDING":
return "The deployment is queued and waiting to be processed.";
case "BUILDING":
return "The code is being built and prepared for deployment.";
case "DEPLOYING":
return "The deployment is in progress and tasks are being indexed.";
case "DEPLOYED":
return "The deployment has completed successfully.";
case "CANCELED":
return "The deployment was manually canceled.";
case "FAILED":
return "The deployment encountered an error and could not complete.";
case "TIMED_OUT":
return "The deployment exceeded the maximum allowed time and was stopped.";
default: {
assertNever(status);
}
}
}