Skip to content

Commit 9d6c424

Browse files
committed
Add deploy admin debug tooltips
1 parent cffc88a commit 9d6c424

File tree

4 files changed

+116
-1
lines changed

4 files changed

+116
-1
lines changed

apps/webapp/app/env.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const EnvironmentSchema = z.object({
104104
COORDINATOR_SECRET: z.string().default("coordinator-secret"),
105105
DEPOT_TOKEN: z.string().optional(),
106106
DEPOT_PROJECT_ID: z.string().optional(),
107+
DEPOT_ORG_ID: z.string().optional(),
107108
CONTAINER_REGISTRY_ORIGIN: z.string().optional(),
108109
CONTAINER_REGISTRY_USERNAME: z.string().optional(),
109110
CONTAINER_REGISTRY_PASSWORD: z.string().optional(),

apps/webapp/app/presenters/v3/DeploymentPresenter.server.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
DeploymentErrorData,
3+
ExternalBuildData,
34
TaskMetadataFailedToParseData,
45
groupTaskMetadataIssuesByTask,
56
} from "@trigger.dev/core/v3";
@@ -39,6 +40,7 @@ export class DeploymentPresenter {
3940
const project = await this.#prismaClient.project.findFirstOrThrow({
4041
select: {
4142
id: true,
43+
organizationId: true,
4244
},
4345
where: {
4446
slug: projectSlug,
@@ -65,6 +67,9 @@ export class DeploymentPresenter {
6567
shortCode: true,
6668
version: true,
6769
errorData: true,
70+
imageReference: true,
71+
externalBuildData: true,
72+
projectId: true,
6873
environment: {
6974
select: {
7075
id: true,
@@ -117,6 +122,10 @@ export class DeploymentPresenter {
117122
},
118123
});
119124

125+
const externalBuildData = deployment.externalBuildData
126+
? ExternalBuildData.safeParse(deployment.externalBuildData)
127+
: undefined;
128+
120129
return {
121130
deployment: {
122131
id: deployment.id,
@@ -137,6 +146,11 @@ export class DeploymentPresenter {
137146
deployedBy: deployment.triggeredBy,
138147
errorData: this.#prepareErrorData(deployment.errorData),
139148
sdkVersion: deployment.worker?.sdkVersion,
149+
imageReference: deployment.imageReference,
150+
externalBuildData:
151+
externalBuildData && externalBuildData.success ? externalBuildData.data : undefined,
152+
projectId: deployment.projectId,
153+
organizationId: project.organizationId,
140154
},
141155
};
142156
}

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.deployments.$deploymentParam/route.tsx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { useLocation } from "@remix-run/react";
1+
import { Link, useLocation } from "@remix-run/react";
22
import { LoaderFunctionArgs } from "@remix-run/server-runtime";
33
import { typedjson, useTypedLoaderData } from "remix-typedjson";
44
import { ExitIcon } from "~/assets/icons/ExitIcon";
55
import { UserAvatar } from "~/components/UserProfilePhoto";
6+
import { AdminDebugTooltip } from "~/components/admin/debugTooltip";
67
import { CodeBlock } from "~/components/code/CodeBlock";
78
import { EnvironmentLabel } from "~/components/environments/EnvironmentLabel";
89
import { Badge } from "~/components/primitives/Badge";
@@ -68,6 +69,48 @@ export default function Page() {
6869
<div className="grid h-full max-h-full grid-rows-[2.5rem_1fr] overflow-hidden bg-background-bright">
6970
<div className="mx-3 flex items-center justify-between gap-2 border-b border-grid-dimmed">
7071
<Header2 className={cn("whitespace-nowrap")}>Deploy: {deployment.shortCode}</Header2>
72+
73+
<AdminDebugTooltip>
74+
<PropertyTable>
75+
<Property label="ID">
76+
<div className="flex items-center gap-2">
77+
<Paragraph variant="extra-small/bright/mono">{deployment.id}</Paragraph>
78+
</div>
79+
</Property>
80+
<Property label="Project ID">
81+
<div className="flex items-center gap-2">
82+
<Paragraph variant="extra-small/bright/mono">{deployment.projectId}</Paragraph>
83+
</div>
84+
</Property>
85+
<Property label="Org ID">
86+
<div className="flex items-center gap-2">
87+
<Paragraph variant="extra-small/bright/mono">{deployment.organizationId}</Paragraph>
88+
</div>
89+
</Property>
90+
{deployment.imageReference && (
91+
<Property label="Image">
92+
<div className="flex items-center gap-2">
93+
<Paragraph variant="extra-small/bright/mono">
94+
{deployment.imageReference}
95+
</Paragraph>
96+
</div>
97+
</Property>
98+
)}
99+
{deployment.externalBuildData && (
100+
<Property label="Build Server">
101+
<div className="flex items-center gap-2">
102+
<Link
103+
to={`/resources/${deployment.projectId}/deployments/${deployment.id}/logs`}
104+
className="extra-small/bright/mono underline"
105+
>
106+
{deployment.externalBuildData.buildId}
107+
</Link>
108+
</div>
109+
</Property>
110+
)}
111+
</PropertyTable>
112+
</AdminDebugTooltip>
113+
71114
<LinkButton
72115
to={`${v3DeploymentsPath(organization, project)}${page ? `?page=${page}` : ""}`}
73116
variant="minimal/medium"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { LoaderFunctionArgs } from "@remix-run/server-runtime";
2+
import { ExternalBuildData } from "@trigger.dev/core/v3";
3+
import { z } from "zod";
4+
import { prisma } from "~/db.server";
5+
import { env } from "~/env.server";
6+
import { redirectBackWithErrorMessage } from "~/models/message.server";
7+
import { requireUserId } from "~/services/session.server";
8+
9+
const ParamsSchema = z.object({
10+
projectId: z.string(),
11+
deploymentId: z.string(),
12+
});
13+
14+
// Redirects to Depot.dev
15+
export async function loader({ params, request }: LoaderFunctionArgs) {
16+
const userId = await requireUserId(request);
17+
const { projectId, deploymentId } = ParamsSchema.parse(params);
18+
19+
await prisma.project.findFirstOrThrow({
20+
where: {
21+
id: projectId,
22+
organization: {
23+
members: {
24+
some: {
25+
userId,
26+
},
27+
},
28+
},
29+
},
30+
});
31+
32+
const deployment = await prisma.workerDeployment.findUniqueOrThrow({
33+
where: {
34+
id: deploymentId,
35+
projectId: projectId,
36+
},
37+
});
38+
39+
const externalBuildData = deployment.externalBuildData
40+
? ExternalBuildData.safeParse(deployment.externalBuildData)
41+
: undefined;
42+
43+
if (!externalBuildData || externalBuildData.success === false) {
44+
return redirectBackWithErrorMessage(request, "No build data found for this deployment.");
45+
}
46+
47+
if (!env.DEPOT_ORG_ID) {
48+
return redirectBackWithErrorMessage(request, "No Depot organization ID found.");
49+
}
50+
51+
return new Response(null, {
52+
status: 302,
53+
headers: {
54+
Location: `https://depot.dev/orgs/${env.DEPOT_ORG_ID}/projects/${externalBuildData.data.projectId}/builds/${externalBuildData.data.buildId}/logs`,
55+
},
56+
});
57+
}

0 commit comments

Comments
 (0)