aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/components/FlowView.jsx
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-10-25 15:25:41 +0200
committerMaximilian Hils <git@maximilianhils.com>2017-10-25 15:25:41 +0200
commit42895f4fec0f914d2ca3696c6962830140610e6e (patch)
treeb9834abcf99feaf9ac113820814b4998ef9daba0 /web/src/js/components/FlowView.jsx
parentf870ccd949ca46e6a1ca48a6d5e40589fad41ce2 (diff)
downloadmitmproxy-42895f4fec0f914d2ca3696c6962830140610e6e.tar.gz
mitmproxy-42895f4fec0f914d2ca3696c6962830140610e6e.tar.bz2
mitmproxy-42895f4fec0f914d2ca3696c6962830140610e6e.zip
[web] minor fixes and cleanup
Diffstat (limited to 'web/src/js/components/FlowView.jsx')
-rw-r--r--web/src/js/components/FlowView.jsx100
1 files changed, 27 insertions, 73 deletions
diff --git a/web/src/js/components/FlowView.jsx b/web/src/js/components/FlowView.jsx
index fbdbb049..25e7bb9f 100644
--- a/web/src/js/components/FlowView.jsx
+++ b/web/src/js/components/FlowView.jsx
@@ -3,93 +3,47 @@ import { connect } from 'react-redux'
import _ from 'lodash'
import Nav from './FlowView/Nav'
-import { Request, Response, ErrorView as Error } from './FlowView/Messages'
+import { ErrorView as Error, Request, Response } from './FlowView/Messages'
import Details from './FlowView/Details'
import { selectTab } from '../ducks/ui/flow'
-class FlowView extends Component {
+export const allTabs = { Request, Response, Error, Details }
- static allTabs = { Request, Response, Error, Details }
+function FlowView({ flow, tabName, selectTab }) {
- constructor(props, context) {
- super(props, context)
- this.onPromptFinish = this.onPromptFinish.bind(this)
- }
+ // only display available tab names
+ const tabs = ['request', 'response', 'error'].filter(k => flow[k])
+ tabs.push("details")
- onPromptFinish(edit) {
- this.props.setPrompt(false)
- if (edit && this.tabComponent) {
- this.tabComponent.edit(edit)
+ if (tabs.indexOf(tabName) < 0) {
+ if (tabName === 'response' && flow.error) {
+ tabName = 'error'
+ } else if (tabName === 'error' && flow.response) {
+ tabName = 'response'
+ } else {
+ tabName = tabs[0]
}
}
- getPromptOptions() {
- switch (this.props.tab) {
-
- case 'request':
- return [
- 'method',
- 'url',
- { text: 'http version', key: 'v' },
- 'header'
- ]
- break
-
- case 'response':
- return [
- { text: 'http version', key: 'v' },
- 'code',
- 'message',
- 'header'
- ]
- break
-
- case 'details':
- return
-
- default:
- throw 'Unknown tab for edit: ' + this.props.tab
- }
- }
-
- render() {
- let { flow, tab: active, updateFlow } = this.props
- const tabs = ['request', 'response', 'error'].filter(k => flow[k]).concat(['details'])
-
- if (tabs.indexOf(active) < 0) {
- if (active === 'response' && flow.error) {
- active = 'error'
- } else if (active === 'error' && flow.response) {
- active = 'response'
- } else {
- active = tabs[0]
- }
- }
-
- const Tab = FlowView.allTabs[_.capitalize(active)]
-
- return (
- <div className="flow-detail">
- <Nav
- flow={flow}
- tabs={tabs}
- active={active}
- onSelectTab={this.props.selectTab}
- />
- <Tab ref={ tab => this.tabComponent = tab } flow={flow} updateFlow={updateFlow} />
- {this.props.promptOpen && (
- <div>fixme</div>
- )}
- </div>
- )
- }
+ const Tab = allTabs[_.capitalize(tabName)]
+
+ return (
+ <div className="flow-detail">
+ <Nav
+ tabs={tabs}
+ active={tabName}
+ onSelectTab={selectTab}
+ />
+ <Tab flow={flow}/>
+ </div>
+ )
}
export default connect(
state => ({
- promptOpen: state.ui.promptOpen,
- tab: state.ui.flow.tab
+ flow: state.flows.byId[state.flows.selected[0]],
+ tabName: state.ui.flow.tab,
}),
{
selectTab,