/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment, useContext} from 'react'; import {ModalDialog} from '../ModalDialog'; import {ProfilerContext} from './ProfilerContext'; import TabBar from '../TabBar'; import ClearProfilingDataButton from './ClearProfilingDataButton'; import CommitFlamegraph from './CommitFlamegraph'; import CommitRanked from './CommitRanked'; import Interactions from './Interactions'; import RootSelector from './RootSelector'; import RecordToggle from './RecordToggle'; import ReloadAndProfileButton from './ReloadAndProfileButton'; import ProfilingImportExportButtons from './ProfilingImportExportButtons'; import SnapshotSelector from './SnapshotSelector'; import SidebarCommitInfo from './SidebarCommitInfo'; import SidebarInteractions from './SidebarInteractions'; import SidebarSelectedFiberInfo from './SidebarSelectedFiberInfo'; import SettingsModal from 'react-devtools-shared/src/devtools/views/Settings/SettingsModal'; import SettingsModalContextToggle from 'react-devtools-shared/src/devtools/views/Settings/SettingsModalContextToggle'; import {SettingsModalContextController} from 'react-devtools-shared/src/devtools/views/Settings/SettingsModalContext'; import portaledContent from '../portaledContent'; import styles from './Profiler.css'; function Profiler(_: {||}) { const { didRecordCommits, isProcessingData, isProfiling, selectedCommitIndex, selectedFiberID, selectedTabID, selectTab, supportsProfiling, } = useContext(ProfilerContext); let view = null; if (didRecordCommits) { switch (selectedTabID) { case 'flame-chart': view = ; break; case 'ranked-chart': view = ; break; case 'interactions': view = ; break; default: break; } } else if (isProfiling) { view = ; } else if (isProcessingData) { view = ; } else if (supportsProfiling) { view = ; } else { view = ; } let sidebar = null; if (!isProfiling && !isProcessingData && didRecordCommits) { switch (selectedTabID) { case 'interactions': sidebar = ; break; case 'flame-chart': case 'ranked-chart': // TRICKY // Handle edge case where no commit is selected because of a min-duration filter update. // In that case, the selected commit index would be null. // We could still show a sidebar for the previously selected fiber, // but it would be an odd user experience. // TODO (ProfilerContext) This check should not be necessary. if (selectedCommitIndex !== null) { if (selectedFiberID !== null) { sidebar = ; } else { sidebar = ; } } break; default: break; } } return (
{didRecordCommits && (
)}
{view}
{sidebar}
); } const tabs = [ { id: 'flame-chart', icon: 'flame-chart', label: 'Flamegraph', title: 'Flamegraph chart', }, { id: 'ranked-chart', icon: 'ranked-chart', label: 'Ranked', title: 'Ranked chart', }, { id: 'interactions', icon: 'interactions', label: 'Interactions', title: 'Profiled interactions', }, ]; const NoProfilingData = () => (
No profiling data has been recorded.
Click the record button to start recording.
); const ProfilingNotSupported = () => (
Profiling not supported.

Profiling support requires either a development or production-profiling build of React v16.5+.

Learn more at{' '} fb.me/react-profiling .

); const ProcessingData = () => (
Processing data...
This should only take a minute.
); const RecordingInProgress = () => (
Profiling is in progress...
Click the record button to stop recording.
); export default portaledContent(Profiler);