Replace sonner toasts with one top-centre notification stack

The app said things in two places: sonner's bottom-right toasts and the
custom top-centre chrome. This is the second of those, generalised — a
module-level store anyone can call, drawn as a stack of frosted cards that go
on their own unless raised as persistent, with room for buttons and for a
message longer than a line.

useCustomToast keeps its signatures, so the forty-odd call sites behind it and
handleError are untouched. The component and its store are byte-identical with
the portal's copy and checked by `make design-check`.
This commit is contained in:
2026-08-27 16:00:47 +02:00
parent c1410f6a0b
commit 8ef78678a0
7 changed files with 249 additions and 60 deletions
+5 -5
View File
@@ -8,13 +8,13 @@ import { createRouter, RouterProvider } from "@tanstack/react-router"
import { MotionConfig } from "motion/react"
import { StrictMode } from "react"
import ReactDOM from "react-dom/client"
import { toast } from "sonner"
import { ApiError, OpenAPI } from "./client"
import { PageLoading } from "./components/Common/Loading"
import { Notifications } from "./components/Common/Notifications"
import { ThemeProvider } from "./components/theme-provider"
import { Toaster } from "./components/ui/sonner"
import "./index.css"
import { connectionStore, offlineDetail } from "./lib/connectionStore"
import { notify } from "./lib/notificationStore"
import { apiToken, appPath, appRoute, portalConfig } from "./lib/portal"
import { routeTree } from "./routeTree.gen"
@@ -74,10 +74,10 @@ const handleApiError = (error: Error) => {
}
if (isForbidden(error) && !appRoute().startsWith("/panel")) {
// The session stands, so stay put — but a refused change that says nothing
// reads as a broken button. On a panel there is nobody to read a toast: a
// reads as a broken button. On a panel there is nobody there to read it: a
// 403 there is a dashboard it was just unassigned from, which its next read
// of the panel corrects on its own.
toast.error("You do not have permission to do that")
notify("You do not have permission to do that", "error")
}
}
@@ -121,7 +121,7 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
<MotionConfig reducedMotion="user">
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} />
<Toaster richColors closeButton />
<Notifications />
</QueryClientProvider>
</MotionConfig>
</ThemeProvider>