44 type EngineInstance ,
55 useEngineLatestVersion ,
66 useEngineSystemHealth ,
7- useEngineUpdateVersion ,
7+ useEngineUpdateServerVersion ,
88} from "@3rdweb-sdk/react/hooks/useEngine" ;
99import { CircleArrowDownIcon , CloudDownloadIcon } from "lucide-react" ;
1010import { 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
7983const 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" />
0 commit comments