Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

feat(notifications): confirm before deleting a notification or clearing read ones on the notifications page; note it in the automations help page

Khuram Niaze8c8e0da692e
diff --git a/__tests__/NotificationsContainer.spec.tsx b/__tests__/NotificationsContainer.spec.tsx
index 9583954..0f8dff7 100644
--- a/__tests__/NotificationsContainer.spec.tsx
+++ b/__tests__/NotificationsContainer.spec.tsx
@@ -56,6 +56,8 @@ const automations = [{ id: "a-1", name: "Remote Frontend" }, { id: "a-2", name:
const renderPage = (init = initial) =>
render(<NotificationsContainer initial={init} automations={automations} />);
+const confirmDelete = () =>
+ userEvent.click(within(screen.getByRole("alertdialog")).getByRole("button", { name: "Delete" }));
beforeEach(() => {
vi.clearAllMocks();
@@ -89,18 +91,29 @@ it("row × deletes the row, not dismisses it", async () => {
renderPage();
const row = screen.getByText("Remote Frontend", { selector: "li span" }).closest("li")!;
await userEvent.click(within(row).getByRole("button", { name: /delete notification/i }));
+ await confirmDelete();
expect(actions.deleteNotification).toHaveBeenCalledWith("r1");
expect(actions.dismissNotification).not.toHaveBeenCalled();
expect(screen.queryByText("Remote Frontend", { selector: "li span" })).toBeNull();
expect(refresh).toHaveBeenCalled();
});
+it("cancelling the confirmation keeps the row", async () => {
+ renderPage();
+ const row = screen.getByText("Remote Frontend", { selector: "li span" }).closest("li")!;
+ await userEvent.click(within(row).getByRole("button", { name: /delete notification/i }));
+ await userEvent.click(within(screen.getByRole("alertdialog")).getByRole("button", { name: "Cancel" }));
+ expect(actions.deleteNotification).not.toHaveBeenCalled();
+ expect(screen.getByText("Remote Frontend", { selector: "li span" })).toBeInTheDocument();
+});
+
it("Clear read deletes read rows from the list", async () => {
(actions.getNotificationList as any).mockResolvedValue({
success: true, data: { items: [run], total: 1, counts: { all: 1, unread: 1, errors: 0, runs: 1 } },
});
renderPage();
await userEvent.click(screen.getByRole("button", { name: /clear read/i }));
+ await confirmDelete();
expect(actions.clearReadNotifications).toHaveBeenCalled();
expect(await screen.findByRole("tab", { name: /All\s*1/ })).toBeInTheDocument();
expect(screen.queryByText("Backend EU", { selector: "li span" })).toBeNull();
@@ -165,6 +178,7 @@ it("a failed delete shows an error and restores the row", async () => {
renderPage();
const row = screen.getByText("Remote Frontend", { selector: "li span" }).closest("li")!;
await userEvent.click(within(row).getByRole("button", { name: /delete notification/i }));
+ await confirmDelete();
expect(toastError).toHaveBeenCalledWith("Not authenticated");
expect(await screen.findByText("Remote Frontend", { selector: "li span" })).toBeInTheDocument();
});
@@ -181,6 +195,7 @@ it("a failed clear read shows an error", async () => {
(actions.clearReadNotifications as any).mockResolvedValueOnce({ success: false, message: "Busy" });
renderPage();
await userEvent.click(screen.getByRole("button", { name: /clear read/i }));
+ await confirmDelete();
expect(toastError).toHaveBeenCalledWith("Busy");
expect(screen.getByText("Backend EU", { selector: "li span" })).toBeInTheDocument();
});
diff --git a/src/components/notifications/NotificationsContainer.tsx b/src/components/notifications/NotificationsContainer.tsx
index fdc9bcd..81e53a7 100644
--- a/src/components/notifications/NotificationsContainer.tsx
+++ b/src/components/notifications/NotificationsContainer.tsx
@@ -12,6 +12,7 @@ import {
SelectValue,
} from "@/components/ui/select";
import { ResponsiveCardHeader } from "@/components/ResponsiveCardHeader";
+import { DeleteAlertDialog } from "@/components/DeleteAlertDialog";
import { cn } from "@/lib/utils";
import { toastError } from "@/lib/toast";
import { useTabQueryParam } from "@/hooks/useTabQueryParam";
@@ -28,6 +29,7 @@ import { NotificationRow } from "./NotificationRow";
import { groupByDay, isErrorNotification } from "./notificationDisplay";
type Counts = Record<NotificationTab, number>;
+type PendingDelete = { kind: "clear" } | { kind: "delete"; id: string };
interface NotificationsContainerProps {
initial: { items: NotificationItem[]; total: number; counts: Counts };
@@ -52,6 +54,7 @@ export function NotificationsContainer({ initial, automations }: NotificationsCo
const [total, setTotal] = useState(initial.total);
const [counts, setCounts] = useState(initial.counts);
const [loading, setLoading] = useState(false);
+ const [pending, setPending] = useState<PendingDelete | null>(null);
// Drops a response that a newer tab or filter pick has overtaken.
const requestId = useRef(0);
@@ -136,6 +139,12 @@ export function NotificationsContainer({ initial, automations }: NotificationsCo
await query(tab, automationId, 0);
};
+ const onConfirmDelete = () => {
+ if (pending?.kind === "clear") onClearRead();
+ else if (pending?.kind === "delete") onRemove(pending.id);
+ setPending(null);
+ };
+
const groups = groupByDay(items);
return (
@@ -152,7 +161,7 @@ export function NotificationsContainer({ initial, automations }: NotificationsCo
<CheckCheck className="h-4 w-4" />
Mark all read
</Button>
- <Button variant="ghost" size="sm" className="gap-1.5" onClick={onClearRead}>
+ <Button variant="ghost" size="sm" className="gap-1.5" onClick={() => setPending({ kind: "clear" })}>
<Trash2 className="h-4 w-4" />
Clear read
</Button>
@@ -226,7 +235,7 @@ export function NotificationsContainer({ initial, automations }: NotificationsCo
key={item.id}
item={item}
variant="page"
- onRemove={onRemove}
+ onRemove={(id) => setPending({ kind: "delete", id })}
onOpenLink={onOpenLink}
/>
))}
@@ -252,6 +261,20 @@ export function NotificationsContainer({ initial, automations }: NotificationsCo
Notifications older than 30 days are removed automatically.
</p>
</CardContent>
+ <DeleteAlertDialog
+ pageTitle="notification"
+ open={pending !== null}
+ onOpenChange={(open) => !open && setPending(null)}
+ onDelete={onConfirmDelete}
+ alertTitle={
+ pending?.kind === "clear" ? "Delete all read notifications?" : "Delete this notification?"
+ }
+ alertDescription={
+ pending?.kind === "clear"
+ ? "Every read notification is deleted, including ones not loaded on this page. This cannot be undone."
+ : "This notification is deleted for good. This cannot be undone."
+ }
+ />
</Card>
);
}
diff --git a/wiki/automations.md b/wiki/automations.md
index e32ec23..0ffb99f 100644
--- a/wiki/automations.md
+++ b/wiki/automations.md
@@ -108,4 +108,4 @@ The bell in the header tells you: it shows a count of unread notifications, red
Every finished run posts a summary of what it found, with a link to any new jobs; cancelled runs post nothing. A company board that could not be reached (removed, timed out or rate-limited) gets its own row, which comes back after each run until you fix it — **Edit watchlist** opens the automation's editor. If every board fails, the run is marked failed.
-The **×** in the bell only hides a row; the Notifications page (**View all notifications**, or the account menu) still lists it. On the page, **×** and **Clear read** delete for good. Notifications are kept for 30 days.
+The **×** in the bell only hides a row; the Notifications page (**View all notifications**, or the account menu) still lists it. On the page, **×** and **Clear read** delete for good, after asking you to confirm. Notifications are kept for 30 days.