/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format */ import {Layout, styled, theme, useValue} from 'flipper-plugin'; import React, {cloneElement, useCallback, useState} from 'react'; import {useStore} from '../utils/useStore'; import config from '../fb-stubs/config'; import {isConnected, currentUser, logoutUser} from '../fb-stubs/user'; import {showLoginDialog} from '../chrome/fb-stubs/SignInSheet'; import {Avatar, Badge, Button, Popover, Tooltip} from 'antd'; import { AppstoreAddOutlined, BellOutlined, CameraOutlined, EllipsisOutlined, FileExclamationOutlined, LayoutOutlined, LoginOutlined, MedicineBoxOutlined, QuestionCircleOutlined, VideoCameraOutlined, WarningOutlined, } from '@ant-design/icons'; export function Navbar() { return ( {config.showLogin && } ); } function NavbarButton({ icon: Icon, label, selected, }: { icon: typeof LoginOutlined; label: string; selected?: boolean; }) { return ( ); } function LoginConnectivityButton() { const loggedIn = useValue(currentUser()); const user = useStore((state) => state.user); const profileUrl = user?.profile_picture?.uri; const [showLogout, setShowLogout] = useState(false); const onHandleVisibleChange = useCallback( (visible) => setShowLogout(visible), [], ); const connected = useValue(isConnected()); if (!connected) { return ( ); } return loggedIn ? ( { onHandleVisibleChange(false); await logoutUser(); }}> Log Out } trigger="click" placement="bottom" visible={showLogout} overlayStyle={{padding: 0}} onVisibleChange={onHandleVisibleChange}> ) : ( <> } title="Log In" onClick={() => showLoginDialog()} /> ); } const LeftRailButtonElem = styled(Button)<{kind?: 'small'}>(({kind}) => ({ width: kind === 'small' ? 32 : 36, height: kind === 'small' ? 32 : 36, border: 'none', boxShadow: 'none', })); LeftRailButtonElem.displayName = 'LeftRailButtonElem'; export function LeftRailButton({ icon, small, selected, toggled, count, title, onClick, disabled, }: { icon?: React.ReactElement; small?: boolean; toggled?: boolean; selected?: boolean; disabled?: boolean; count?: number | true; title?: string; onClick?: React.MouseEventHandler; }) { const iconElement = icon && cloneElement(icon, {style: {fontSize: small ? 16 : 24}}); let res = ( ); if (count !== undefined) { res = count === true ? ( {res} ) : ( {res} ); } if (title) { res = ( {res} ); } return res; }