Skip to content

Commit 4090a57

Browse files
committed
Switch to not use a fetcher so the page reloads
1 parent dbe89dd commit 4090a57

File tree

2 files changed

+82
-64
lines changed
  • apps/webapp/app
    • components/primitives
    • routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors.$fingerprint

2 files changed

+82
-64
lines changed

apps/webapp/app/components/primitives/Popover.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ const PopoverMenuItem = React.forwardRef<
6666
onClick?: React.MouseEventHandler;
6767
disabled?: boolean;
6868
openInNewTab?: boolean;
69+
name?: string;
70+
value?: string;
71+
type?: React.ComponentProps<"button">["type"];
6972
}
7073
>(
7174
(
@@ -80,6 +83,9 @@ const PopoverMenuItem = React.forwardRef<
8083
onClick,
8184
disabled,
8285
openInNewTab = false,
86+
name,
87+
value,
88+
type,
8389
},
8490
ref
8591
) => {
@@ -114,14 +120,16 @@ const PopoverMenuItem = React.forwardRef<
114120

115121
return (
116122
<button
117-
type="button"
118123
ref={ref as React.Ref<HTMLButtonElement>}
119124
onClick={onClick}
120125
disabled={disabled}
121126
className={cn(
122127
"group/button outline-none focus-custom",
123128
contentProps.fullWidth ? "w-full" : ""
124129
)}
130+
name={name}
131+
value={value}
132+
type={type ?? "button"}
125133
>
126134
<ButtonContent {...contentProps}>{title}</ButtonContent>
127135
</button>
@@ -245,8 +253,7 @@ function PopoverArrowTrigger({
245253

246254
const popoverVerticalEllipseVariants = {
247255
minimal: {
248-
trigger:
249-
"size-6 rounded-[3px] text-text-dimmed hover:bg-tertiary hover:text-text-bright",
256+
trigger: "size-6 rounded-[3px] text-text-dimmed hover:bg-tertiary hover:text-text-bright",
250257
icon: "size-5",
251258
},
252259
secondary: {

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

Lines changed: 72 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type LoaderFunctionArgs, type ActionFunctionArgs, json } from "@remix-run/server-runtime";
2-
import { type MetaFunction, Form, useFetcher } from "@remix-run/react";
2+
import { type MetaFunction, Form, useFetcher, useNavigation, useSubmit } from "@remix-run/react";
33
import { BellAlertIcon } from "@heroicons/react/20/solid";
44
import { parse } from "@conform-to/zod";
55
import { z } from "zod";
@@ -657,75 +657,86 @@ function ErrorGroupActionButtons({
657657
taskIdentifier: string;
658658
fingerprint: string;
659659
}) {
660-
const fetcher = useFetcher();
660+
const navigation = useNavigation();
661+
const submit = useSubmit();
661662
const [customIgnoreOpen, setCustomIgnoreOpen] = useState(false);
662-
const isSubmitting = fetcher.state !== "idle";
663-
664-
const submitAction = (data: Record<string, string>) => {
665-
fetcher.submit({ ...data, taskIdentifier }, { method: "post" });
666-
};
663+
const isSubmitting = navigation.state !== "idle";
667664

668665
return (
669-
<div className="flex items-center gap-2">
670-
<StatusBadge status={state.status} />
666+
<>
667+
<Form className="flex items-center gap-2">
668+
<StatusBadge status={state.status} />
669+
670+
{state.status === "UNRESOLVED" && (
671+
<>
672+
<Button
673+
variant="secondary/small"
674+
disabled={isSubmitting}
675+
onClick={() => submit({ taskIdentifier, action: "resolve" }, { method: "post" })}
676+
type="button"
677+
>
678+
Resolve
679+
</Button>
680+
<Popover>
681+
<PopoverArrowTrigger>Ignore</PopoverArrowTrigger>
682+
<PopoverContent className="min-w-[180px] p-1" align="end">
683+
<PopoverMenuItem
684+
title="Ignore for 1 hour"
685+
onClick={() =>
686+
submit(
687+
{ taskIdentifier, action: "ignore", duration: String(60 * 60 * 1000) },
688+
{ method: "post" }
689+
)
690+
}
691+
/>
692+
<PopoverMenuItem
693+
title="Ignore for 24 hours"
694+
onClick={() =>
695+
submit(
696+
{
697+
taskIdentifier,
698+
action: "ignore",
699+
duration: String(24 * 60 * 60 * 1000),
700+
},
701+
{ method: "post" }
702+
)
703+
}
704+
/>
705+
<PopoverMenuItem
706+
title="Ignore forever"
707+
onClick={() => submit({ taskIdentifier, action: "ignore" }, { method: "post" })}
708+
/>
709+
<PopoverMenuItem
710+
title="Custom condition..."
711+
onClick={() => setCustomIgnoreOpen(true)}
712+
/>
713+
</PopoverContent>
714+
</Popover>
715+
</>
716+
)}
671717

672-
{state.status === "UNRESOLVED" && (
673-
<>
718+
{state.status === "RESOLVED" && (
674719
<Button
675720
variant="secondary/small"
676721
disabled={isSubmitting}
677-
onClick={() => submitAction({ action: "resolve" })}
722+
onClick={() => submit({ taskIdentifier, action: "unresolve" }, { method: "post" })}
723+
type="button"
678724
>
679-
Resolve
725+
Unresolve
680726
</Button>
681-
<Popover>
682-
<PopoverArrowTrigger>Ignore</PopoverArrowTrigger>
683-
<PopoverContent className="min-w-[180px] p-1" align="end">
684-
<PopoverMenuItem
685-
title="Ignore for 1 hour"
686-
onClick={() => submitAction({ action: "ignore", duration: String(60 * 60 * 1000) })}
687-
/>
688-
<PopoverMenuItem
689-
title="Ignore for 24 hours"
690-
onClick={() =>
691-
submitAction({
692-
action: "ignore",
693-
duration: String(24 * 60 * 60 * 1000),
694-
})
695-
}
696-
/>
697-
<PopoverMenuItem
698-
title="Ignore forever"
699-
onClick={() => submitAction({ action: "ignore" })}
700-
/>
701-
<PopoverMenuItem
702-
title="Custom condition..."
703-
onClick={() => setCustomIgnoreOpen(true)}
704-
/>
705-
</PopoverContent>
706-
</Popover>
707-
</>
708-
)}
709-
710-
{state.status === "RESOLVED" && (
711-
<Button
712-
variant="secondary/small"
713-
disabled={isSubmitting}
714-
onClick={() => submitAction({ action: "unresolve" })}
715-
>
716-
Unresolve
717-
</Button>
718-
)}
727+
)}
719728

720-
{state.status === "IGNORED" && (
721-
<Button
722-
variant="secondary/small"
723-
disabled={isSubmitting}
724-
onClick={() => submitAction({ action: "unresolve" })}
725-
>
726-
Unignore
727-
</Button>
728-
)}
729+
{state.status === "IGNORED" && (
730+
<Button
731+
variant="secondary/small"
732+
disabled={isSubmitting}
733+
onClick={() => submit({ taskIdentifier, action: "unresolve" }, { method: "post" })}
734+
type="button"
735+
>
736+
Unignore
737+
</Button>
738+
)}
739+
</Form>
729740

730741
<Dialog open={customIgnoreOpen} onOpenChange={setCustomIgnoreOpen}>
731742
<DialogContent>
@@ -738,7 +749,7 @@ function ErrorGroupActionButtons({
738749
/>
739750
</DialogContent>
740751
</Dialog>
741-
</div>
752+
</>
742753
);
743754
}
744755

0 commit comments

Comments
 (0)