ColumnSize.js (1166B)
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 Component, 9 } = require("resource://devtools/client/shared/vendor/react.mjs"); 10 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); 11 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs"); 12 const { 13 getFormattedSize, 14 } = require("resource://devtools/client/netmonitor/src/utils/format-utils.js"); 15 16 /** 17 * Renders the "Size" column of a message. 18 */ 19 class ColumnSize extends Component { 20 static get propTypes() { 21 return { 22 item: PropTypes.object.isRequired, 23 }; 24 } 25 26 shouldComponentUpdate(nextProps) { 27 return this.props.item.payload !== nextProps.item.payload; 28 } 29 30 render() { 31 const { payload } = this.props.item; 32 33 return dom.td( 34 { 35 className: "message-list-column message-list-size", 36 title: getFormattedSize(payload.length), 37 }, 38 getFormattedSize(payload.length) 39 ); 40 } 41 } 42 43 module.exports = ColumnSize;