From 1f9ba1d62533dc16b48f6059fa469c0921851398 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:06:56 -0500 Subject: [PATCH] Use MobilePage for camera group editor (#13710) * Use MobilePage for camera group editor * alignment * clear editing group name --- .../components/filter/CameraGroupSelector.tsx | 161 ++++++++++++------ web/src/components/mobile/MobilePage.tsx | 2 +- web/src/views/events/EventView.tsx | 2 +- 3 files changed, 114 insertions(+), 51 deletions(-) diff --git a/web/src/components/filter/CameraGroupSelector.tsx b/web/src/components/filter/CameraGroupSelector.tsx index 6f14b8eb9..fdb01c5ee 100644 --- a/web/src/components/filter/CameraGroupSelector.tsx +++ b/web/src/components/filter/CameraGroupSelector.tsx @@ -7,8 +7,13 @@ import { Button } from "../ui/button"; import { useCallback, useMemo, useState } from "react"; import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; import { LuPencil, LuPlus } from "react-icons/lu"; -import { Dialog, DialogContent, DialogTitle } from "../ui/dialog"; -import { Drawer, DrawerContent } from "../ui/drawer"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from "../ui/dialog"; import { Input } from "../ui/input"; import { Separator } from "../ui/separator"; import { @@ -24,6 +29,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, + DropdownMenuPortal, DropdownMenuTrigger, } from "../ui/dropdown-menu"; import { @@ -53,6 +59,13 @@ import { cn } from "@/lib/utils"; import * as LuIcons from "react-icons/lu"; import IconPicker, { IconName, IconRenderer } from "../icons/IconPicker"; import { isValidIconName } from "@/utils/iconUtil"; +import { + MobilePage, + MobilePageContent, + MobilePageDescription, + MobilePageHeader, + MobilePageTitle, +} from "../mobile/MobilePage"; type CameraGroupSelectorProps = { className?: string; @@ -278,6 +291,7 @@ function NewGroupDialog({ const onSave = () => { setOpen(false); setEditState("none"); + setEditingGroupName(""); }; const onCancel = () => { @@ -290,8 +304,11 @@ function NewGroupDialog({ setEditState("edit"); }, []); - const Overlay = isDesktop ? Dialog : Drawer; - const Content = isDesktop ? DialogContent : DrawerContent; + const Overlay = isDesktop ? Dialog : MobilePage; + const Content = isDesktop ? DialogContent : MobilePageContent; + const Header = isDesktop ? DialogHeader : MobilePageHeader; + const Description = isDesktop ? DialogDescription : MobilePageDescription; + const Title = isDesktop ? DialogTitle : MobilePageTitle; return ( <> @@ -308,16 +325,36 @@ function NewGroupDialog({ }} > -
- {editState === "none" && ( - <> -
- Camera Groups + {editState === "none" && ( + <> +
setOpen(false)} + > + Camera Groups + + Edit camera groups + +
+
+
{currentGroups.map((group) => ( onEditGroup(group)} /> ))} - - )} +
+ + )} - {editState != "none" && ( - <> -
- - {editState == "add" ? "Add" : "Edit"} Camera Group - -
- - - )} -
+ {editState != "none" && ( + <> +
{ + setEditState("none"); + setEditingGroupName(""); + }} + > + + {editState == "add" ? "Add" : "Edit"} Camera Group + + + Edit camera groups + +
+ + + )} @@ -372,6 +420,12 @@ export function EditGroupDialog({ currentGroups, activeGroup, }: EditGroupDialogProps) { + const Overlay = isDesktop ? Dialog : MobilePage; + const Content = isDesktop ? DialogContent : MobilePageContent; + const Header = isDesktop ? DialogHeader : MobilePageHeader; + const Description = isDesktop ? DialogDescription : MobilePageDescription; + const Title = isDesktop ? DialogTitle : MobilePageTitle; + // editing group and state const editingGroup = useMemo(() => { @@ -391,19 +445,24 @@ export function EditGroupDialog({ position="top-center" closeButton={true} /> - { setOpen(open); }} > - -
-
- Edit Camera Group -
+
+
setOpen(false)}> + Edit Camera Group + Edit camera group +
+ setOpen(false)} />
- -
+ + ); } @@ -440,7 +499,7 @@ export function CameraGroupRow({ <>

{group[0]}

@@ -472,12 +531,16 @@ export function CameraGroupRow({ - - Edit - setDeleteDialogOpen(true)}> - Delete - - + + + + Edit + + setDeleteDialogOpen(true)}> + Delete + + + )} @@ -659,7 +722,7 @@ export function CameraGroupEdit({ /> -
+
{filter?.before == undefined && (