Spaces:
Configuration error
Configuration error
Download frontend/src/components/features/sidebar/user-actions.tsx from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/components/features/sidebar/user-actions.tsx
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/src/components/features/sidebar/user-actions.tsx
-
curl -L -o user-actions.tsx https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/components/features/sidebar/user-actions.tsx
1.13 kB
| import React from "react"; | |
| import { UserAvatar } from "./user-avatar"; | |
| import { AccountSettingsContextMenu } from "../context-menu/account-settings-context-menu"; | |
| interface UserActionsProps { | |
| onLogout: () => void; | |
| user?: { avatar_url: string }; | |
| isLoading?: boolean; | |
| } | |
| export function UserActions({ onLogout, user, isLoading }: UserActionsProps) { | |
| const [accountContextMenuIsVisible, setAccountContextMenuIsVisible] = | |
| React.useState(false); | |
| const toggleAccountMenu = () => { | |
| setAccountContextMenuIsVisible((prev) => !prev); | |
| }; | |
| const closeAccountMenu = () => { | |
| setAccountContextMenuIsVisible(false); | |
| }; | |
| const handleLogout = () => { | |
| onLogout(); | |
| closeAccountMenu(); | |
| }; | |
| return ( | |
| <div data-testid="user-actions" className="w-8 h-8 relative"> | |
| <UserAvatar | |
| avatarUrl={user?.avatar_url} | |
| onClick={toggleAccountMenu} | |
| isLoading={isLoading} | |
| /> | |
| {accountContextMenuIsVisible && ( | |
| <AccountSettingsContextMenu | |
| isLoggedIn={!!user} | |
| onLogout={handleLogout} | |
| onClose={closeAccountMenu} | |
| /> | |
| )} | |
| </div> | |
| ); | |
| } | |