|
| 1 | +import { Link } from "@remix-run/react"; |
| 2 | +import { typedjson, useTypedLoaderData } from "remix-typedjson"; |
| 3 | +import { NODE_RUNTIME_UPDATE_MAJOR } from "@trigger.dev/core/v3"; |
| 4 | +import { RuntimeIcon } from "~/components/RuntimeIcon"; |
| 5 | +import { |
| 6 | + MainHorizontallyCenteredContainer, |
| 7 | + PageBody, |
| 8 | + PageContainer, |
| 9 | +} from "~/components/layout/AppLayout"; |
| 10 | +import { Header2 } from "~/components/primitives/Headers"; |
| 11 | +import { Paragraph } from "~/components/primitives/Paragraph"; |
| 12 | +import { |
| 13 | + Table, |
| 14 | + TableBody, |
| 15 | + TableCell, |
| 16 | + TableHeader, |
| 17 | + TableHeaderCell, |
| 18 | + TableRow, |
| 19 | +} from "~/components/primitives/Table"; |
| 20 | +import { resolveOrgIdFromSlug } from "~/models/organization.server"; |
| 21 | +import { dashboardLoader } from "~/services/routeBuilders/dashboardBuilder"; |
| 22 | +import { listCurrentProductionProjectRuntimes } from "~/services/projectRuntimeUpdates.server"; |
| 23 | +import { OrganizationParamsSchema, v3DeploymentsPath } from "~/utils/pathBuilder"; |
| 24 | +import { pageMeta } from "~/utils/pageTitle"; |
| 25 | + |
| 26 | +export const meta = pageMeta("Runtime updates"); |
| 27 | + |
| 28 | +export const loader = dashboardLoader( |
| 29 | + { |
| 30 | + params: OrganizationParamsSchema, |
| 31 | + context: async (params) => { |
| 32 | + const organizationId = await resolveOrgIdFromSlug(params.organizationSlug); |
| 33 | + return organizationId ? { organizationId } : {}; |
| 34 | + }, |
| 35 | + authorization: { |
| 36 | + action: "read", |
| 37 | + resource: { type: "deployments" }, |
| 38 | + message: "With your current role, you can't view runtime updates.", |
| 39 | + }, |
| 40 | + }, |
| 41 | + async ({ context, params }) => { |
| 42 | + const runtimes = await listCurrentProductionProjectRuntimes({ |
| 43 | + organizationId: context.organizationId, |
| 44 | + }); |
| 45 | + |
| 46 | + return typedjson({ |
| 47 | + organizationSlug: params.organizationSlug, |
| 48 | + runtimes: runtimes.filter( |
| 49 | + (runtime) => runtime.deployment?.nodeMajor === NODE_RUNTIME_UPDATE_MAJOR |
| 50 | + ), |
| 51 | + }); |
| 52 | + } |
| 53 | +); |
| 54 | + |
| 55 | +export default function Page() { |
| 56 | + const { organizationSlug, runtimes } = useTypedLoaderData<typeof loader>(); |
| 57 | + |
| 58 | + return ( |
| 59 | + <PageContainer> |
| 60 | + <PageBody> |
| 61 | + <MainHorizontallyCenteredContainer> |
| 62 | + <div className="mb-6"> |
| 63 | + <Header2>Runtime updates</Header2> |
| 64 | + <Paragraph className="mt-2 text-text-dimmed"> |
| 65 | + Projects with a current Production deployment using Node.js{" "} |
| 66 | + {NODE_RUNTIME_UPDATE_MAJOR}. Update your <code>trigger.config</code> to use{" "} |
| 67 | + <code>runtime: "node-24"</code>, then deploy again. |
| 68 | + </Paragraph> |
| 69 | + </div> |
| 70 | + |
| 71 | + {runtimes.length === 0 ? ( |
| 72 | + <Paragraph className="text-text-dimmed"> |
| 73 | + No Production projects are currently using Node.js {NODE_RUNTIME_UPDATE_MAJOR}. |
| 74 | + </Paragraph> |
| 75 | + ) : ( |
| 76 | + <Table variant="bright" fullWidth> |
| 77 | + <TableHeader> |
| 78 | + <TableRow> |
| 79 | + <TableHeaderCell>Project</TableHeaderCell> |
| 80 | + <TableHeaderCell>Runtime</TableHeaderCell> |
| 81 | + <TableHeaderCell>Deployed</TableHeaderCell> |
| 82 | + <TableHeaderCell /> |
| 83 | + </TableRow> |
| 84 | + </TableHeader> |
| 85 | + <TableBody> |
| 86 | + {runtimes.map(({ project, environment, deployment }) => { |
| 87 | + if (!deployment) return null; |
| 88 | + |
| 89 | + return ( |
| 90 | + <TableRow key={project.externalRef}> |
| 91 | + <TableCell> |
| 92 | + <span className="font-medium text-text-bright">{project.name}</span> |
| 93 | + </TableCell> |
| 94 | + <TableCell> |
| 95 | + <RuntimeIcon |
| 96 | + runtime={deployment.runtime} |
| 97 | + runtimeVersion={deployment.runtimeVersion} |
| 98 | + withLabel |
| 99 | + /> |
| 100 | + </TableCell> |
| 101 | + <TableCell>{deployment.deployedAt?.toLocaleString() ?? "-"}</TableCell> |
| 102 | + <TableCell alignment="right"> |
| 103 | + <Link |
| 104 | + to={v3DeploymentsPath( |
| 105 | + { slug: organizationSlug }, |
| 106 | + { slug: project.slug }, |
| 107 | + { slug: environment.slug } |
| 108 | + )} |
| 109 | + className="text-sm text-indigo-500 hover:text-indigo-400" |
| 110 | + > |
| 111 | + View deployment |
| 112 | + </Link> |
| 113 | + </TableCell> |
| 114 | + </TableRow> |
| 115 | + ); |
| 116 | + })} |
| 117 | + </TableBody> |
| 118 | + </Table> |
| 119 | + )} |
| 120 | + </MainHorizontallyCenteredContainer> |
| 121 | + </PageBody> |
| 122 | + </PageContainer> |
| 123 | + ); |
| 124 | +} |
0 commit comments