troubleshoot menu

Reviewed By: lblasa

Differential Revision: D47472474

fbshipit-source-id: 50684055b72067e7ea042da24b6cfc502fe1f85e
This commit is contained in:
Anton Kastritskiy
2023-07-18 03:52:34 -07:00
committed by Facebook GitHub Bot
parent 7c93d92956
commit b1be5d79c8

View File

@@ -32,15 +32,12 @@ import {isConnected, currentUser, logoutUser} from '../fb-stubs/user';
import {showLoginDialog} from '../chrome/fb-stubs/SignInSheet'; import {showLoginDialog} from '../chrome/fb-stubs/SignInSheet';
import {Avatar, Badge, Button, Menu, Modal, Popover, Tooltip} from 'antd'; import {Avatar, Badge, Button, Menu, Modal, Popover, Tooltip} from 'antd';
import { import {
ApiOutlined,
AppstoreAddOutlined, AppstoreAddOutlined,
BellOutlined, BellOutlined,
BugOutlined, BugOutlined,
ExportOutlined, ExportOutlined,
FileExclamationOutlined,
LayoutOutlined, LayoutOutlined,
LoginOutlined, LoginOutlined,
MedicineBoxOutlined,
MobileOutlined, MobileOutlined,
RocketOutlined, RocketOutlined,
SettingOutlined, SettingOutlined,
@@ -50,7 +47,7 @@ import {
toggleLeftSidebarVisible, toggleLeftSidebarVisible,
toggleRightSidebarVisible, toggleRightSidebarVisible,
} from '../reducers/application'; } from '../reducers/application';
import {ToplevelProps} from './SandyApp'; import {ToplevelNavItem, ToplevelProps} from './SandyApp';
import PluginManager from '../chrome/plugin-manager/PluginManager'; import PluginManager from '../chrome/plugin-manager/PluginManager';
import {showEmulatorLauncher} from './appinspect/LaunchEmulator'; import {showEmulatorLauncher} from './appinspect/LaunchEmulator';
import SetupDoctorScreen, {checkHasNewProblem} from './SetupDoctorScreen'; import SetupDoctorScreen, {checkHasNewProblem} from './SetupDoctorScreen';
@@ -113,12 +110,6 @@ export const Navbar = withTrackingScope(function Navbar({
<NavbarScreenshotButton /> <NavbarScreenshotButton />
<NavbarScreenRecordButton /> <NavbarScreenRecordButton />
<LaunchVirtualDeviceButton /> <LaunchVirtualDeviceButton />
{getRenderHostInstance().GK('flipper_connection_troubleshoot') && (
<ConnectionTroubleshootButton
toplevelSelection={toplevelSelection}
setToplevelSelection={setToplevelSelection}
/>
)}
{!isProduction() && ( {!isProduction() && (
<div> <div>
<FpsGraph /> <FpsGraph />
@@ -134,17 +125,12 @@ export const Navbar = withTrackingScope(function Navbar({
Dialog.showModal((onHide) => <PluginManager onHide={onHide} />); Dialog.showModal((onHide) => <PluginManager onHide={onHide} />);
}} }}
/> />
<DebugLogsButton
toplevelSelection={toplevelSelection}
setToplevelSelection={setToplevelSelection}
/>
<NotificationButton <NotificationButton
toplevelSelection={toplevelSelection} toplevelSelection={toplevelSelection}
setToplevelSelection={setToplevelSelection} setToplevelSelection={setToplevelSelection}
/> />
<TroubleshootMenu /> <TroubleshootMenu setToplevelSelection={setToplevelSelection} />
<ExtrasMenu /> <ExtrasMenu />
<SetupDoctorButton />
<ExportEverythingEverywhereAllAtOnceButton /> <ExportEverythingEverywhereAllAtOnceButton />
<RightSidebarToggleButton /> <RightSidebarToggleButton />
{config.showLogin && <LoginConnectivityButton />} {config.showLogin && <LoginConnectivityButton />}
@@ -288,22 +274,6 @@ function ExportEverythingEverywhereAllAtOnceStatusModal({
); );
} }
function ConnectionTroubleshootButton({
toplevelSelection,
setToplevelSelection,
}: ToplevelProps) {
return (
<NavbarButton
icon={ApiOutlined}
label="Troubleshoot"
toggled={toplevelSelection === 'connectivity'}
onClick={() => {
setToplevelSelection('connectivity');
}}
/>
);
}
function NotificationButton({ function NotificationButton({
toplevelSelection, toplevelSelection,
setToplevelSelection, setToplevelSelection,
@@ -380,44 +350,6 @@ function LaunchVirtualDeviceButton() {
); );
} }
function DebugLogsButton({
toplevelSelection,
setToplevelSelection,
}: ToplevelProps) {
const errorCount = useValue(errorCounterAtom);
return (
<NavbarButton
icon={FileExclamationOutlined}
label="Flipper Logs"
toggled={toplevelSelection === 'flipperlogs'}
count={errorCount}
onClick={() => {
setToplevelSelection('flipperlogs');
}}
/>
);
}
function SetupDoctorButton() {
const [visible, setVisible] = useState(false);
const result = useStore(
(state) => state.healthchecks.healthcheckReport.result,
);
const hasNewProblem = useMemo(() => checkHasNewProblem(result), [result]);
const onClose = useCallback(() => setVisible(false), []);
return (
<>
<NavbarButton
icon={MedicineBoxOutlined}
label="Setup Doctor"
count={hasNewProblem ? true : undefined}
onClick={() => setVisible(true)}
/>
<SetupDoctorScreen visible={visible} onClose={onClose} />
</>
);
}
const badgeDotClassname = css` const badgeDotClassname = css`
sup { sup {
right: calc(50% - 14px); right: calc(50% - 14px);
@@ -647,24 +579,64 @@ const submenu = css`
} }
`; `;
function TroubleshootMenu() { function TroubleshootMenu({
setToplevelSelection,
}: {
setToplevelSelection: (x: ToplevelNavItem) => void;
}) {
const [isDoctorVisible, setIsDoctorVisible] = useState(false);
const result = useStore(
(state) => state.healthchecks.healthcheckReport.result,
);
const hasNewProblem = useMemo(() => checkHasNewProblem(result), [result]);
const flipperErrorLogCount = useValue(errorCounterAtom);
const count = flipperErrorLogCount || hasNewProblem || 0;
const badgeProps: Parameters<typeof Badge>[0] =
count === true ? {dot: true, offset: [-8, 8]} : {count, offset: [-6, 5]};
return ( return (
<Menu <>
mode="vertical" {/* using Badge **here** as NavbarButton badge is being cut off by Menu component */}
className={menu} <Badge {...badgeProps}>
selectable={false} <Menu
style={{backgroundColor: theme.backgroundDefault}}> mode="vertical"
<Menu.SubMenu className={menu}
popupOffset={[-90, 50]} selectable={false}
key="extras" style={{backgroundColor: theme.backgroundDefault}}>
title={<NavbarButton icon={BugOutlined} label="Troubleshoot" />} <Menu.SubMenu
className={submenu}> popupOffset={[-90, 50]}
<Menu.Item>TODO troubleshooting guide</Menu.Item> key="troubleshooting"
<Menu.Item>TODO troubleshoot</Menu.Item> title={<NavbarButton icon={BugOutlined} label="Troubleshoot" />}
<Menu.Item>TODO flipper logs</Menu.Item> className={submenu}>
<Menu.Item>TODO setup doctor</Menu.Item> {getRenderHostInstance().GK('flipper_connection_troubleshoot') && (
</Menu.SubMenu> <Menu.Item
</Menu> key="connectivity"
onClick={() => setToplevelSelection('connectivity')}>
Troubleshoot connectivity
</Menu.Item>
)}
<Menu.Item
key="flipperlogs"
onClick={() => setToplevelSelection('flipperlogs')}>
<Badge offset={[12, 0]} count={flipperErrorLogCount}>
Flipper Logs
</Badge>
</Menu.Item>
<Menu.Item
key="setupdoctor"
onClick={() => setIsDoctorVisible(true)}>
<Badge dot={hasNewProblem}>Setup Doctor</Badge>
</Menu.Item>
</Menu.SubMenu>
</Menu>
</Badge>
<SetupDoctorScreen
visible={isDoctorVisible}
onClose={() => setIsDoctorVisible(false)}
/>
</>
); );
} }