-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathRunIcon.tsx
More file actions
128 lines (118 loc) · 4.77 KB
/
RunIcon.tsx
File metadata and controls
128 lines (118 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import {
ClockIcon,
HandRaisedIcon,
InformationCircleIcon,
RectangleStackIcon,
Squares2X2Icon,
TableCellsIcon,
TagIcon,
} from "@heroicons/react/20/solid";
import { AttemptIcon } from "~/assets/icons/AttemptIcon";
import { TaskIcon } from "~/assets/icons/TaskIcon";
import { cn } from "~/utils/cn";
import { tablerIcons } from "~/utils/tablerIcons";
import tablerSpritePath from "~/components/primitives/tabler-sprite.svg";
import { TaskCachedIcon } from "~/assets/icons/TaskCachedIcon";
import { PauseIcon } from "~/assets/icons/PauseIcon";
import { RunFunctionIcon } from "~/assets/icons/RunFunctionIcon";
import { MiddlewareIcon } from "~/assets/icons/MiddlewareIcon";
import { FunctionIcon } from "~/assets/icons/FunctionIcon";
import { TriggerIcon } from "~/assets/icons/TriggerIcon";
import { PythonLogoIcon } from "~/assets/icons/PythonLogoIcon";
import { TraceIcon } from "~/assets/icons/TraceIcon";
import { WaitpointTokenIcon } from "~/assets/icons/WaitpointTokenIcon";
import { StreamsIcon } from "~/assets/icons/StreamsIcon";
type TaskIconProps = {
name: string | undefined;
spanName: string;
className?: string;
};
type SpanNameIcons = {
matcher: RegExp;
iconName: string;
};
const spanNameIcons: SpanNameIcons[] = [{ matcher: /^prisma:/, iconName: "brand-prisma" }];
export function RunIcon({ name, className, spanName }: TaskIconProps) {
const spanNameIcon = spanNameIcons.find(({ matcher }) => matcher.test(spanName));
if (spanNameIcon) {
if (tablerIcons.has("tabler-" + spanNameIcon.iconName)) {
return <TablerIcon name={"tabler-" + spanNameIcon.iconName} className={className} />;
} else if (
spanNameIcon.iconName.startsWith("tabler-") &&
tablerIcons.has(spanNameIcon.iconName)
) {
return <TablerIcon name={spanNameIcon.iconName} className={className} />;
}
<InformationCircleIcon className={cn(className, "text-text-dimmed")} />;
}
if (!name) return <Squares2X2Icon className={cn(className, "text-text-dimmed")} />;
if (tablerIcons.has(name)) {
return <TablerIcon name={name} className={className} />;
}
switch (name) {
case "task":
return <TaskIcon className={cn(className, "text-blue-500")} />;
case "task-cached":
return <TaskCachedIcon className={cn(className, "text-blue-500")} />;
case "scheduled":
return <ClockIcon className={cn(className, "text-sun-500")} />;
case "attempt":
return <AttemptIcon className={cn(className, "text-text-dimmed")} />;
case "wait":
return <PauseIcon className={cn(className, "text-teal-500")} />;
case "trace":
return <TraceIcon className={cn(className, "text-text-dimmed")} />;
case "tag":
return <TagIcon className={cn(className, "text-text-dimmed")} />;
case "queue":
return <RectangleStackIcon className={cn(className, "text-purple-500")} />;
case "trigger":
return <TriggerIcon className={cn(className, "text-orange-500")} />;
case "python":
return <PythonLogoIcon className={className} />;
case "wait-token":
return <WaitpointTokenIcon className={cn(className, "text-sky-500")} />;
case "function":
return <FunctionIcon className={cn(className, "text-text-dimmed")} />;
case "query":
return <TableCellsIcon className={cn(className, "text-query")} />;
//log levels
case "debug":
case "log":
case "info":
return <InformationCircleIcon className={cn(className, "text-text-dimmed")} />;
case "warn":
return <InformationCircleIcon className={cn(className, "text-amber-400")} />;
case "error":
return <InformationCircleIcon className={cn(className, "text-error")} />;
case "fatal":
return <HandRaisedIcon className={cn(className, "text-error")} />;
case "task-middleware":
return <MiddlewareIcon className={cn(className, "text-text-dimmed")} />;
case "task-fn-run":
return <RunFunctionIcon className={cn(className, "text-text-dimmed")} />;
case "task-hook-init":
case "task-hook-onStart":
case "task-hook-onStartAttempt":
case "task-hook-onSuccess":
case "task-hook-onWait":
case "task-hook-onResume":
case "task-hook-onComplete":
case "task-hook-cleanup":
case "task-hook-onCancel":
return <FunctionIcon className={cn(className, "text-text-dimmed")} />;
case "task-hook-onFailure":
case "task-hook-catchError":
return <FunctionIcon className={cn(className, "text-error")} />;
case "streams":
return <StreamsIcon className={cn(className, "text-text-dimmed")} />;
}
return <InformationCircleIcon className={cn(className, "text-text-dimmed")} />;
}
function TablerIcon({ name, className }: { name: string; className?: string }) {
return (
<svg className={cn("stroke-[1.5]", className)}>
<use xlinkHref={`${tablerSpritePath}#${name}`} />
</svg>
);
}