mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 14:47:14 +01:00
Updated nav.
This commit is contained in:
parent
25f96f6b6b
commit
a025fc9552
11 changed files with 971 additions and 1005 deletions
|
|
@ -11,8 +11,8 @@ import {
|
|||
Text,
|
||||
} from '@umami/react-zen';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { User, LogOut, CircleUserRound } from 'lucide-react';
|
||||
import { useMessages, useLoginQuery } from '@/components/hooks';
|
||||
import { LogOut, Settings, UserCircle, LockKeyhole } from '@/components/icons';
|
||||
|
||||
export function ProfileButton() {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
|
|
@ -21,31 +21,34 @@ export function ProfileButton() {
|
|||
const cloudMode = !!process.env.cloudMode;
|
||||
|
||||
const handleSelect = (key: Key) => {
|
||||
if (key === 'profile') {
|
||||
router.push('/settings/profile');
|
||||
}
|
||||
if (key === 'logout') {
|
||||
router.push('/logout');
|
||||
}
|
||||
router.push(`/${key}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<MenuTrigger>
|
||||
<Button data-test="button-profile" variant="quiet">
|
||||
<Icon>
|
||||
<CircleUserRound />
|
||||
<UserCircle />
|
||||
</Icon>
|
||||
</Button>
|
||||
<Popover placement="bottom end">
|
||||
<Menu autoFocus="last" onAction={handleSelect}>
|
||||
<MenuSection title={user.username}>
|
||||
<MenuSeparator />
|
||||
<MenuItem id="profile">
|
||||
<MenuItem id="settings">
|
||||
<Icon>
|
||||
<User />
|
||||
<Settings />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.profile)}</Text>
|
||||
<Text>{formatMessage(labels.settings)}</Text>
|
||||
</MenuItem>
|
||||
{user.isAdmin && (
|
||||
<MenuItem id="admin">
|
||||
<Icon>
|
||||
<LockKeyhole />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.admin)}</Text>
|
||||
</MenuItem>
|
||||
)}
|
||||
{!cloudMode && (
|
||||
<MenuItem data-test="item-logout" id="logout">
|
||||
<Icon>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue