Skip to content

Commit 226805c

Browse files
committed
Allow span icons to be determined based on the span name (e.g. prisma:)
1 parent 848a55f commit 226805c

File tree

3 files changed

+31
-3
lines changed
  • apps/webapp/app
    • components/runs/v3
    • routes
      • _app.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam
      • _app.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam.spans.$spanParam

3 files changed

+31
-3
lines changed

apps/webapp/app/components/runs/v3/RunIcon.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,30 @@ import { cn } from "~/utils/cn";
1212

1313
type TaskIconProps = {
1414
name: string | undefined;
15+
spanName: string;
1516
className?: string;
1617
};
1718

18-
export function RunIcon({ name, className }: TaskIconProps) {
19+
type SpanNameIcons = {
20+
matcher: RegExp;
21+
iconName: string;
22+
};
23+
24+
const spanNameIcons: SpanNameIcons[] = [{ matcher: /^prisma:/, iconName: "brand-prisma" }];
25+
26+
export function RunIcon({ name, className, spanName }: TaskIconProps) {
27+
const spanNameIcon = spanNameIcons.find(({ matcher }) => matcher.test(spanName));
28+
29+
if (spanNameIcon) {
30+
return (
31+
<NamedIcon
32+
name={spanNameIcon.iconName}
33+
className={cn(className)}
34+
fallback={<InformationCircleIcon className={cn(className, "text-text-dimmed")} />}
35+
/>
36+
);
37+
}
38+
1939
if (!name) return <Squares2X2Icon className={cn(className, "text-text-dimmed")} />;
2040

2141
switch (name) {

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam.spans.$spanParam/route.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ export default function Page() {
6565
>
6666
<div className="mx-3 flex items-center justify-between gap-2 border-b border-grid-dimmed">
6767
<div className="flex items-center gap-1 overflow-x-hidden">
68-
<RunIcon name={event.style?.icon} className="h-4 min-h-4 w-4 min-w-4" />
68+
<RunIcon
69+
name={event.style?.icon}
70+
spanName={event.message}
71+
className="h-4 min-h-4 w-4 min-w-4"
72+
/>
6973
<Header2 className={cn("whitespace-nowrap")}>
7074
<SpanTitle {...event} size="large" />
7175
</Header2>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,11 @@ function TasksTreeView({
362362

363363
<div className="flex w-full items-center justify-between gap-2 pl-1">
364364
<div className="flex items-center gap-2 overflow-x-hidden">
365-
<RunIcon name={node.data.style?.icon} className="h-4 min-h-4 w-4 min-w-4" />
365+
<RunIcon
366+
name={node.data.style?.icon}
367+
spanName={node.data.message}
368+
className="h-4 min-h-4 w-4 min-w-4"
369+
/>
366370
<NodeText node={node} />
367371
{node.data.isRoot && <Badge variant="outline-rounded">Root</Badge>}
368372
</div>

0 commit comments

Comments
 (0)