Misc UI fixes (#11237)

* add close button to all toasters

* check if persistent options are loaded

* add id to prevent message duplication in bottom bar
This commit is contained in:
Josh Hawkins 2024-05-04 14:54:50 -05:00 committed by GitHub
parent 2dd5b893a0
commit ad87f5786e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 45 additions and 26 deletions

View File

@ -273,7 +273,11 @@ function NewGroupDialog({
return ( return (
<> <>
<Toaster className="toaster group z-[100]" position="top-center" /> <Toaster
className="toaster group z-[100]"
position="top-center"
closeButton={true}
/>
<Overlay <Overlay
open={open} open={open}
onOpenChange={(open) => { onOpenChange={(open) => {

View File

@ -178,7 +178,12 @@ export default function MasksAndZones({
setAllPolygons([...(editingPolygons ?? [])]); setAllPolygons([...(editingPolygons ?? [])]);
setHoveredPolygonIndex(null); setHoveredPolygonIndex(null);
setUnsavedChanges(false); setUnsavedChanges(false);
addMessage("masks_zones", "Restart required (masks/zones changed)"); addMessage(
"masks_zones",
"Restart required (masks/zones changed)",
undefined,
"masks_zones",
);
}, [editingPolygons, setUnsavedChanges, addMessage]); }, [editingPolygons, setUnsavedChanges, addMessage]);
useEffect(() => { useEffect(() => {
@ -366,7 +371,7 @@ export default function MasksAndZones({
<> <>
{cameraConfig && editingPolygons && ( {cameraConfig && editingPolygons && (
<div className="flex flex-col md:flex-row size-full"> <div className="flex flex-col md:flex-row size-full">
<Toaster position="top-center" /> <Toaster position="top-center" closeButton={true} />
<div className="flex flex-col h-full w-full overflow-y-auto mt-2 md:mt-0 mb-10 md:mb-0 md:w-3/12 order-last md:order-none md:mr-2 rounded-lg border-secondary-foreground border-[1px] p-2 bg-background_alt"> <div className="flex flex-col h-full w-full overflow-y-auto mt-2 md:mt-0 mb-10 md:mb-0 md:w-3/12 order-last md:order-none md:mr-2 rounded-lg border-secondary-foreground border-[1px] p-2 bg-background_alt">
{editPane == "zone" && ( {editPane == "zone" && (
<ZoneEditPane <ZoneEditPane

View File

@ -183,7 +183,7 @@ export default function MotionMaskEditPane({
return ( return (
<> <>
<Toaster position="top-center" /> <Toaster position="top-center" closeButton={true} />
<Heading as="h3" className="my-2"> <Heading as="h3" className="my-2">
{polygon.name.length ? "Edit" : "New"} Motion Mask {polygon.name.length ? "Edit" : "New"} Motion Mask
</Heading> </Heading>

View File

@ -153,7 +153,12 @@ export default function MotionTuner({
useEffect(() => { useEffect(() => {
if (changedValue) { if (changedValue) {
addMessage("motion_tuner", "Unsaved motion tuner changes"); addMessage(
"motion_tuner",
"Unsaved motion tuner changes",
undefined,
"motion_tuner",
);
} else { } else {
clearMessages("motion_tuner"); clearMessages("motion_tuner");
} }
@ -169,7 +174,7 @@ export default function MotionTuner({
return ( return (
<div className="flex flex-col md:flex-row size-full"> <div className="flex flex-col md:flex-row size-full">
<Toaster position="top-center" /> <Toaster position="top-center" closeButton={true} />
<div className="flex flex-col h-full w-full overflow-y-auto mt-2 md:mt-0 mb-10 md:mb-0 md:w-3/12 order-last md:order-none md:mr-2 rounded-lg border-secondary-foreground border-[1px] p-2 bg-background_alt"> <div className="flex flex-col h-full w-full overflow-y-auto mt-2 md:mt-0 mb-10 md:mb-0 md:w-3/12 order-last md:order-none md:mr-2 rounded-lg border-secondary-foreground border-[1px] p-2 bg-background_alt">
<Heading as="h3" className="my-2"> <Heading as="h3" className="my-2">
Motion Detection Tuner Motion Detection Tuner

View File

@ -245,7 +245,7 @@ export default function ObjectMaskEditPane({
return ( return (
<> <>
<Toaster position="top-center" /> <Toaster position="top-center" closeButton={true} />
<Heading as="h3" className="my-2"> <Heading as="h3" className="my-2">
{polygon.name.length ? "Edit" : "New"} Object Mask {polygon.name.length ? "Edit" : "New"} Object Mask
</Heading> </Heading>

View File

@ -64,7 +64,7 @@ export default function ObjectSettings({
}, },
]; ];
const [options, setOptions] = usePersistence<Options>( const [options, setOptions, optionsLoaded] = usePersistence<Options>(
`${selectedCamera}-feed`, `${selectedCamera}-feed`,
emptyObject, emptyObject,
); );
@ -87,17 +87,20 @@ export default function ObjectSettings({
const memoizedObjects = useDeepMemo(objects); const memoizedObjects = useDeepMemo(objects);
const searchParams = useMemo( const searchParams = useMemo(() => {
() => if (!optionsLoaded) {
new URLSearchParams( return new URLSearchParams();
}
const params = new URLSearchParams(
Object.keys(options || {}).reduce((memo, key) => { Object.keys(options || {}).reduce((memo, key) => {
//@ts-expect-error we know this is correct //@ts-expect-error we know this is correct
memo.push([key, options[key] === true ? "1" : "0"]); memo.push([key, options[key] === true ? "1" : "0"]);
return memo; return memo;
}, []), }, []),
),
[options],
); );
return params;
}, [options, optionsLoaded]);
useEffect(() => { useEffect(() => {
document.title = "Object Settings - Frigate"; document.title = "Object Settings - Frigate";
@ -109,7 +112,7 @@ export default function ObjectSettings({
return ( return (
<div className="flex flex-col md:flex-row size-full"> <div className="flex flex-col md:flex-row size-full">
<Toaster position="top-center" /> <Toaster position="top-center" closeButton={true} />
<div className="flex flex-col h-full w-full overflow-y-auto mt-2 md:mt-0 mb-10 md:mb-0 md:w-3/12 order-last md:order-none md:mr-2 rounded-lg border-secondary-foreground border-[1px] p-2 bg-background_alt"> <div className="flex flex-col h-full w-full overflow-y-auto mt-2 md:mt-0 mb-10 md:mb-0 md:w-3/12 order-last md:order-none md:mr-2 rounded-lg border-secondary-foreground border-[1px] p-2 bg-background_alt">
<Heading as="h3" className="my-2"> <Heading as="h3" className="my-2">
Debug Debug

View File

@ -202,7 +202,7 @@ export default function PolygonItem({
return ( return (
<> <>
<Toaster position="top-center" /> <Toaster position="top-center" closeButton={true} />
<div <div
key={index} key={index}

View File

@ -318,7 +318,7 @@ export default function ZoneEditPane({
return ( return (
<> <>
<Toaster position="top-center" /> <Toaster position="top-center" closeButton={true} />
<Heading as="h3" className="my-2"> <Heading as="h3" className="my-2">
{polygon.name.length ? "Edit" : "New"} Zone {polygon.name.length ? "Edit" : "New"} Zone
</Heading> </Heading>

View File

@ -18,6 +18,8 @@ const Toaster = ({ ...props }: ToasterProps) => {
actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary", actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary",
cancelButton: cancelButton:
"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground", "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
closeButton:
"group-[.toast]:bg-secondary border-primary border-[1px]",
success: success:
"group toast group-[.toaster]:bg-success group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg", "group toast group-[.toaster]:bg-success group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
error: error:

View File

@ -158,7 +158,7 @@ function ConfigEditor() {
)} )}
<div ref={configRef} className="h-full mt-2" /> <div ref={configRef} className="h-full mt-2" />
<Toaster /> <Toaster closeButton={true} />
</div> </div>
); );
} }

View File

@ -332,7 +332,7 @@ function Logs() {
return ( return (
<div className="size-full p-2 flex flex-col"> <div className="size-full p-2 flex flex-col">
<Toaster position="top-center" /> <Toaster position="top-center" closeButton={true} />
<LogInfoDialog logLine={selectedLog} setLogLine={setSelectedLog} /> <LogInfoDialog logLine={selectedLog} setLogLine={setSelectedLog} />
<div className="flex justify-between items-center"> <div className="flex justify-between items-center">

View File

@ -238,7 +238,7 @@ export default function EventView({
return ( return (
<div className="py-2 flex flex-col size-full"> <div className="py-2 flex flex-col size-full">
<Toaster /> <Toaster closeButton={true} />
<div className="h-11 mb-2 pl-3 pr-2 relative flex justify-between items-center"> <div className="h-11 mb-2 pl-3 pr-2 relative flex justify-between items-center">
{isMobile && ( {isMobile && (
<Logo className="absolute inset-x-1/2 -translate-x-1/2 h-8" /> <Logo className="absolute inset-x-1/2 -translate-x-1/2 h-8" />

View File

@ -261,7 +261,7 @@ export function RecordingView({
return ( return (
<div ref={contentRef} className="size-full pt-2 flex flex-col"> <div ref={contentRef} className="size-full pt-2 flex flex-col">
<Toaster /> <Toaster closeButton={true} />
<div <div
className={`w-full h-11 mb-2 px-2 relative flex items-center justify-between`} className={`w-full h-11 mb-2 px-2 relative flex items-center justify-between`}
> >