aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/components/ContentView/ContentViews.jsx
diff options
context:
space:
mode:
authorClemens <cle1000.cb@gmail.com>2016-08-10 10:49:27 +0200
committerClemens <cle1000.cb@gmail.com>2016-08-10 10:49:27 +0200
commit8b43972b95f002e8a5d8a85b7a53f43f16711362 (patch)
treeb19ae3713219f3a06bc3be13b358f73066a12dbe /web/src/js/components/ContentView/ContentViews.jsx
parent6397c4d02f10dc68d7f8db3b0ad421ab6e2876b3 (diff)
downloadmitmproxy-8b43972b95f002e8a5d8a85b7a53f43f16711362.tar.gz
mitmproxy-8b43972b95f002e8a5d8a85b7a53f43f16711362.tar.bz2
mitmproxy-8b43972b95f002e8a5d8a85b7a53f43f16711362.zip
move content to redux, add lines to view
Diffstat (limited to 'web/src/js/components/ContentView/ContentViews.jsx')
-rw-r--r--web/src/js/components/ContentView/ContentViews.jsx20
1 files changed, 9 insertions, 11 deletions
diff --git a/web/src/js/components/ContentView/ContentViews.jsx b/web/src/js/components/ContentView/ContentViews.jsx
index 9feb0623..cd593023 100644
--- a/web/src/js/components/ContentView/ContentViews.jsx
+++ b/web/src/js/components/ContentView/ContentViews.jsx
@@ -1,6 +1,6 @@
import React, { PropTypes, Component } from 'react'
import { connect } from 'react-redux'
-import { setContentViewDescription, setShowFullContent } from '../../ducks/ui/flow'
+import { setContentViewDescription, setContent } from '../../ducks/ui/flow'
import ContentLoader from './ContentLoader'
import { MessageUtils } from '../../flow/utils'
import CodeEditor from './CodeEditor'
@@ -30,28 +30,25 @@ function Edit({ content, onChange }) {
Edit = ContentLoader(Edit)
class ViewServer extends Component {
- static defaultProps = {
- maxLines: 80,
- }
componentWillMount(){
this.setContentView(this.props)
}
componentWillReceiveProps(nextProps){
- this.setContentView(nextProps)
+ if (nextProps.content != this.props.content) {
+ this.setContentView(nextProps)
+ }
}
setContentView(props){
try {
this.data = JSON.parse(props.content)
}catch(err) {
- this.data= {lines: [], description: err.message}
+ this.data = {lines: [], description: err.message}
}
props.setContentViewDescription(props.contentView != this.data.description ? this.data.description : '')
-
- let isFullContentShown = this.data.lines.length < props.maxLines
- if (isFullContentShown) props.setShowFullContent(true)
+ props.setContent(this.data.lines)
}
render() {
const {content, contentView, message, maxLines} = this.props
@@ -78,11 +75,12 @@ class ViewServer extends Component {
ViewServer = connect(
state => ({
- showFullContent: state.ui.flow.showFullContent
+ showFullContent: state.ui.flow.showFullContent,
+ maxLines: state.ui.flow.maxContentLines
}),
{
setContentViewDescription,
- setShowFullContent
+ setContent
}
)(ContentLoader(ViewServer))