Skip to content

Commit 46c3abb

Browse files
authored
feat: Select Engine versions (#5479)
1 parent d1845f3 commit 46c3abb

File tree

7 files changed

+199
-75
lines changed

7 files changed

+199
-75
lines changed

apps/dashboard/src/@3rdweb-sdk/react/cache-keys.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ export const engineKeys = {
111111
] as const,
112112
health: (instance: string) =>
113113
[...engineKeys.all, instance, "health"] as const,
114-
latestVersion: () => [...engineKeys.all, "latestVersion"] as const,
114+
deploymentPublicConfiguration: () =>
115+
[...engineKeys.all, "deploymentPublicConfiguration"] as const,
115116
systemMetrics: (engineId: string) =>
116117
[...engineKeys.all, engineId, "systemMetrics"] as const,
117118
queueMetrics: (engineId: string) =>

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

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,32 +191,48 @@ export function useEngineQueueMetrics(
191191
});
192192
}
193193

194-
export function useEngineLatestVersion() {
195-
return useQuery({
196-
queryKey: engineKeys.latestVersion(),
194+
interface GetDeploymentPublicConfigurationInput {
195+
teamSlug: string;
196+
}
197+
198+
interface DeploymentPublicConfigurationResponse {
199+
serverVersions: {
200+
name: string;
201+
createdAt: string;
202+
}[];
203+
}
204+
205+
export function useEngineGetDeploymentPublicConfiguration(
206+
input: GetDeploymentPublicConfigurationInput,
207+
) {
208+
return useQuery<DeploymentPublicConfigurationResponse>({
209+
queryKey: engineKeys.deploymentPublicConfiguration(),
197210
queryFn: async () => {
198-
const res = await fetch(`${THIRDWEB_API_HOST}/v1/engine/latest-version`, {
199-
method: "GET",
200-
});
211+
const res = await fetch(
212+
`${THIRDWEB_API_HOST}/v1/teams/${input.teamSlug}/engine/deployments/public-configuration`,
213+
{ method: "GET" },
214+
);
201215
if (!res.ok) {
202216
throw new Error(`Unexpected status ${res.status}: ${await res.text()}`);
203217
}
218+
204219
const json = await res.json();
205-
return json.data.version as string;
220+
return json.data as DeploymentPublicConfigurationResponse;
206221
},
207222
});
208223
}
209224

210-
interface UpdateVersionInput {
225+
interface UpdateDeploymentInput {
226+
teamSlug: string;
211227
deploymentId: string;
212228
serverVersion: string;
213229
}
214230

215-
export function useEngineUpdateServerVersion() {
231+
export function useEngineUpdateDeployment() {
216232
return useMutation({
217-
mutationFn: async (input: UpdateVersionInput) => {
233+
mutationFn: async (input: UpdateDeploymentInput) => {
218234
const res = await fetch(
219-
`${THIRDWEB_API_HOST}/v2/engine/deployments/${input.deploymentId}/infrastructure`,
235+
`${THIRDWEB_API_HOST}/v1/teams/${input.teamSlug}/engine/deployments/${input.deploymentId}`,
220236
{
221237
method: "PUT",
222238
headers: {

apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(general)/overview/engine-instances-table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ function DeleteSubscriptionModalContent(props: {
465465
<div className="h-4" />
466466

467467
<Alert variant="destructive">
468-
<TriangleAlertIcon className="!text-destructive-text size-5" />
468+
<TriangleAlertIcon className="!text-destructive-text size-4" />
469469
<AlertTitle>This action is irreversible!</AlertTitle>
470470

471471
<AlertDescription className="!pl-0 pt-2">

apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(instance)/[engineId]/_components/EnginePageLayout.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export function WithEngineInstance(props: {
119119
instance={sandboxEngine}
120120
content={props.content}
121121
rootPath={rootPath}
122+
teamSlug={props.teamSlug}
122123
/>
123124
);
124125
}
@@ -128,6 +129,7 @@ export function WithEngineInstance(props: {
128129
content={props.content}
129130
engineId={props.engineId}
130131
rootPath={rootPath}
132+
teamSlug={props.teamSlug}
131133
/>
132134
);
133135
}
@@ -136,6 +138,7 @@ function QueryAndRenderInstanceHeader(props: {
136138
engineId: string;
137139
content: React.FC<{ instance: EngineInstance }>;
138140
rootPath: string;
141+
teamSlug: string;
139142
}) {
140143
const instancesQuery = useEngineInstances();
141144
const instance = instancesQuery.data?.find((x) => x.id === props.engineId);
@@ -157,6 +160,7 @@ function QueryAndRenderInstanceHeader(props: {
157160
instance={instance}
158161
content={props.content}
159162
rootPath={props.rootPath}
163+
teamSlug={props.teamSlug}
160164
/>
161165
);
162166
}
@@ -165,6 +169,7 @@ function EnsurePermissionAndRenderInstance(props: {
165169
content: React.FC<{ instance: EngineInstance }>;
166170
instance: EngineInstance;
167171
rootPath: string;
172+
teamSlug: string;
168173
}) {
169174
const permissionQuery = useHasEnginePermission({
170175
instanceUrl: props.instance.url,
@@ -210,6 +215,7 @@ function EnsurePermissionAndRenderInstance(props: {
210215
rootPath={props.rootPath}
211216
instance={props.instance}
212217
content={props.content}
218+
teamSlug={props.teamSlug}
213219
/>
214220
);
215221
}
@@ -218,6 +224,7 @@ function RenderEngineInstanceHeader(props: {
218224
instance: EngineInstance;
219225
content: React.FC<{ instance: EngineInstance }>;
220226
rootPath: string;
227+
teamSlug: string;
221228
}) {
222229
const { instance } = props;
223230

@@ -261,7 +268,7 @@ function RenderEngineInstanceHeader(props: {
261268
)}
262269
</div>
263270
</div>
264-
<EngineVersionBadge instance={instance} />
271+
<EngineVersionBadge instance={instance} teamSlug={props.teamSlug} />
265272
</div>
266273

267274
<div className="h-5" />

0 commit comments

Comments
 (0)