diff options
author | Clemens <cle1000.cb@gmail.com> | 2016-08-10 10:49:27 +0200 |
---|---|---|
committer | Clemens <cle1000.cb@gmail.com> | 2016-08-10 10:49:27 +0200 |
commit | 8b43972b95f002e8a5d8a85b7a53f43f16711362 (patch) | |
tree | b19ae3713219f3a06bc3be13b358f73066a12dbe /web/src/js/components | |
parent | 6397c4d02f10dc68d7f8db3b0ad421ab6e2876b3 (diff) | |
download | mitmproxy-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')
-rw-r--r-- | web/src/js/components/ContentView/ContentViews.jsx | 20 | ||||
-rw-r--r-- | web/src/js/components/ContentView/ShowFullContentButton.jsx | 13 |
2 files changed, 19 insertions, 14 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)) diff --git a/web/src/js/components/ContentView/ShowFullContentButton.jsx b/web/src/js/components/ContentView/ShowFullContentButton.jsx index acb094a7..676068e9 100644 --- a/web/src/js/components/ContentView/ShowFullContentButton.jsx +++ b/web/src/js/components/ContentView/ShowFullContentButton.jsx @@ -11,16 +11,23 @@ ShowFullContentButton.propTypes = { showFullContent: PropTypes.bool.isRequired } -function ShowFullContentButton ( {setShowFullContent, showFullContent} ){ +function ShowFullContentButton ( {setShowFullContent, showFullContent, visibleLines, contentLines} ){ return ( - !showFullContent && <Button className="view-all-content-btn btn-xs" onClick={() => setShowFullContent(true)} text="Show full content"/> + !showFullContent && + <div> + <Button className="view-all-content-btn btn-xs" onClick={() => setShowFullContent(true)} text="Show full content"/> + <span className="pull-right"> {visibleLines}/{contentLines} are visible </span> + </div> ) } export default connect( state => ({ - showFullContent: state.ui.flow.showFullContent + showFullContent: state.ui.flow.showFullContent, + visibleLines: state.ui.flow.maxContentLines, + contentLines: state.ui.flow.content.length + }), { setShowFullContent |