Skip to content

Commit 689fd31

Browse files
committed
move to teamSlug
1 parent 0c196a3 commit 689fd31

File tree

5 files changed

+29
-37
lines changed

5 files changed

+29
-37
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export function useEngineQueueMetrics(
192192
}
193193

194194
interface GetDeploymentPublicConfigurationInput {
195-
teamId: string;
195+
teamSlug: string;
196196
}
197197

198198
interface DeploymentPublicConfigurationResponse {
@@ -209,7 +209,7 @@ export function useEngineGetDeploymentPublicConfiguration(
209209
queryKey: engineKeys.deploymentPublicConfiguration(),
210210
queryFn: async () => {
211211
const res = await fetch(
212-
`${THIRDWEB_API_HOST}/v1/teams/${input.teamId}/engine/deployments/public-configuration`,
212+
`${THIRDWEB_API_HOST}/v1/teams/${input.teamSlug}/engine/deployments/public-configuration`,
213213
{ method: "GET" },
214214
);
215215
if (!res.ok) {
@@ -223,7 +223,7 @@ export function useEngineGetDeploymentPublicConfiguration(
223223
}
224224

225225
interface UpdateDeploymentInput {
226-
teamId: string;
226+
teamSlug: string;
227227
deploymentId: string;
228228
serverVersion: string;
229229
}
@@ -232,7 +232,7 @@ export function useEngineUpdateDeployment() {
232232
return useMutation({
233233
mutationFn: async (input: UpdateDeploymentInput) => {
234234
const res = await fetch(
235-
`${THIRDWEB_API_HOST}/v1/teams/${input.teamId}/engine/deployments/${input.deploymentId}`,
235+
`${THIRDWEB_API_HOST}/v1/teams/${input.teamSlug}/engine/deployments/${input.deploymentId}`,
236236
{
237237
method: "PUT",
238238
headers: {

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} teamId={instance.accountId} />
271+
<EngineVersionBadge instance={instance} teamSlug={props.teamSlug} />
265272
</div>
266273

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

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

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,32 @@ import {
2727
useEngineUpdateDeployment,
2828
} from "@3rdweb-sdk/react/hooks/useEngine";
2929
import { formatDistanceToNow } from "date-fns";
30-
import {
31-
CircleArrowDownIcon,
32-
CloudDownloadIcon,
33-
TriangleAlertIcon,
34-
} from "lucide-react";
30+
import { CircleArrowUpIcon, TriangleAlertIcon } from "lucide-react";
3531
import { useState } from "react";
3632
import { toast } from "sonner";
3733
import invariant from "tiny-invariant";
3834

3935
export const EngineVersionBadge = ({
4036
instance,
41-
teamId,
37+
teamSlug,
4238
}: {
4339
instance: EngineInstance;
44-
teamId: string;
40+
teamSlug: string;
4541
}) => {
4642
const healthQuery = useEngineSystemHealth(instance.url);
4743
const publicConfigurationQuery = useEngineGetDeploymentPublicConfiguration({
48-
teamId,
44+
teamSlug,
4945
});
5046
const [isModalOpen, setModalOpen] = useState(false);
5147

52-
if (
53-
!healthQuery.data ||
54-
publicConfigurationQuery.data.serverVersions?.length === 0
55-
) {
48+
if (!healthQuery.data || !publicConfigurationQuery.data) {
5649
return null;
5750
}
5851

5952
const serverVersions = publicConfigurationQuery.data.serverVersions;
53+
const latestVersion = serverVersions[0];
6054
const currentVersion = healthQuery.data.engineVersion ?? "N/A";
61-
const hasNewerVersion = serverVersions[0].name !== currentVersion;
55+
const hasNewerVersion = latestVersion?.name !== currentVersion;
6256

6357
// Hide the change version modal unless owner.
6458
if (!instance.deploymentId) {
@@ -75,11 +69,9 @@ export const EngineVersionBadge = ({
7569
label={
7670
hasNewerVersion
7771
? "An update is available"
78-
: "You are on the latest version"
79-
}
80-
leftIcon={
81-
<CircleArrowDownIcon className="size-4 text-link-foreground" />
72+
: "Engine is on the latest update"
8273
}
74+
leftIcon={<CircleArrowUpIcon className="size-4 text-link-foreground" />}
8375
>
8476
<Button
8577
variant="outline"
@@ -103,7 +95,7 @@ export const EngineVersionBadge = ({
10395
instance={instance}
10496
currentVersion={currentVersion}
10597
serverVersions={serverVersions}
106-
teamId={teamId}
98+
teamSlug={teamSlug}
10799
/>
108100
</>
109101
);
@@ -115,15 +107,15 @@ const ChangeVersionModal = (props: {
115107
instance: EngineInstance;
116108
currentVersion: string;
117109
serverVersions: { name: string; createdAt: string }[];
118-
teamId: string;
110+
teamSlug: string;
119111
}) => {
120112
const {
121113
open,
122114
onOpenChange,
123115
instance,
124116
currentVersion,
125117
serverVersions,
126-
teamId,
118+
teamSlug,
127119
} = props;
128120
const [selectedVersion, setSelectedVersion] = useState(
129121
serverVersions[0]?.name,
@@ -162,11 +154,12 @@ const ChangeVersionModal = (props: {
162154
}
163155

164156
const onClickUpdate = async () => {
157+
invariant(selectedVersion, "No version selected.");
165158
invariant(instance.deploymentId, "Engine is missing deploymentId.");
166159

167160
try {
168161
const promise = updateDeploymentMutation.mutateAsync({
169-
teamId,
162+
teamSlug,
170163
deploymentId: instance.deploymentId,
171164
serverVersion: selectedVersion,
172165
});
@@ -271,11 +264,12 @@ const ChangeVersionModal = (props: {
271264
onClick={onClickUpdate}
272265
variant="primary"
273266
className="gap-2"
267+
disabled={selectedVersion === currentVersion}
274268
>
275269
{updateDeploymentMutation.isPending ? (
276270
<Spinner className="size-4" />
277271
) : (
278-
<CloudDownloadIcon className="size-4" />
272+
<CircleArrowUpIcon className="size-4" />
279273
)}
280274
Update to {selectedVersion}
281275
</Button>

apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(instance)/[engineId]/overview/overview-page.client.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ import { EngineOverview } from "./components/engine-overview";
66
export function EngineOverviewPage(props: {
77
engineId: string;
88
teamSlug: string;
9-
teamId: string;
109
}) {
1110
return (
1211
<WithEngineInstance
1312
engineId={props.engineId}
1413
content={(res) => (
1514
<EngineOverview instance={res.instance} teamSlug={props.teamSlug} />
1615
)}
17-
teamId={props.teamId}
16+
teamSlug={props.teamSlug}
1817
/>
1918
);
2019
}
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
import { getTeamBySlug } from "@/api/team";
2-
import { redirect } from "next/navigation";
31
import { EngineOverviewPage } from "./overview/overview-page.client";
42
import type { EngineInstancePageProps } from "./types";
53

64
export default async function Page(props: EngineInstancePageProps) {
75
const params = await props.params;
8-
const team = await getTeamBySlug(params.team_slug);
9-
if (!team) {
10-
redirect("/team");
11-
}
12-
136
return (
147
<EngineOverviewPage
158
engineId={params.engineId}
169
teamSlug={params.team_slug}
17-
teamId={team.id}
1810
/>
1911
);
2012
}

0 commit comments

Comments
 (0)