DevToolsPanel.js (3221B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 // @ts-check 5 6 /** 7 * @template P 8 * @typedef {import("react-redux").ResolveThunks<P>} ResolveThunks<P> 9 */ 10 11 /** 12 * @typedef {object} StateProps 13 * @property {boolean?} isSupportedPlatform 14 */ 15 16 /** 17 * @typedef {object} OwnProps 18 * @property {import("../../@types/perf").PerfFront} perfFront 19 * @property {import("../../@types/perf").OnProfileReceived} onProfileReceived 20 * @property {() => void} onEditSettingsLinkClicked 21 */ 22 23 /** 24 * @typedef {StateProps & OwnProps} Props 25 * @typedef {import("../../@types/perf").State} StoreState 26 * @typedef {import("../../@types/perf").RecordingState} RecordingState 27 * @typedef {import("../../@types/perf").PanelWindow} PanelWindow 28 */ 29 30 "use strict"; 31 32 const { 33 PureComponent, 34 createFactory, 35 } = require("resource://devtools/client/shared/vendor/react.mjs"); 36 const { 37 connect, 38 } = require("resource://devtools/client/shared/vendor/react-redux.js"); 39 const { 40 div, 41 hr, 42 } = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); 43 const RecordingButton = createFactory( 44 require("resource://devtools/client/performance-new/components/panel/RecordingButton.js") 45 ); 46 const Description = createFactory( 47 require("resource://devtools/client/performance-new/components/panel/Description.js") 48 ); 49 const DevToolsPresetSelection = createFactory( 50 require("resource://devtools/client/performance-new/components/panel/DevToolsPresetSelection.js") 51 ); 52 const OnboardingMessage = createFactory( 53 require("resource://devtools/client/performance-new/components/panel/OnboardingMessage.js") 54 ); 55 const ToolboxHighlightController = createFactory( 56 require("resource://devtools/client/performance-new/components/panel/ToolboxHighlightController.js") 57 ); 58 59 const selectors = require("resource://devtools/client/performance-new/store/selectors.js"); 60 const anyWindow = /** @type {any} */ (window); 61 const panelWindow = /** @type {PanelWindow} */ (anyWindow); 62 63 /** 64 * This is the top level component for the DevTools panel. 65 * 66 * @augments {React.PureComponent<Props>} 67 */ 68 class DevToolsPanel extends PureComponent { 69 render() { 70 const { 71 isSupportedPlatform, 72 perfFront, 73 onProfileReceived, 74 onEditSettingsLinkClicked, 75 } = this.props; 76 77 if (isSupportedPlatform === null) { 78 // We don't know yet if this is a supported platform, wait for a response. 79 return null; 80 } 81 82 return [ 83 OnboardingMessage(), 84 div( 85 { className: `perf perf-devtools` }, 86 RecordingButton({ perfFront, onProfileReceived }), 87 panelWindow.gToolbox 88 ? ToolboxHighlightController({ toolbox: panelWindow.gToolbox }) 89 : null, 90 Description(), 91 hr({ className: "perf-presets-hr" }), 92 DevToolsPresetSelection({ onEditSettingsLinkClicked }) 93 ), 94 ]; 95 } 96 } 97 98 /** 99 * @param {StoreState} state 100 * @returns {StateProps} 101 */ 102 function mapStateToProps(state) { 103 return { 104 isSupportedPlatform: selectors.getIsSupportedPlatform(state), 105 }; 106 } 107 108 module.exports = connect(mapStateToProps)(DevToolsPanel);