diff --git a/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx b/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx index 65e3d835b..243da5d2b 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx @@ -8,27 +8,16 @@ */ import React, {cloneElement, useState, useCallback, useMemo} from 'react'; -import { - Button, - Divider, - Badge, - Tooltip, - Avatar, - Popover, - Menu, - Modal, -} from 'antd'; +import {Button, Divider, Badge, Tooltip, Menu, Modal} from 'antd'; import { MobileFilled, AppstoreOutlined, BellOutlined, FileExclamationOutlined, - LoginOutlined, SettingOutlined, MedicineBoxOutlined, RocketOutlined, BugOutlined, - WarningOutlined, ApiOutlined, } from '@ant-design/icons'; import {SidebarLeft, SidebarRight} from './SandyIcons'; @@ -63,7 +52,6 @@ import NetworkGraph from '../chrome/NetworkGraph'; import FpsGraph from '../chrome/FpsGraph'; import UpdateIndicator from '../chrome/UpdateIndicator'; import PluginManager from '../chrome/plugin-manager/PluginManager'; -import {showLoginDialog} from '../chrome/fb-stubs/SignInSheet'; import constants from '../fb-stubs/constants'; import { canFileExport, @@ -79,7 +67,6 @@ import {css} from '@emotion/css'; import {getRenderHostInstance} from 'flipper-frontend-core'; import {StyleGuide} from './StyleGuide'; import {useEffect} from 'react'; -import {isConnected, currentUser, logoutUser} from '../fb-stubs/user'; const LeftRailButtonElem = styled(Button)<{kind?: 'small'}>(({kind}) => ({ width: kind === 'small' ? 32 : 36, @@ -217,7 +204,6 @@ export const LeftRail = withTrackingScope(function LeftRail({ - {config.showLogin && } @@ -614,62 +600,3 @@ function SetupDoctorButton() { ); } - -function LoginConnectivityButton() { - const dispatch = useDispatch(); - 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="right" - visible={showLogout} - overlayStyle={{padding: 0}} - onVisibleChange={onHandleVisibleChange}> - - - - - ) : ( - <> - } - title="Log In" - onClick={() => showLoginDialog()} - /> - - ); -} diff --git a/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx b/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx index 672f9ecd8..4b18d6532 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx @@ -7,8 +7,14 @@ * @format */ -import {Layout, theme} from 'flipper-plugin'; -import React from 'react'; +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 {LoginOutlined, WarningOutlined} from '@ant-design/icons'; export function Navbar() { return ( @@ -34,7 +40,135 @@ export function Navbar() { + {config.showLogin && } ); } + +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; +}