Run redirect route and link to runs from Query page
This commit is contained in:
@@ -17,6 +17,8 @@ import {
|
||||
TaskRunStatusCombo,
|
||||
} from "~/components/runs/v3/TaskRunStatus";
|
||||
import { Paragraph } from "../primitives/Paragraph";
|
||||
import { TextLink } from "../primitives/TextLink";
|
||||
import { v3RunPathFromFriendlyId } from "~/utils/pathBuilder";
|
||||
|
||||
/**
|
||||
* Check if a ClickHouse type is a DateTime type
|
||||
@@ -83,6 +85,12 @@ function CellValue({
|
||||
// First check customRenderType for special rendering
|
||||
if (column.customRenderType) {
|
||||
switch (column.customRenderType) {
|
||||
case "runId": {
|
||||
if (typeof value === "string") {
|
||||
return <TextLink to={v3RunPathFromFriendlyId(value)}>{value}</TextLink>;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "runStatus": {
|
||||
// We have mapped the status to a friendly status so we need to map back to render the normal component
|
||||
if (isTaskRunStatus(value)) {
|
||||
|
||||
+1
-1
@@ -202,7 +202,7 @@ export default function Page() {
|
||||
minHeight="200px"
|
||||
className="min-h-[200px]"
|
||||
/>
|
||||
<Form method="post" className="flex items-center justify-end gap-3 px-2">
|
||||
<Form method="post" className="flex items-center justify-end gap-2 px-2">
|
||||
<input type="hidden" name="query" value={query} />
|
||||
<input type="hidden" name="scope" value={scope} />
|
||||
<Select
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { redirect, type LoaderFunctionArgs } from "@remix-run/server-runtime";
|
||||
import { z } from "zod";
|
||||
import { prisma } from "~/db.server";
|
||||
import { redirectWithErrorMessage } from "~/models/message.server";
|
||||
import { requireUser } from "~/services/session.server";
|
||||
import { rootPath, v3RunPath } from "~/utils/pathBuilder";
|
||||
|
||||
const ParamsSchema = z.object({
|
||||
runParam: z.string(),
|
||||
});
|
||||
|
||||
export async function loader({ params, request }: LoaderFunctionArgs) {
|
||||
const user = await requireUser(request);
|
||||
|
||||
const { runParam } = ParamsSchema.parse(params);
|
||||
|
||||
const run = await prisma.taskRun.findFirst({
|
||||
where: {
|
||||
friendlyId: runParam,
|
||||
project: {
|
||||
organization: {
|
||||
members: {
|
||||
some: {
|
||||
userId: user.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
runtimeEnvironment: {
|
||||
select: {
|
||||
slug: true,
|
||||
},
|
||||
},
|
||||
project: {
|
||||
select: {
|
||||
slug: true,
|
||||
organization: {
|
||||
select: {
|
||||
slug: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!run) {
|
||||
return redirectWithErrorMessage(
|
||||
rootPath(),
|
||||
request,
|
||||
"Run either doesn't exist or you don't have permission to view it",
|
||||
{
|
||||
ephemeral: false,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return redirect(
|
||||
v3RunPath(
|
||||
{ slug: run.project.organization.slug },
|
||||
{ slug: run.project.slug },
|
||||
{ slug: run.runtimeEnvironment.slug },
|
||||
{ friendlyId: runParam }
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -306,11 +306,15 @@ export function v3RunPath(
|
||||
export function v3RunRedirectPath(
|
||||
organization: OrgForPath,
|
||||
project: ProjectForPath,
|
||||
run: v3RunForPath,
|
||||
run: v3RunForPath
|
||||
) {
|
||||
return `${v3ProjectPath(organization, project)}/runs/${run.friendlyId}`;
|
||||
}
|
||||
|
||||
export function v3RunPathFromFriendlyId(runId: string) {
|
||||
return `/runs/${runId}`;
|
||||
}
|
||||
|
||||
export function v3RunDownloadLogsPath(run: v3RunForPath) {
|
||||
return `/resources/runs/${run.friendlyId}/logs/download`;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export const runsSchema: TableSchema = {
|
||||
run_id: {
|
||||
name: "run_id",
|
||||
clickhouseName: "friendly_id",
|
||||
...column("String", { description: "Run ID (e.g., run_abc123)" }),
|
||||
...column("String", { description: "Run ID (e.g., run_abc123)", customRenderType: "runId" }),
|
||||
},
|
||||
environment_id: {
|
||||
name: "environment_id",
|
||||
@@ -54,6 +54,7 @@ export const runsSchema: TableSchema = {
|
||||
...column("LowCardinality(String)", {
|
||||
description: "Environment type",
|
||||
allowedValues: [...ENVIRONMENT_TYPES],
|
||||
customRenderType: "environmentType",
|
||||
}),
|
||||
},
|
||||
attempt: {
|
||||
|
||||
Reference in New Issue
Block a user