// Copyright 2024, Command Line Inc. // SPDX-License-Identifier: Apache-2.0 import { Button } from "@/element/button"; import { Popover, PopoverButton, PopoverContent } from "@/element/popover"; import { atoms } from "@/store/global"; import { makeIconClass } from "@/util/util"; import clsx from "clsx"; import { useAtom } from "jotai"; import { OverlayScrollbarsComponent } from "overlayscrollbars-react"; import { Fragment, useCallback } from "react"; import { NotificationItem } from "./notificationitem"; import { useUpdateNotifier } from "./updatenotifier"; import { useNotification } from "./usenotification"; import "./notificationpopover.less"; const NotificationPopover = () => { useUpdateNotifier(); const { notifications, removeNotification, removeAllNotifications, hideAllNotifications, copyNotification, handleActionClick, formatTimestamp, hoveredId, setHoveredId, } = useNotification(); const [notificationPopoverMode, setNotificationPopoverMode] = useAtom(atoms.notificationPopoverMode); const handleTogglePopover = useCallback(() => { if (notificationPopoverMode) { hideAllNotifications(); } setNotificationPopoverMode(!notificationPopoverMode); }, [notificationPopoverMode]); const hasErrors = notifications.some((n) => n.type === "error"); const hasUpdate = notifications.some((n) => n.type === "update"); const addOnClassNames = hasUpdate ? "solid green" : hasErrors ? "solid red" : "ghost grey"; const getIcon = () => { if (hasUpdate) { return ; } return ; }; return ( {getIcon()} {notifications.length > 0 && (
Notifications
{notifications.map((notif, index) => ( setHoveredId(notif.id)} onMouseLeave={() => setHoveredId(null)} /> {index !== notifications.length - 1 &&
}
))}
)}
); }; export { NotificationPopover };