From 8ff168283ce5dd3e32893ebd561f4283cf9dfdd0 Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Wed, 14 Dec 2022 23:43:43 -0500 Subject: [PATCH] fsdf --- web/src/components/ActionBar.js | 122 +++++++++++++++++--------------- 1 file changed, 65 insertions(+), 57 deletions(-) diff --git a/web/src/components/ActionBar.js b/web/src/components/ActionBar.js index 651ecf5..87483c2 100644 --- a/web/src/components/ActionBar.js +++ b/web/src/components/ActionBar.js @@ -7,7 +7,7 @@ import Typography from "@mui/material/Typography"; import * as React from "react"; import {useEffect, useRef, useState} from "react"; import Box from "@mui/material/Box"; -import {formatShortDateTime, shuffle, topicDisplayName, topicShortUrl} from "../app/utils"; +import {formatShortDateTime, shuffle, topicDisplayName} from "../app/utils"; import {useLocation, useNavigate} from "react-router-dom"; import ClickAwayListener from '@mui/material/ClickAwayListener'; import Grow from '@mui/material/Grow'; @@ -23,11 +23,14 @@ import routes from "./routes"; import subscriptionManager from "../app/SubscriptionManager"; import logo from "../img/ntfy.svg"; import {useTranslation} from "react-i18next"; -import {Portal, Snackbar} from "@mui/material"; +import {Menu, Portal, Snackbar} from "@mui/material"; import SubscriptionSettingsDialog from "./SubscriptionSettingsDialog"; import session from "../app/Session"; import AccountCircleIcon from '@mui/icons-material/AccountCircle'; import Button from "@mui/material/Button"; +import Divider from "@mui/material/Divider"; +import {Logout, Person, Settings} from "@mui/icons-material"; +import ListItemIcon from "@mui/material/ListItemIcon"; const ActionBar = (props) => { const { t } = useTranslation(); @@ -246,32 +249,15 @@ const SettingsIcons = (props) => { const ProfileIcon = (props) => { const { t } = useTranslation(); - const [open, setOpen] = useState(false); - const anchorRef = useRef(null); + const [anchorEl, setAnchorEl] = useState(null); + const open = Boolean(anchorEl); const navigate = useNavigate(); - const handleToggleOpen = () => { - setOpen((prevOpen) => !prevOpen); + const handleClick = (event) => { + setAnchorEl(event.currentTarget); }; - - const handleClose = (event) => { - if (anchorRef.current && anchorRef.current.contains(event.target)) { - return; - } - setOpen(false); - }; - - const handleListKeyDown = (event) => { - if (event.key === 'Tab') { - event.preventDefault(); - setOpen(false); - } else if (event.key === 'Escape') { - setOpen(false); - } - } - - const handleUpgrade = () => { - // TODO + const handleClose = () => { + setAnchorEl(null); }; const handleLogout = async () => { @@ -280,19 +266,10 @@ const ProfileIcon = (props) => { window.location.href = routes.app; }; - // return focus to the button when we transitioned from !open -> open - const prevOpen = useRef(open); - useEffect(() => { - if (prevOpen.current === true && open === false) { - anchorRef.current.focus(); - } - prevOpen.current = open; - }, [open]); - return ( <> {session.exists() && - + } @@ -302,30 +279,61 @@ const ProfileIcon = (props) => { } - - {({TransitionProps, placement}) => ( - - - - - Upgrade - Logout - - - - - )} - + + + + + {session.username()} + + + + + + + Settings + + + + + + Logout + + ); };