forked from Shikaga/DamJS
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CapturedPacketElement.js
38 lines (38 loc) · 1.15 KB
/
CapturedPacketElement.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
define(['lib/react', 'CapturedPacketElementInfo'], function(React, CapturedPacketElementInfo) {
return React.createClass({
getInitialState: function() {
return {
infoShown: false,
infoElement: React.DOM.div(null)
}
},
toggleInfo: function() {
if (this.state.infoShown) {
this.setState({
infoElement: React.DOM.div(null),
infoShown: false
});
} else {
this.setState({
infoElement: CapturedPacketElementInfo({joinPoint: this.props.joinPoint}),
infoShown: true
});
}
},
forwardJoinPoint: function() {
this.props.joinPoint.matcher.forwardJoinPoint(this.props.joinPoint);
},
removeJoinPoint: function() {
this.props.joinPoint.matcher.removeJoinPoint(this.props.joinPoint);
},
render: function() {
var capturedJP = this.props.joinPoint;
var subjectElement = React.DOM.span(null, capturedJP.target.getSubject())
return React.DOM.div(null, subjectElement,
React.DOM.button({onClick: this.forwardJoinPoint}, "Forward"),
React.DOM.button({onClick: this.removeJoinPoint}, "Remove"),
React.DOM.button({onClick: this.toggleInfo}, "Info"),
this.state.infoElement);
}
});
});