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
108
109
110
111
112
113
114
115
116
117
118
119
|
/* 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 PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.js");
const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js");
const {
connect,
} = require("resource://devtools/client/shared/redux/visibility-handler-connect.js");
// Components
loader.lazyGetter(this, "AppErrorBoundary", function () {
return createFactory(
require("resource://devtools/client/shared/components/AppErrorBoundary.js")
);
});
loader.lazyGetter(this, "MonitorPanel", function () {
return createFactory(
require("resource://devtools/client/netmonitor/src/components/MonitorPanel.js")
);
});
loader.lazyGetter(this, "StatisticsPanel", function () {
return createFactory(
require("resource://devtools/client/netmonitor/src/components/StatisticsPanel.js")
);
});
loader.lazyGetter(this, "DropHarHandler", function () {
return createFactory(
require("resource://devtools/client/netmonitor/src/components/DropHarHandler.js")
);
});
// Localized strings for (devtools/client/locales/en-US/startup.properties)
loader.lazyGetter(this, "L10N", function () {
const { LocalizationHelper } = require("resource://devtools/shared/l10n.js");
return new LocalizationHelper("devtools/client/locales/startup.properties");
});
const { div } = dom;
/**
* App component
* The top level component for representing main panel
*/
class App extends Component {
static get propTypes() {
return {
// List of actions passed to HAR importer.
actions: PropTypes.object.isRequired,
// The backend connector object.
connector: PropTypes.object.isRequired,
// Callback for opening links in the UI
openLink: PropTypes.func,
// Callback for opening split console.
openSplitConsole: PropTypes.func,
// Service to enable the source map feature.
sourceMapURLService: PropTypes.object,
// True if the stats panel is opened.
statisticsOpen: PropTypes.bool.isRequired,
// Document which settings menu will be injected to
toolboxDoc: PropTypes.object.isRequired,
// Syncing blocked requests
addBlockedUrl: PropTypes.func,
};
}
// Rendering
render() {
const {
actions,
connector,
openLink,
openSplitConsole,
sourceMapURLService,
statisticsOpen,
toolboxDoc,
} = this.props;
return div(
{ className: "network-monitor" },
AppErrorBoundary(
{
componentName: "Netmonitor",
panel: L10N.getStr("netmonitor.label"),
},
!statisticsOpen
? DropHarHandler(
{
actions,
openSplitConsole,
},
MonitorPanel({
actions,
connector,
openSplitConsole,
sourceMapURLService,
openLink,
toolboxDoc,
})
)
: StatisticsPanel({
connector,
})
)
);
}
}
// Exports
module.exports = connect(state => ({
statisticsOpen: state.ui.statisticsOpen,
}))(App);
|