Link to relevant page from status bar warnings / errors (#11140)

* Use hash state for system pages

* Add links to items

* Add stats to other types

* Link on mobile as well

* Use link

* Cleanup using util
This commit is contained in:
Nicolas Mowen
2024-04-28 16:59:03 -06:00
committed by GitHub
parent c2c6113299
commit acf37f9920
7 changed files with 79 additions and 24 deletions

View File

@@ -13,6 +13,7 @@ import {
StatusBarMessagesContext,
StatusMessage,
} from "@/context/statusbar-provider";
import { Link } from "react-router-dom";
function Bottombar() {
const navItems = useNavigation("secondary");
@@ -51,7 +52,13 @@ function StatusAlertNav() {
useEffect(() => {
clearMessages("stats");
potentialProblems.forEach((problem) => {
addMessage("stats", problem.text, problem.color);
addMessage(
"stats",
problem.text,
problem.color,
undefined,
problem.relevantLink,
);
});
}, [potentialProblems, addMessage, clearMessages]);
@@ -68,14 +75,22 @@ function StatusAlertNav() {
<div className="w-full h-auto py-4 overflow-y-auto overflow-x-hidden flex flex-col items-center gap-2">
{Object.entries(messages).map(([key, messageArray]) => (
<div key={key} className="w-full flex items-center gap-2">
{messageArray.map(({ id, text, color }: StatusMessage) => (
<div key={id} className="flex items-center text-xs gap-2">
<IoIosWarning
className={`size-5 ${color || "text-danger"}`}
/>
{text}
</div>
))}
{messageArray.map(({ id, text, color, link }: StatusMessage) => {
const message = (
<div key={id} className="flex items-center text-xs gap-2">
<IoIosWarning
className={`size-5 ${color || "text-danger"}`}
/>
{text}
</div>
);
if (link) {
return <Link to={link}>{message}</Link>;
} else {
return message;
}
})}
</div>
))}
</div>