|
| 1 | +import { ArrowUpRightIcon } from "@heroicons/react/20/solid"; |
| 2 | +import { NODE_RUNTIME_UPDATE_MAJOR } from "@trigger.dev/core/v3"; |
| 3 | +import { typedjson, useTypedLoaderData } from "remix-typedjson"; |
| 4 | +import { RuntimeIcon } from "~/components/RuntimeIcon"; |
| 5 | +import { |
| 6 | + MainHorizontallyCenteredContainer, |
| 7 | + PageBody, |
| 8 | + PageContainer, |
| 9 | +} from "~/components/layout/AppLayout"; |
| 10 | +import { LinkButton } from "~/components/primitives/Buttons"; |
| 11 | +import { Header2 } from "~/components/primitives/Headers"; |
| 12 | +import { Paragraph } from "~/components/primitives/Paragraph"; |
| 13 | +import { resolveOrgIdFromSlug } from "~/models/organization.server"; |
| 14 | +import { dashboardLoader } from "~/services/routeBuilders/dashboardBuilder"; |
| 15 | +import { listCurrentProductionProjectRuntimes } from "~/services/projectRuntimeUpdates.server"; |
| 16 | +import { OrganizationParamsSchema, v3DeploymentsPath } from "~/utils/pathBuilder"; |
| 17 | +import { pageMeta } from "~/utils/pageTitle"; |
| 18 | + |
| 19 | +export const meta = pageMeta("Runtime updates"); |
| 20 | + |
| 21 | +export const loader = dashboardLoader( |
| 22 | + { |
| 23 | + params: OrganizationParamsSchema, |
| 24 | + context: async (params) => { |
| 25 | + const organizationId = await resolveOrgIdFromSlug(params.organizationSlug); |
| 26 | + return organizationId ? { organizationId } : {}; |
| 27 | + }, |
| 28 | + authorization: { |
| 29 | + action: "read", |
| 30 | + resource: { type: "deployments" }, |
| 31 | + message: "With your current role, you can't view runtime updates.", |
| 32 | + }, |
| 33 | + }, |
| 34 | + async ({ context, params }) => { |
| 35 | + const runtimes = await listCurrentProductionProjectRuntimes({ |
| 36 | + organizationId: context.organizationId, |
| 37 | + }); |
| 38 | + |
| 39 | + return typedjson({ |
| 40 | + organizationSlug: params.organizationSlug, |
| 41 | + runtimes: runtimes.filter( |
| 42 | + (runtime) => runtime.deployment?.nodeMajor === NODE_RUNTIME_UPDATE_MAJOR |
| 43 | + ), |
| 44 | + }); |
| 45 | + } |
| 46 | +); |
| 47 | + |
| 48 | +export default function Page() { |
| 49 | + const { organizationSlug, runtimes } = useTypedLoaderData<typeof loader>(); |
| 50 | + |
| 51 | + return ( |
| 52 | + <PageContainer> |
| 53 | + <PageBody> |
| 54 | + <MainHorizontallyCenteredContainer> |
| 55 | + <header className="mb-8 max-w-2xl"> |
| 56 | + <p className="mb-2 text-xs font-medium uppercase tracking-[0.16em] text-warning"> |
| 57 | + Runtime update available |
| 58 | + </p> |
| 59 | + <Header2>Move Production projects to Node.js 24</Header2> |
| 60 | + <Paragraph className="mt-2 text-text-dimmed"> |
| 61 | + {runtimes.length} {runtimes.length === 1 ? "project is" : "projects are"} currently |
| 62 | + running Node.js {NODE_RUNTIME_UPDATE_MAJOR} in Production. Update every project listed |
| 63 | + below. |
| 64 | + </Paragraph> |
| 65 | + </header> |
| 66 | + |
| 67 | + {runtimes.length === 0 ? ( |
| 68 | + <div className="border border-grid-bright bg-background-bright px-5 py-6"> |
| 69 | + <Header2 className="text-base">Everything is up to date</Header2> |
| 70 | + <Paragraph className="mt-1 text-text-dimmed"> |
| 71 | + No Production projects are currently using Node.js {NODE_RUNTIME_UPDATE_MAJOR}. |
| 72 | + </Paragraph> |
| 73 | + </div> |
| 74 | + ) : ( |
| 75 | + <div className="space-y-4"> |
| 76 | + <div className="border border-warning/30 bg-warning/5 px-5 py-4"> |
| 77 | + <p className="text-sm font-medium text-text-bright">Update every listed project</p> |
| 78 | + <Paragraph className="mt-1 text-sm text-text-dimmed"> |
| 79 | + In each project's <code>trigger.config.ts</code>, set the runtime below and |
| 80 | + deploy a new Production version. |
| 81 | + </Paragraph> |
| 82 | + <pre className="mt-3 overflow-x-auto border border-grid-bright bg-background-dimmed px-3 py-2.5 font-mono text-sm text-text-bright"> |
| 83 | + <code>runtime: "node-24",</code> |
| 84 | + </pre> |
| 85 | + </div> |
| 86 | + |
| 87 | + <div className="overflow-hidden border border-grid-bright bg-background-bright"> |
| 88 | + {runtimes.map(({ project, environment, deployment }) => { |
| 89 | + if (!deployment) return null; |
| 90 | + |
| 91 | + return ( |
| 92 | + <div |
| 93 | + key={project.externalRef} |
| 94 | + className="grid gap-5 border-b border-grid-bright p-5 last:border-b-0 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center" |
| 95 | + > |
| 96 | + <div className="min-w-0"> |
| 97 | + <p className="truncate font-medium text-text-bright">{project.name}</p> |
| 98 | + <div className="mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-text-dimmed"> |
| 99 | + <RuntimeIcon |
| 100 | + runtime={deployment.runtime} |
| 101 | + runtimeVersion={deployment.runtimeVersion} |
| 102 | + withLabel |
| 103 | + /> |
| 104 | + <span> |
| 105 | + Production deployed {deployment.deployedAt?.toLocaleString() ?? "-"} |
| 106 | + </span> |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + <LinkButton |
| 110 | + variant="secondary/small" |
| 111 | + LeadingIcon={ArrowUpRightIcon} |
| 112 | + to={v3DeploymentsPath( |
| 113 | + { slug: organizationSlug }, |
| 114 | + { slug: project.slug }, |
| 115 | + { slug: environment.slug } |
| 116 | + )} |
| 117 | + > |
| 118 | + View deployment |
| 119 | + </LinkButton> |
| 120 | + </div> |
| 121 | + ); |
| 122 | + })} |
| 123 | + </div> |
| 124 | + </div> |
| 125 | + )} |
| 126 | + </MainHorizontallyCenteredContainer> |
| 127 | + </PageBody> |
| 128 | + </PageContainer> |
| 129 | + ); |
| 130 | +} |
0 commit comments