-
Notifications
You must be signed in to change notification settings - Fork 5
/
MatcherConfigElement.js
50 lines (48 loc) · 2.28 KB
/
MatcherConfigElement.js
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
define(['lib/react', 'MatcherFilterOutgoingButton', 'MatcherInjectOutgoingButton', 'MatcherLoggerOutgoingButton', 'MatcherFilterIncomingButton', 'MatcherInjectIncomingButton', 'MatcherLoggerIncomingButton', 'InjectorConfigElement', 'CapturedPacketListElement'], function(React, MatcherFilterOutgoingButton, MatcherInjectOutgoingButton, MatcherLoggerOutgoingButton, MatcherFilterIncomingButton, MatcherInjectIncomingButton, MatcherLoggerIncomingButton, InjectorConfigElement, CapturedPacketListElement) {
return React.createClass({
getInitialState: function() {
return {state: "none"}
},
back: function() {
this.setState({state: "none"});
},
inject: function() {
this.setState({state: "inject"});
},
captured: function() {
this.setState({state: "captured"});
},
render: function() {
var textStyle = {display: "inline-block", minWidth: "40px"};
var buttonStyle = {backgroundColor: "lightgrey"};
if (this.state.state == "captured") {
return React.DOM.div({style: columnStyle},
CapturedPacketListElement({matcher: this.props.matcher, back: this.back}));
} else if (this.state.state == "inject") {
return React.DOM.div({style: columnStyle},
InjectorConfigElement({matcher: this.props.matcher, back: this.back}));
} else if (this.props.matcher) {
return React.DOM.div(null,
React.DOM.button({onClick: function() {this.props.deselectMatcher()}.bind(this)}, "Back"),
React.DOM.div(null, this.props.matcher.matchString),
React.DOM.div(null,
React.DOM.span({style: textStyle},"Filter"), MatcherFilterIncomingButton({matcher: this.props.matcher}),
MatcherFilterOutgoingButton({matcher: this.props.matcher}),
React.DOM.button({style: buttonStyle, onClick: this.captured}, "View")
),
React.DOM.div(null,
React.DOM.span({style: textStyle},"Inject"), MatcherInjectIncomingButton({matcher: this.props.matcher}),
MatcherInjectOutgoingButton({matcher: this.props.matcher}),
React.DOM.button({style: buttonStyle, onClick: this.inject}, "Conf")
),
React.DOM.div(null,
React.DOM.span({style: textStyle},"Log"), MatcherLoggerIncomingButton({matcher: this.props.matcher}),
MatcherLoggerOutgoingButton({matcher: this.props.matcher})
)
);
} else {
return React.DOM.div();
}
}
})
});