Move framework event monitoring out of options

Summary: An more options page drop down of size one didnt really make a great deal of sense

Reviewed By: lblasa

Differential Revision: D47520034

fbshipit-source-id: cea7ac404f73a0d7e5a1541b16097c4fd6549215
This commit is contained in:
Luke De Feo
2023-07-19 08:58:20 -07:00
committed by Facebook GitHub Bot
parent 3282417663
commit 16480a95f3

View File

@@ -14,15 +14,13 @@ import {
Input, Input,
Modal, Modal,
Tooltip, Tooltip,
Dropdown,
Menu,
Typography, Typography,
TreeSelect, TreeSelect,
Space, Space,
Switch, Switch,
} from 'antd'; } from 'antd';
import { import {
MoreOutlined, EyeOutlined,
PauseCircleOutlined, PauseCircleOutlined,
PlayCircleOutlined, PlayCircleOutlined,
SearchOutlined, SearchOutlined,
@@ -48,6 +46,9 @@ export const Controls: React.FC = () => {
instance.uiState.frameworkEventMonitoring, instance.uiState.frameworkEventMonitoring,
); );
const [showFrameworkEventsModal, setShowFrameworkEventsModal] =
useState(false);
const onSetEventMonitored: ( const onSetEventMonitored: (
eventType: FrameworkEventType, eventType: FrameworkEventType,
monitored: boolean, monitored: boolean,
@@ -83,72 +84,33 @@ export const Controls: React.FC = () => {
{isPaused ? <PlayCircleOutlined /> : <PauseCircleOutlined />} {isPaused ? <PlayCircleOutlined /> : <PauseCircleOutlined />}
</Tooltip> </Tooltip>
}></Button> }></Button>
<Button
type="default"
shape="circle"
onClick={() => {
setShowFrameworkEventsModal(true);
}}
icon={
<Tooltip title="Framework event monitoring">
<EyeOutlined />
</Tooltip>
}></Button>
{frameworkEventMonitoring.size > 0 && ( {frameworkEventMonitoring.size > 0 && (
<MoreOptionsMenu <FrameworkEventsMonitoringModal
filterMainThreadMonitoring={filterMainThreadMonitoring} filterMainThreadMonitoring={filterMainThreadMonitoring}
onSetFilterMainThreadMonitoring={ onSetFilterMainThreadMonitoring={
instance.uiActions.onSetFilterMainThreadMonitoring instance.uiActions.onSetFilterMainThreadMonitoring
} }
onSetEventMonitored={onSetEventMonitored}
frameworkEventTypes={[...frameworkEventMonitoring.entries()]} frameworkEventTypes={[...frameworkEventMonitoring.entries()]}
onSetEventMonitored={onSetEventMonitored}
visible={showFrameworkEventsModal}
onCancel={() => setShowFrameworkEventsModal(false)}
/> />
)} )}
</Layout.Horizontal> </Layout.Horizontal>
); );
}; };
function MoreOptionsMenu({
onSetEventMonitored,
frameworkEventTypes,
filterMainThreadMonitoring,
onSetFilterMainThreadMonitoring,
}: {
filterMainThreadMonitoring: boolean;
onSetFilterMainThreadMonitoring: (toggled: boolean) => void;
onSetEventMonitored: (
eventType: FrameworkEventType,
monitored: boolean,
) => void;
frameworkEventTypes: [FrameworkEventType, boolean][];
}) {
const [showFrameworkEventsModal, setShowFrameworkEventsModal] =
useState(false);
const moreOptionsMenu = (
<Menu>
<Menu.Item
onClick={() => {
tracker.track('more-options-opened', {});
setShowFrameworkEventsModal(true);
}}>
Framework event monitoring
</Menu.Item>
</Menu>
);
return (
<>
<Dropdown
key="more"
mouseLeaveDelay={0.7}
overlay={moreOptionsMenu}
placement="bottomRight">
<Button type="text" icon={<MoreOutlined style={{fontSize: 20}} />} />
</Dropdown>
{/*invisible until shown*/}
<FrameworkEventsMonitoringModal
filterMainThreadMonitoring={filterMainThreadMonitoring}
onSetFilterMainThreadMonitoring={onSetFilterMainThreadMonitoring}
frameworkEventTypes={frameworkEventTypes}
onSetEventMonitored={onSetEventMonitored}
visible={showFrameworkEventsModal}
onCancel={() => setShowFrameworkEventsModal(false)}
/>
</>
);
}
function FrameworkEventsMonitoringModal({ function FrameworkEventsMonitoringModal({
visible, visible,
onCancel, onCancel,
@@ -184,15 +146,15 @@ function FrameworkEventsMonitoringModal({
<Space direction="vertical" size="large"> <Space direction="vertical" size="large">
<Typography.Text> <Typography.Text>
Monitoring an event will cause the relevant node in the visualizer and Monitoring an event will cause the relevant node in the visualizer and
tree to highlight briefly. Additionally a running total of the number tree to highlight briefly. Additionally counter will show the number
of each event will be show in the tree inline of matching events in the tree
</Typography.Text> </Typography.Text>
<TreeSelect <TreeSelect
treeCheckable treeCheckable
showSearch={false} showSearch={false}
showCheckedStrategy={TreeSelect.SHOW_PARENT} showCheckedStrategy={TreeSelect.SHOW_PARENT}
placeholder="Select nodes to monitor" placeholder="Select node types to monitor"
virtual={false} //for scrollbar virtual={false} //for scrollbar
style={{ style={{
width: '100%', width: '100%',