forked from Github/frigate
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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user