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/. */
9 } = require("resource://devtools/client/shared/vendor/react.js");
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.js");
14 } = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
17 } = require("resource://devtools/client/netmonitor/src/utils/request-utils.js");
19 const { div
, span
} = dom
;
21 const UPDATED_STATUS_PROPS
= [
30 * Status code component
31 * Displays HTTP status code icon
32 * Used in RequestListColumnStatus and HeadersPanel
34 class StatusCode
extends Component
{
35 static get propTypes() {
37 item
: PropTypes
.object
.isRequired
,
41 shouldComponentUpdate(nextProps
) {
42 return !propertiesEqual(
50 const { item
} = this.props
;
64 } else if (fromServiceWorker
) {
65 code
= "service worker";
75 "requests-list-status-code status-code status-code-blocked",
76 title
: L10N
.getStr("networkMenu.blockedTooltip"),
79 className
: "status-code-blocked-icon",
91 if (earlyHintsStatus
) {
93 status
: earlyHintsStatus
,
95 code
: earlyHintsStatus
,
99 // `data-code` refers to the status-code
100 // `data-status-code` can be one of "cached", "service worker"
101 // or the status-code itself
102 // For example - if a resource is cached, `data-code` would be 200
103 // and the `data-status-code` would be "cached"
106 statusInfo
.map(info
=> {
112 className
: "requests-list-status-code status-code",
113 onMouseOver({ target
}) {
114 if (info
.status
&& info
.statusText
&& !target
.title
) {
115 target
.title
= getStatusTooltip(item
);
118 "data-status-code": info
.code
,
119 "data-code": info
.status
,
128 function getStatusTooltip(item
) {
129 const { fromCache
, fromServiceWorker
, status
, statusText
} = item
;
131 if (fromCache
&& fromServiceWorker
) {
132 title
= L10N
.getFormatStr(
133 "netmonitor.status.tooltip.cachedworker",
137 } else if (fromCache
) {
138 title
= L10N
.getFormatStr(
139 "netmonitor.status.tooltip.cached",
143 } else if (fromServiceWorker
) {
144 title
= L10N
.getFormatStr(
145 "netmonitor.status.tooltip.worker",
150 title
= L10N
.getFormatStr(
151 "netmonitor.status.tooltip.simple",
159 module
.exports
= StatusCode
;