diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/netmonitor/src/components/request-list/RequestListColumnFile.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/netmonitor/src/components/request-list/RequestListColumnFile.js | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/src/components/request-list/RequestListColumnFile.js b/devtools/client/netmonitor/src/components/request-list/RequestListColumnFile.js new file mode 100644 index 0000000000..f824cdb973 --- /dev/null +++ b/devtools/client/netmonitor/src/components/request-list/RequestListColumnFile.js @@ -0,0 +1,91 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const { + Component, +} = require("resource://devtools/client/shared/vendor/react.js"); +const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); +const { + L10N, +} = require("resource://devtools/client/netmonitor/src/utils/l10n.js"); +const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.js"); +const { + connect, +} = require("resource://devtools/client/shared/redux/visibility-handler-connect.js"); +const { + propertiesEqual, +} = require("resource://devtools/client/netmonitor/src/utils/request-utils.js"); +const { + getFormattedTime, +} = require("resource://devtools/client/netmonitor/src/utils/format-utils.js"); + +const UPDATED_FILE_PROPS = ["urlDetails", "waitingTime"]; + +class RequestListColumnFile extends Component { + static get propTypes() { + return { + item: PropTypes.object.isRequired, + slowLimit: PropTypes.number, + onWaterfallMouseDown: PropTypes.func, + }; + } + + shouldComponentUpdate(nextProps) { + return !propertiesEqual( + UPDATED_FILE_PROPS, + this.props.item, + nextProps.item + ); + } + + render() { + const { + item: { urlDetails, waitingTime }, + slowLimit, + onWaterfallMouseDown, + } = this.props; + + const originalFileURL = urlDetails.url; + const decodedFileURL = urlDetails.unicodeUrl; + const ORIGINAL_FILE_URL = L10N.getFormatStr( + "netRequest.originalFileURL.tooltip", + originalFileURL + ); + const DECODED_FILE_URL = L10N.getFormatStr( + "netRequest.decodedFileURL.tooltip", + decodedFileURL + ); + const requestedFile = urlDetails.baseNameWithQuery; + const fileToolTip = + originalFileURL === decodedFileURL + ? originalFileURL + : ORIGINAL_FILE_URL + "\n\n" + DECODED_FILE_URL; + + const isSlow = slowLimit > 0 && !!waitingTime && waitingTime > slowLimit; + + return dom.td( + { + className: "requests-list-column requests-list-file", + title: fileToolTip, + }, + dom.div({}, requestedFile), + isSlow && + dom.div({ + title: L10N.getFormatStr( + "netmonitor.audits.slowIconTooltip", + getFormattedTime(waitingTime), + getFormattedTime(slowLimit) + ), + onMouseDown: onWaterfallMouseDown, + className: "requests-list-slow-button", + }) + ); + } +} + +module.exports = connect(state => ({ + slowLimit: state.ui.slowLimit, +}))(RequestListColumnFile); |