diff --git a/web/src/components/filter/LogLevelFilter.tsx b/web/src/components/filter/LogLevelFilter.tsx new file mode 100644 index 000000000..4eb19d350 --- /dev/null +++ b/web/src/components/filter/LogLevelFilter.tsx @@ -0,0 +1,126 @@ +import { Button } from "../ui/button"; +import { FaFilter } from "react-icons/fa"; +import { isMobile } from "react-device-detect"; +import { Drawer, DrawerContent, DrawerTrigger } from "../ui/drawer"; +import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"; +import { LogSeverity } from "@/types/log"; +import { Label } from "../ui/label"; +import { Switch } from "../ui/switch"; +import { DropdownMenuSeparator } from "../ui/dropdown-menu"; + +type LogLevelFilterButtonProps = { + selectedLabels?: LogSeverity[]; + updateLabelFilter: (labels: LogSeverity[] | undefined) => void; +}; +export function LogLevelFilterButton({ + selectedLabels, + updateLabelFilter, +}: LogLevelFilterButtonProps) { + const trigger = ( + + ); + const content = ( + + ); + + if (isMobile) { + return ( + + {trigger} + + {content} + + + ); + } + + return ( + + {trigger} + {content} + + ); +} + +type GeneralFilterContentProps = { + selectedLabels: LogSeverity[] | undefined; + updateLabelFilter: (labels: LogSeverity[] | undefined) => void; +}; +export function GeneralFilterContent({ + selectedLabels, + updateLabelFilter, +}: GeneralFilterContentProps) { + return ( + <> +
+
+ + { + if (isChecked) { + updateLabelFilter(undefined); + } + }} + /> +
+ +
+ {["debug", "info", "warning", "error"].map((item) => ( +
+ + { + if (isChecked) { + const updatedLabels = selectedLabels + ? [...selectedLabels] + : []; + + updatedLabels.push(item as LogSeverity); + updateLabelFilter(updatedLabels); + } else { + const updatedLabels = selectedLabels + ? [...selectedLabels] + : []; + + // can not deselect the last item + if (updatedLabels.length > 1) { + updatedLabels.splice( + updatedLabels.indexOf(item as LogSeverity), + 1, + ); + updateLabelFilter(updatedLabels); + } + } + }} + /> +
+ ))} +
+
+ + + ); +} diff --git a/web/src/components/filter/ReviewFilterGroup.tsx b/web/src/components/filter/ReviewFilterGroup.tsx index a3c3fadbc..91e390847 100644 --- a/web/src/components/filter/ReviewFilterGroup.tsx +++ b/web/src/components/filter/ReviewFilterGroup.tsx @@ -567,7 +567,7 @@ export function GeneralFilterContent({ {allLabels.map((item) => (