Merge pull request #2002 from mitmproxy/content_views_edit

Content views edit
This commit is contained in:
Maximilian Hils 2017-02-09 23:21:44 +01:00 committed by GitHub
commit 74c991d70b
3 changed files with 6 additions and 15 deletions

View File

@ -12,13 +12,13 @@ ContentViewOptions.propTypes = {
function ContentViewOptions({ flow, message, uploadContent, readonly, contentViewDescription }) { function ContentViewOptions({ flow, message, uploadContent, readonly, contentViewDescription }) {
return ( return (
<div className="view-options"> <div className="view-options">
<ViewSelector message={message}/> {readonly ? <ViewSelector message={message}/> : <span><b>View:</b> edit</span>}
&nbsp; &nbsp;
<DownloadContentButton flow={flow} message={message}/> <DownloadContentButton flow={flow} message={message}/>
&nbsp; &nbsp;
{!readonly && <UploadContentButton uploadContent={uploadContent}/> } {!readonly && <UploadContentButton uploadContent={uploadContent}/> }
&nbsp; &nbsp;
<span>{contentViewDescription}</span> {readonly && <span>{contentViewDescription}</span>}
</div> </div>
) )
} }

View File

@ -1,6 +1,5 @@
import React, { PropTypes, Component } from 'react' import React, { PropTypes, Component } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import * as ContentViews from './ContentViews'
import { setContentView } from '../../ducks/ui/flow'; import { setContentView } from '../../ducks/ui/flow';
import Dropdown from '../common/Dropdown' import Dropdown from '../common/Dropdown'
@ -8,13 +7,11 @@ import Dropdown from '../common/Dropdown'
ViewSelector.propTypes = { ViewSelector.propTypes = {
contentViews: PropTypes.array.isRequired, contentViews: PropTypes.array.isRequired,
activeView: PropTypes.string.isRequired, activeView: PropTypes.string.isRequired,
isEdit: PropTypes.bool.isRequired,
setContentView: PropTypes.func.isRequired setContentView: PropTypes.func.isRequired
} }
function ViewSelector ({contentViews, activeView, isEdit, setContentView}){ function ViewSelector ({contentViews, activeView, setContentView}){
let edit = ContentViews.Edit.displayName let inner = <span> <b>View:</b> {activeView.toLowerCase()} <span className="caret"></span> </span>
let inner = <span> <b>View:</b> {activeView} <span className="caret"></span> </span>
return ( return (
<Dropdown dropup className="pull-left" btnClass="btn btn-default btn-xs" text={inner}> <Dropdown dropup className="pull-left" btnClass="btn btn-default btn-xs" text={inner}>
@ -24,11 +21,6 @@ function ViewSelector ({contentViews, activeView, isEdit, setContentView}){
</a> </a>
) )
} }
{isEdit &&
<a href="#" onClick={e => {e.preventDefault(); setContentView(edit)}}>
{edit.toLowerCase()}
</a>
}
</Dropdown> </Dropdown>
) )
} }
@ -37,7 +29,6 @@ export default connect (
state => ({ state => ({
contentViews: state.settings.contentViews, contentViews: state.settings.contentViews,
activeView: state.ui.flow.contentView, activeView: state.ui.flow.contentView,
isEdit: !!state.ui.flow.modifiedFlow,
}), { }), {
setContentView, setContentView,
} }

View File

@ -89,7 +89,7 @@ export default function reducer(state = defaultState, action) {
...state, ...state,
tab: action.tab ? action.tab : 'request', tab: action.tab ? action.tab : 'request',
displayLarge: false, displayLarge: false,
showFullContent: false showFullContent: state.contentView == 'Edit'
} }
case SET_CONTENT_VIEW: case SET_CONTENT_VIEW: