InspectAction.js (1679B)
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 5 "use strict"; 6 7 const { 8 createFactory, 9 PureComponent, 10 } = require("resource://devtools/client/shared/vendor/react.mjs"); 11 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); 12 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs"); 13 14 const FluentReact = require("resource://devtools/client/shared/vendor/fluent-react.js"); 15 const Localized = createFactory(FluentReact.Localized); 16 17 const Actions = require("resource://devtools/client/aboutdebugging/src/actions/index.js"); 18 const Types = require("resource://devtools/client/aboutdebugging/src/types/index.js"); 19 20 /** 21 * This component provides inspect button. 22 */ 23 class InspectAction extends PureComponent { 24 static get propTypes() { 25 return { 26 dispatch: PropTypes.func.isRequired, 27 disabled: PropTypes.bool, 28 target: Types.debugTarget.isRequired, 29 title: PropTypes.string, 30 }; 31 } 32 33 inspect() { 34 const { dispatch, target } = this.props; 35 dispatch(Actions.inspectDebugTarget(target.type, target.id)); 36 } 37 38 render() { 39 const { disabled, title } = this.props; 40 41 return Localized( 42 { 43 id: "about-debugging-debug-target-inspect-button", 44 }, 45 dom.button( 46 { 47 onClick: () => this.inspect(), 48 className: "default-button qa-debug-target-inspect-button", 49 disabled, 50 title, 51 }, 52 "Inspect" 53 ) 54 ); 55 } 56 } 57 58 module.exports = InspectAction;