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
120
121
122
123
124
|
/* 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";
define(function (require, exports) {
const { Component } = require("devtools/client/shared/vendor/react");
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
const { createFactories } = require("devtools/client/shared/react-utils");
const { JsonPanel } = createFactories(
require("devtools/client/jsonview/components/JsonPanel")
);
const { TextPanel } = createFactories(
require("devtools/client/jsonview/components/TextPanel")
);
const { HeadersPanel } = createFactories(
require("devtools/client/jsonview/components/HeadersPanel")
);
const { Tabs, TabPanel } = createFactories(
require("devtools/client/shared/components/tabs/Tabs")
);
/**
* This object represents the root application template
* responsible for rendering the basic tab layout.
*/
class MainTabbedArea extends Component {
static get propTypes() {
return {
jsonText: PropTypes.instanceOf(Text),
activeTab: PropTypes.number,
actions: PropTypes.object,
headers: PropTypes.object,
searchFilter: PropTypes.string,
json: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object,
PropTypes.array,
PropTypes.bool,
PropTypes.number,
]),
expandedNodes: PropTypes.instanceOf(Set),
};
}
constructor(props) {
super(props);
this.state = {
json: props.json,
expandedNodes: props.expandedNodes,
jsonText: props.jsonText,
activeTab: props.activeTab,
};
this.onTabChanged = this.onTabChanged.bind(this);
}
onTabChanged(index) {
this.setState({ activeTab: index });
// Send notification event to the window. This is useful for tests.
window.dispatchEvent(
new CustomEvent("TabChanged", { detail: { index } })
);
}
render() {
return Tabs(
{
activeTab: this.state.activeTab,
onAfterChange: this.onTabChanged,
tall: true,
},
TabPanel(
{
id: "json",
className: "json",
title: JSONView.Locale["jsonViewer.tab.JSON"],
},
JsonPanel({
data: this.state.json,
expandedNodes: this.state.expandedNodes,
actions: this.props.actions,
searchFilter: this.state.searchFilter,
dataSize: this.state.jsonText.length,
})
),
TabPanel(
{
id: "rawdata",
className: "rawdata",
title: JSONView.Locale["jsonViewer.tab.RawData"],
},
TextPanel({
isValidJson:
!(this.state.json instanceof Error) &&
document.readyState != "loading",
data: this.state.jsonText,
errorMessage:
this.state.json instanceof Error ? this.state.json + "" : null,
actions: this.props.actions,
})
),
TabPanel(
{
id: "headers",
className: "headers",
title: JSONView.Locale["jsonViewer.tab.Headers"],
},
HeadersPanel({
data: this.props.headers,
actions: this.props.actions,
searchFilter: this.props.searchFilter,
})
)
);
}
}
// Exports from this module
exports.MainTabbedArea = MainTabbedArea;
});
|