Footer.js (2217B)
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 connect, 9 } = require("resource://devtools/client/shared/vendor/react-redux.js"); 10 const { 11 createFactory, 12 PureComponent, 13 } = require("resource://devtools/client/shared/vendor/react.mjs"); 14 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); 15 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs"); 16 17 const FluentReact = require("resource://devtools/client/shared/vendor/fluent-react.js"); 18 const Localized = createFactory(FluentReact.Localized); 19 20 const { 21 updateSettingsVisibility, 22 } = require("resource://devtools/client/inspector/compatibility/actions/compatibility.js"); 23 24 const SETTINGS_ICON = "chrome://devtools/skin/images/settings.svg"; 25 26 class Footer extends PureComponent { 27 static get propTypes() { 28 return { 29 updateSettingsVisibility: PropTypes.func.isRequired, 30 }; 31 } 32 33 _renderButton(icon, labelId, titleId, onClick) { 34 return Localized( 35 { 36 id: titleId, 37 attrs: { title: true }, 38 }, 39 dom.button( 40 { 41 className: "compatibility-footer__button", 42 title: titleId, 43 onClick, 44 }, 45 dom.img({ 46 className: "compatibility-footer__icon", 47 src: icon, 48 }), 49 Localized( 50 { 51 id: labelId, 52 }, 53 dom.label( 54 { 55 className: "compatibility-footer__label", 56 }, 57 labelId 58 ) 59 ) 60 ) 61 ); 62 } 63 64 render() { 65 return dom.footer( 66 { 67 className: "compatibility-footer", 68 }, 69 this._renderButton( 70 SETTINGS_ICON, 71 "compatibility-settings-button-label", 72 "compatibility-settings-button-title", 73 this.props.updateSettingsVisibility 74 ) 75 ); 76 } 77 } 78 79 const mapDispatchToProps = dispatch => { 80 return { 81 updateSettingsVisibility: () => dispatch(updateSettingsVisibility(true)), 82 }; 83 }; 84 85 module.exports = connect(null, mapDispatchToProps)(Footer);