Skip to content

Commit de3b8f0

Browse files
committed
chore: Update version flow updates deployment
1 parent cefa4eb commit de3b8f0

File tree

6 files changed

+54
-42
lines changed

6 files changed

+54
-42
lines changed

apps/dashboard/src/@3rdweb-sdk/react/hooks/useEngine.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type EngineInstance = {
2525
| "deploying"
2626
| "paymentFailed"
2727
| "deploymentFailed";
28+
deploymentId: string;
2829
};
2930

3031
// Not checking for null token because the token is required the tanstack useQuery hook
@@ -188,23 +189,26 @@ export function useEngineLatestVersion() {
188189

189190
interface UpdateVersionInput {
190191
engineId: string;
192+
serverVersion: string;
191193
}
192194

193-
export function useEngineUpdateVersion() {
195+
export function useEngineUpdateServerVersion() {
194196
return useMutation({
195197
mutationFn: async (input: UpdateVersionInput) => {
196198
invariant(input.engineId, "engineId is required");
197199

198-
const res = await fetch(`${THIRDWEB_API_HOST}/v1/engine/update-version`, {
199-
method: "POST",
200-
201-
headers: {
202-
"Content-Type": "application/json",
200+
const res = await fetch(
201+
`${THIRDWEB_API_HOST}/v2/engine/${input.engineId}/infrastructure`,
202+
{
203+
method: "PUT",
204+
headers: {
205+
"Content-Type": "application/json",
206+
},
207+
body: JSON.stringify({
208+
serverVersion: input.serverVersion,
209+
}),
203210
},
204-
body: JSON.stringify({
205-
engineId: input.engineId,
206-
}),
207-
});
211+
);
208212
// we never use the response body
209213
res.body?.cancel();
210214
if (!res.ok) {

apps/dashboard/src/components/engine/badges/version.tsx

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
type EngineInstance,
55
useEngineLatestVersion,
66
useEngineSystemHealth,
7-
useEngineUpdateVersion,
7+
useEngineUpdateServerVersion,
88
} from "@3rdweb-sdk/react/hooks/useEngine";
99
import { CircleArrowDownIcon, CloudDownloadIcon } from "lucide-react";
1010
import { useState } from "react";
@@ -30,15 +30,17 @@ export const EngineVersionBadge = ({
3030
const latestVersionQuery = useEngineLatestVersion();
3131
const [isModalOpen, setModalOpen] = useState(false);
3232

33-
const current = healthQuery.data?.engineVersion ?? "...";
34-
const latest = latestVersionQuery.data ?? "...";
35-
const isStale = current !== latest;
33+
const currentVersion = healthQuery.data?.engineVersion ?? "...";
34+
const latestVersion = "v2.0.17";
35+
// DEBUG
36+
// const latestVersion = latestVersionQuery.data;
37+
const isStale = latestVersion && currentVersion !== latestVersion;
3638

3739
if (!isStale) {
3840
return (
3941
<ToolTipLabel label="Latest Version">
4042
<Button variant="outline" asChild className="hover:bg-transparent">
41-
<div>{current}</div>
43+
<div>{currentVersion}</div>
4244
</Button>
4345
</ToolTipLabel>
4446
);
@@ -57,7 +59,7 @@ export const EngineVersionBadge = ({
5759
className="relative"
5860
onClick={() => setModalOpen(true)}
5961
>
60-
{current}
62+
{currentVersion}
6163

6264
{/* Notification Dot */}
6365
<span className="-top-1 -right-1 absolute">
@@ -66,24 +68,26 @@ export const EngineVersionBadge = ({
6668
</Button>
6769
</ToolTipLabel>
6870

69-
<UpdateVersionModal
70-
open={isModalOpen}
71-
onOpenChange={setModalOpen}
72-
latest={latest ?? ""}
73-
instance={instance}
74-
/>
71+
{latestVersion && (
72+
<UpdateVersionModal
73+
open={isModalOpen}
74+
onOpenChange={setModalOpen}
75+
latestVersion={latestVersion}
76+
instance={instance}
77+
/>
78+
)}
7579
</>
7680
);
7781
};
7882

7983
const UpdateVersionModal = (props: {
8084
open: boolean;
8185
onOpenChange: (open: boolean) => void;
82-
latest: string;
86+
latestVersion: string;
8387
instance: EngineInstance;
8488
}) => {
85-
const { open, onOpenChange, latest, instance } = props;
86-
const updateEngine = useEngineUpdateVersion();
89+
const { open, onOpenChange, latestVersion, instance } = props;
90+
const updateEngineServerMutation = useEngineUpdateServerVersion();
8791

8892
if (!instance.cloudDeployedAt) {
8993
// For self-hosted, show a prompt to the Github release page.
@@ -95,19 +99,20 @@ const UpdateVersionModal = (props: {
9599
>
96100
<DialogHeader>
97101
<DialogTitle className="mb-6 pr-4 font-semibold text-2xl tracking-tight">
98-
Update your self-hosted Engine to {latest}
102+
Update your self-hosted Engine to {latestVersion}
99103
</DialogTitle>
100104
<DialogDescription>
101-
View the changelog in the
105+
View the{" "}
102106
<TrackedLinkTW
103107
href="https://github.com/thirdweb-dev/engine/releases"
104108
category="engine"
105109
label="clicked-engine-releases"
106110
target="_blank"
107111
className="text-link-foreground hover:text-foreground"
108112
>
109-
Engine Github repository
113+
latest changelog
110114
</TrackedLinkTW>
115+
.
111116
</DialogDescription>
112117
</DialogHeader>
113118
</DialogContent>
@@ -117,11 +122,13 @@ const UpdateVersionModal = (props: {
117122

118123
const onClick = async () => {
119124
try {
120-
const promise = updateEngine.mutateAsync({ engineId: instance.id });
125+
const promise = updateEngineServerMutation.mutateAsync({
126+
engineId: instance.id,
127+
serverVersion: latestVersion,
128+
});
121129
toast.promise(promise, {
122-
success:
123-
"Submitted a request to update your Engine instance. Please allow 1-2 business days for this process.",
124-
error: "Unexpected error updating your Engine instance.",
130+
success: `Upgrading your Engine to ${latestVersion}. Please confirm after a few minutes.`,
131+
error: "Unexpected error updating your Engine.",
125132
});
126133
await promise;
127134
} finally {
@@ -136,7 +143,12 @@ const UpdateVersionModal = (props: {
136143
dialogOverlayClassName="z-[10000]"
137144
>
138145
<DialogHeader>
139-
<DialogTitle>Update Engine to {latest}?</DialogTitle>
146+
<DialogTitle>Update Engine to {latestVersion}?</DialogTitle>
147+
148+
<DialogDescription>
149+
{`It is recommended to pause traffic to Engine before performing this
150+
upgrade. There is < 1 minute of expected downtime.`}
151+
</DialogDescription>
140152
</DialogHeader>
141153

142154
<DialogFooter className="mt-5">
@@ -153,7 +165,7 @@ const UpdateVersionModal = (props: {
153165
variant="primary"
154166
className="gap-2"
155167
>
156-
{updateEngine.isPending ? (
168+
{updateEngineServerMutation.isPending ? (
157169
<Spinner className="size-4" />
158170
) : (
159171
<CloudDownloadIcon className="size-4" />

apps/dashboard/src/components/engine/configuration/ip-allowlist.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const EngineIpAllowlistConfig: React.FC<
8484
</Flex>
8585

8686
<Textarea
87-
placeholder="8.8.8.8\nff06:0:0:0:0:0:0:c3"
87+
placeholder={"8.8.8.8\nff06:0:0:0:0:0:0:c3"}
8888
rows={4}
8989
{...form.register("raw")}
9090
/>

apps/dashboard/src/components/engine/create/CreateEnginePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const CreateEnginePage = () => {
115115
</h1>
116116

117117
<p className="mb-7 text-muted-foreground">
118-
Host Engine on thirdweb with no setup or maintenance required
118+
Host Engine on thirdweb with no setup or maintenance required.
119119
</p>
120120

121121
<div className="grid grid-cols-1 gap-6 lg:grid-cols-3">

apps/dashboard/src/components/engine/engine-instances-table.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,7 @@ const EditModal = (props: {
266266
className="gap-2"
267267
disabled={!form.formState.isDirty}
268268
>
269-
{editInstance.isPending ? (
270-
<Spinner className="size-4" />
271-
) : (
272-
<SendIcon className="size-4" />
273-
)}
269+
{editInstance.isPending && <Spinner className="size-4" />}
274270
Update
275271
</Button>
276272
</DialogFooter>

apps/dashboard/src/components/engine/import/EngineImportPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const EngineImportPage = () => {
114114
<div className="mt-2 flex items-center gap-2">
115115
<CircleAlertIcon className="!static size-3 text-warning-foreground" />
116116
<p className="text-muted-foreground text-sm">
117-
Do not import a URL you do not recognize
117+
Do not import a URL you do not recognize.
118118
</p>
119119
</div>
120120
</FormControl>

0 commit comments

Comments
 (0)