/** * 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 React, {useState} from 'react'; import {plugin} from '../../index'; import {Button, Input, Modal, Tooltip, Typography, Space, Switch} from 'antd'; import { EyeOutlined, PauseCircleOutlined, PlayCircleOutlined, SearchOutlined, } from '@ant-design/icons'; import {usePlugin, useValue, Layout} from 'flipper-plugin'; import {FrameworkEventType} from '../../ClientTypes'; import { buildTreeSelectData, FrameworkEventsTreeSelect, } from '../shared/FrameworkEventsTreeSelect'; export const TreeControls: React.FC = () => { const instance = usePlugin(plugin); const searchTerm = useValue(instance.uiState.searchTerm); const isPaused = useValue(instance.uiState.isPaused); const filterMainThreadMonitoring = useValue( instance.uiState.filterMainThreadMonitoring, ); const frameworkEventMonitoring: Map = useValue( instance.uiState.frameworkEventMonitoring, ); const [showFrameworkEventsModal, setShowFrameworkEventsModal] = useState(false); return ( { instance.uiActions.onSearchTermUpdated(e.target.value); }} prefix={} placeholder="Search" /> {frameworkEventMonitoring.size > 0 && ( <> setShowFrameworkEventsModal(false)} /> )} ); }; function FrameworkEventsMonitoringModal({ visible, onCancel, onSetEventMonitored, onSetFilterMainThreadMonitoring, filterMainThreadMonitoring, frameworkEventTypes, }: { visible: boolean; onCancel: () => void; onSetEventMonitored: ( eventType: FrameworkEventType, monitored: boolean, ) => void; filterMainThreadMonitoring: boolean; onSetFilterMainThreadMonitoring: (toggled: boolean) => void; frameworkEventTypes: [FrameworkEventType, boolean][]; }) { const selectedFrameworkEvents = frameworkEventTypes .filter(([, selected]) => selected) .map(([eventType]) => eventType); const treeData = buildTreeSelectData( frameworkEventTypes.map(([type]) => type), ); return ( Monitoring an event will cause the relevant node in the visualizer and tree to highlight briefly. Additionally counter will show the number of matching events in the tree { onSetFilterMainThreadMonitoring(event); }} /> Only highlight events that occured on the main thread ); }