1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/* 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,
createFactory,
} = require("resource://devtools/client/shared/vendor/react.js");
const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.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 Actions = require("resource://devtools/client/netmonitor/src/actions/index.js");
const {
ACTIVITY_TYPE,
} = require("resource://devtools/client/netmonitor/src/constants.js");
const {
L10N,
} = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
const {
getPerformanceAnalysisURL,
} = require("resource://devtools/client/netmonitor/src/utils/doc-utils.js");
// Components
const MDNLink = createFactory(
require("resource://devtools/client/shared/components/MdnLink.js")
);
const { button, div, span } = dom;
const RELOAD_NOTICE_1 = L10N.getStr("netmonitor.reloadNotice1");
const RELOAD_NOTICE_2 = L10N.getStr("netmonitor.reloadNotice2");
const RELOAD_NOTICE_3 = L10N.getStr("netmonitor.reloadNotice3");
const RELOAD_NOTICE_BT = L10N.getStr("netmonitor.emptyBrowserToolbox");
const PERFORMANCE_NOTICE_1 = L10N.getStr("netmonitor.perfNotice1");
const PERFORMANCE_NOTICE_2 = L10N.getStr("netmonitor.perfNotice2");
const PERFORMANCE_NOTICE_3 = L10N.getStr("netmonitor.perfNotice3");
const PERFORMANCE_LEARN_MORE = L10N.getStr("charts.learnMore");
/**
* UI displayed when the request list is empty. Contains instructions on reloading
* the page and on triggering performance analysis of the page.
*/
class RequestListEmptyNotice extends Component {
static get propTypes() {
return {
connector: PropTypes.object.isRequired,
onReloadClick: PropTypes.func.isRequired,
onPerfClick: PropTypes.func.isRequired,
};
}
render() {
const { connector } = this.props;
const toolbox = connector.getToolbox();
return div(
{
className: "request-list-empty-notice",
},
!toolbox.isBrowserToolbox
? div(
{ className: "notice-reload-message empty-notice-element" },
span(null, RELOAD_NOTICE_1),
button(
{
className: "devtools-button requests-list-reload-notice-button",
"data-standalone": true,
onClick: this.props.onReloadClick,
},
RELOAD_NOTICE_2
),
span(null, RELOAD_NOTICE_3)
)
: div(
{ className: "notice-reload-message empty-notice-element" },
span(null, RELOAD_NOTICE_BT)
),
!toolbox.isBrowserToolbox
? div(
{ className: "notice-perf-message empty-notice-element" },
span(null, PERFORMANCE_NOTICE_1),
button({
title: PERFORMANCE_NOTICE_3,
className: "devtools-button requests-list-perf-notice-button",
"data-standalone": true,
onClick: this.props.onPerfClick,
}),
span(null, PERFORMANCE_NOTICE_2),
MDNLink({
url: getPerformanceAnalysisURL(),
title: PERFORMANCE_LEARN_MORE,
})
)
: null
);
}
}
module.exports = connect(undefined, (dispatch, props) => ({
onPerfClick: () => dispatch(Actions.openStatistics(props.connector, true)),
onReloadClick: () =>
props.connector.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_DEFAULT),
}))(RequestListEmptyNotice);
|