Skip to content

Commit 00629cf

Browse files
committed
Unify the error statuses into a reusable badge
1 parent b18f437 commit 00629cf

File tree

3 files changed

+39
-44
lines changed
  • apps/webapp/app
    • components/errors
    • routes
      • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors.$fingerprint
      • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors._index

3 files changed

+39
-44
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { type ErrorGroupStatus } from "@trigger.dev/database";
2+
import { cn } from "~/utils/cn";
3+
4+
const styles: Record<ErrorGroupStatus, string> = {
5+
UNRESOLVED: "bg-error/10 text-error",
6+
RESOLVED: "bg-success/10 text-success",
7+
IGNORED: "bg-charcoal-750 text-text-dimmed",
8+
};
9+
10+
const labels: Record<ErrorGroupStatus, string> = {
11+
UNRESOLVED: "Unresolved",
12+
RESOLVED: "Resolved",
13+
IGNORED: "Ignored",
14+
};
15+
16+
export function ErrorStatusBadge({
17+
status,
18+
className,
19+
}: {
20+
status: ErrorGroupStatus;
21+
className?: string;
22+
}) {
23+
return (
24+
<span
25+
className={cn(
26+
"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium",
27+
styles[status],
28+
className
29+
)}
30+
>
31+
{labels[status]}
32+
</span>
33+
);
34+
}

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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type MetaFunction, Form, useFetcher, useNavigation, useSubmit } from "@
33
import { BellAlertIcon } from "@heroicons/react/20/solid";
44
import { parse } from "@conform-to/zod";
55
import { z } from "zod";
6+
import { ErrorStatusBadge } from "~/components/errors/ErrorStatusBadge";
67
import { ServiceValidationError } from "~/v3/services/baseService.server";
78
import { TypedAwait, typeddefer, useTypedLoaderData } from "remix-typedjson";
89
import { requireUser, requireUserId } from "~/services/session.server";
@@ -543,27 +544,6 @@ function ErrorGroupDetail({
543544
);
544545
}
545546

546-
const STATUS_BADGE_STYLES = {
547-
UNRESOLVED: "bg-error/10 text-error",
548-
RESOLVED: "bg-success/10 text-success",
549-
IGNORED: "bg-text-dimmed/10 text-text-dimmed",
550-
} as const;
551-
552-
const STATUS_LABELS = {
553-
UNRESOLVED: "Unresolved",
554-
RESOLVED: "Resolved",
555-
IGNORED: "Ignored",
556-
} as const;
557-
558-
function StatusBadge({ status }: { status: ErrorGroupState["status"] }) {
559-
return (
560-
<span
561-
className={`inline-flex items-center rounded px-2 py-0.5 text-xs font-medium ${STATUS_BADGE_STYLES[status]}`}
562-
>
563-
{STATUS_LABELS[status]}
564-
</span>
565-
);
566-
}
567547

568548
function IgnoredDetails({
569549
state,
@@ -665,7 +645,7 @@ function ErrorGroupActionButtons({
665645
return (
666646
<>
667647
<Form className="flex items-center gap-2">
668-
<StatusBadge status={state.status} />
648+
<ErrorStatusBadge status={state.status} />
669649

670650
{state.status === "UNRESOLVED" && (
671651
<>

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

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Form, type MetaFunction, useRevalidator } from "@remix-run/react";
44
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
55
import { type ErrorGroupStatus } from "@trigger.dev/database";
66
import { IconBugFilled } from "@tabler/icons-react";
7+
import { ErrorStatusBadge } from "~/components/errors/ErrorStatusBadge";
78
import { ErrorId } from "@trigger.dev/core/v3/isomorphic";
89
import { Suspense, useCallback, useMemo, type ReactNode } from "react";
910
import {
@@ -382,7 +383,7 @@ function ErrorStatusDropdown({
382383
<SelectList>
383384
{filtered.map((item) => (
384385
<SelectItem key={item.value} value={item.value}>
385-
{item.label}
386+
<ErrorStatusBadge status={item.value} />
386387
</SelectItem>
387388
))}
388389
</SelectList>
@@ -569,7 +570,7 @@ function ErrorGroupRow({
569570
{errorGroup.fingerprint.slice(-8)}
570571
</CopyableTableCell>
571572
<TableCell to={errorPath}>
572-
<ListStatusBadge status={errorGroup.status} />
573+
<ErrorStatusBadge status={errorGroup.status} />
573574
</TableCell>
574575
<TableCell to={errorPath}>{errorGroup.taskIdentifier}</TableCell>
575576
<CopyableTableCell to={errorPath} className="font-mono" value={errorMessage}>
@@ -602,26 +603,6 @@ function ErrorGroupRow({
602603
);
603604
}
604605

605-
const LIST_STATUS_STYLES = {
606-
UNRESOLVED: "text-error",
607-
RESOLVED: "text-success",
608-
IGNORED: "text-text-dimmed",
609-
} as const;
610-
611-
const LIST_STATUS_LABELS = {
612-
UNRESOLVED: "Unresolved",
613-
RESOLVED: "Resolved",
614-
IGNORED: "Ignored",
615-
} as const;
616-
617-
function ListStatusBadge({ status }: { status: string }) {
618-
const s = (status as keyof typeof LIST_STATUS_STYLES) ?? "UNRESOLVED";
619-
return (
620-
<span className={`text-xs ${LIST_STATUS_STYLES[s] ?? LIST_STATUS_STYLES.UNRESOLVED}`}>
621-
{LIST_STATUS_LABELS[s] ?? "Unresolved"}
622-
</span>
623-
);
624-
}
625606

626607
function ErrorActivityGraph({ activity }: { activity: ErrorOccurrenceActivity }) {
627608
const maxCount = Math.max(...activity.map((d) => d.count));

0 commit comments

Comments
 (0)