HeadersToolbar.mjs (1222B)
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 import { Component } from "resource://devtools/client/shared/vendor/react.mjs"; 6 import PropTypes from "resource://devtools/client/shared/vendor/react-prop-types.mjs"; 7 import { createFactories } from "resource://devtools/client/shared/react-utils.mjs"; 8 9 import ToolbarClass from "resource://devtools/client/jsonview/components/reps/Toolbar.mjs"; 10 11 const { Toolbar, ToolbarButton } = createFactories(ToolbarClass); 12 13 /** 14 * This template is responsible for rendering a toolbar 15 * within the 'Headers' panel. 16 */ 17 class HeadersToolbar extends Component { 18 static get propTypes() { 19 return { 20 actions: PropTypes.object, 21 }; 22 } 23 24 constructor(props) { 25 super(props); 26 this.onCopy = this.onCopy.bind(this); 27 } 28 29 // Commands 30 31 onCopy() { 32 this.props.actions.onCopyHeaders(); 33 } 34 35 render() { 36 return Toolbar( 37 {}, 38 ToolbarButton( 39 { className: "btn copy", onClick: this.onCopy }, 40 JSONView.Locale["jsonViewer.Copy"] 41 ) 42 ); 43 } 44 } 45 46 export default { HeadersToolbar };