Skip to content

Commit a22e189

Browse files
committed
WIP adding separate links to Parent and Root runs
1 parent 05a0f4f commit a22e189

File tree

1 file changed

+86
-53
lines changed
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam

1 file changed

+86
-53
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx

Lines changed: 86 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import {
9595
} from "~/utils/pathBuilder";
9696
import { useCurrentPlan } from "../_app.orgs.$organizationSlug/route";
9797
import { SpanView } from "../resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route";
98+
import { TextLink } from "~/components/primitives/TextLink";
9899

99100
const resizableSettings = {
100101
parent: {
@@ -587,16 +588,31 @@ function TasksTreeView({
587588
>
588589
<div className="grid h-full grid-rows-[2rem_1fr] overflow-hidden">
589590
<div className="flex items-center pr-2">
590-
{rootRun ? (
591-
<ShowParentLink
592-
runFriendlyId={rootRun.friendlyId}
593-
isRoot={true}
594-
spanId={rootRun.spanId}
591+
{rootRun || parentRunFriendlyId ? (
592+
<ShowParentOrRootLinks
593+
relationships={{
594+
root: rootRun
595+
? {
596+
friendlyId: rootRun.friendlyId,
597+
taskIdentifier: rootRun.taskIdentifier,
598+
spanId: rootRun.spanId,
599+
isParent: parentRunFriendlyId
600+
? rootRun.friendlyId === parentRunFriendlyId
601+
: true,
602+
}
603+
: undefined,
604+
parent:
605+
parentRunFriendlyId && rootRun?.friendlyId !== parentRunFriendlyId
606+
? {
607+
friendlyId: parentRunFriendlyId,
608+
taskIdentifier: "",
609+
spanId: "",
610+
}
611+
: undefined,
612+
}}
595613
/>
596-
) : parentRunFriendlyId ? (
597-
<ShowParentLink runFriendlyId={parentRunFriendlyId} isRoot={false} />
598614
) : (
599-
<Paragraph variant="small" className="flex-1 text-charcoal-500">
615+
<Paragraph variant="extra-small" className="flex-1 text-charcoal-500">
600616
This is the root task
601617
</Paragraph>
602618
)}
@@ -1126,60 +1142,77 @@ function TaskLine({ isError, isSelected }: { isError: boolean; isSelected: boole
11261142
return <div className={cn("h-8 w-2 border-r border-grid-bright")} />;
11271143
}
11281144

1129-
function ShowParentLink({
1130-
runFriendlyId,
1131-
spanId,
1132-
isRoot,
1145+
function ShowParentOrRootLinks({
1146+
relationships,
11331147
}: {
1134-
runFriendlyId: string;
1135-
spanId?: string;
1136-
isRoot: boolean;
1148+
relationships: {
1149+
root?: {
1150+
friendlyId: string;
1151+
taskIdentifier: string;
1152+
spanId: string;
1153+
isParent?: boolean;
1154+
};
1155+
parent?: {
1156+
friendlyId: string;
1157+
taskIdentifier: string;
1158+
spanId: string;
1159+
};
1160+
};
11371161
}) {
1138-
const [mouseOver, setMouseOver] = useState(false);
11391162
const organization = useOrganization();
11401163
const project = useProject();
11411164
const environment = useEnvironment();
1142-
const { spanParam } = useParams();
11431165

1144-
const span = spanId ? spanId : spanParam;
1166+
// Case 1: Root is also the parent
1167+
if (relationships.root?.isParent === true) {
1168+
return (
1169+
<TextLink
1170+
to={v3RunSpanPath(
1171+
organization,
1172+
project,
1173+
environment,
1174+
{ friendlyId: relationships.root.friendlyId },
1175+
{ spanId: relationships.root.spanId }
1176+
)}
1177+
className="text-xs"
1178+
>
1179+
Show Root & Parent run
1180+
</TextLink>
1181+
);
1182+
}
11451183

1184+
// Case 2: Root and Parent are different runs
11461185
return (
1147-
<LinkButton
1148-
variant="minimal/medium"
1149-
to={
1150-
span
1151-
? v3RunSpanPath(
1152-
organization,
1153-
project,
1154-
environment,
1155-
{
1156-
friendlyId: runFriendlyId,
1157-
},
1158-
{ spanId: span }
1159-
)
1160-
: v3RunPath(organization, project, environment, {
1161-
friendlyId: runFriendlyId,
1162-
})
1163-
}
1164-
onMouseEnter={() => setMouseOver(true)}
1165-
onMouseLeave={() => setMouseOver(false)}
1166-
fullWidth
1167-
textAlignLeft
1168-
shortcut={{ key: "p" }}
1169-
className="flex-1"
1170-
>
1171-
{mouseOver ? (
1172-
<ShowParentIconSelected className="h-4 w-4 text-indigo-500" />
1173-
) : (
1174-
<ShowParentIcon className="h-4 w-4 text-charcoal-650" />
1186+
<div className="flex flex-1 items-center gap-2">
1187+
{relationships.root && (
1188+
<TextLink
1189+
to={v3RunSpanPath(
1190+
organization,
1191+
project,
1192+
environment,
1193+
{ friendlyId: relationships.root.friendlyId },
1194+
{ spanId: relationships.root.spanId }
1195+
)}
1196+
className="text-xs"
1197+
>
1198+
Show Root run
1199+
</TextLink>
11751200
)}
1176-
<Paragraph
1177-
variant="small"
1178-
className={cn(mouseOver ? "text-indigo-500" : "text-charcoal-500")}
1179-
>
1180-
{isRoot ? "Show root run" : "Show parent run"}
1181-
</Paragraph>
1182-
</LinkButton>
1201+
{relationships.parent && (
1202+
<TextLink
1203+
to={v3RunSpanPath(
1204+
organization,
1205+
project,
1206+
environment,
1207+
{ friendlyId: relationships.parent.friendlyId },
1208+
{ spanId: relationships.parent.spanId }
1209+
)}
1210+
className="text-xs"
1211+
>
1212+
Show Parent run
1213+
</TextLink>
1214+
)}
1215+
</div>
11831216
);
11841217
}
11851218

0 commit comments

Comments
 (0)