mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
added flow_content update
This commit is contained in:
parent
698fb11132
commit
281f20ef1e
@ -5,9 +5,8 @@ import * as ContentViews from './ContentView/ContentViews'
|
|||||||
import * as MetaViews from './ContentView/MetaViews'
|
import * as MetaViews from './ContentView/MetaViews'
|
||||||
import ContentLoader from './ContentView/ContentLoader'
|
import ContentLoader from './ContentView/ContentLoader'
|
||||||
import ViewSelector from './ContentView/ViewSelector'
|
import ViewSelector from './ContentView/ViewSelector'
|
||||||
import { setContentView, setDisplayLarge } from '../ducks/ui'
|
import { setContentView, setDisplayLarge, setModifiedFlowContent } from '../ducks/ui'
|
||||||
import CodeEditor from './common/CodeEditor'
|
import CodeEditor from './common/CodeEditor'
|
||||||
import {setModifiedFlowContent} from '../ducks/flows'
|
|
||||||
|
|
||||||
ContentView.propTypes = {
|
ContentView.propTypes = {
|
||||||
// It may seem a bit weird at the first glance:
|
// It may seem a bit weird at the first glance:
|
||||||
@ -20,7 +19,7 @@ ContentView.propTypes = {
|
|||||||
ContentView.isContentTooLarge = msg => msg.contentLength > 1024 * 1024 * (ContentViews.ViewImage.matches(msg) ? 10 : 0.2)
|
ContentView.isContentTooLarge = msg => msg.contentLength > 1024 * 1024 * (ContentViews.ViewImage.matches(msg) ? 10 : 0.2)
|
||||||
|
|
||||||
function ContentView(props) {
|
function ContentView(props) {
|
||||||
const { flow, message, contentView, selectView, displayLarge, setDisplayLarge } = props
|
const { flow, message, contentView, selectView, displayLarge, setDisplayLarge, onContentChange, isFlowEditorOpen, setModifiedFlowContent } = props
|
||||||
|
|
||||||
if (message.contentLength === 0) {
|
if (message.contentLength === 0) {
|
||||||
return <MetaViews.ContentEmpty {...props}/>
|
return <MetaViews.ContentEmpty {...props}/>
|
||||||
@ -37,6 +36,12 @@ function ContentView(props) {
|
|||||||
const View = ContentViews[contentView]
|
const View = ContentViews[contentView]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
|
{isFlowEditorOpen ? (
|
||||||
|
<ContentLoader flow={flow} message={message}>
|
||||||
|
<CodeEditor content="" onChange={content =>{setModifiedFlowContent(content)}}/>
|
||||||
|
</ContentLoader>
|
||||||
|
): (
|
||||||
<div>
|
<div>
|
||||||
{View.textView ? (
|
{View.textView ? (
|
||||||
<ContentLoader flow={flow} message={message}>
|
<ContentLoader flow={flow} message={message}>
|
||||||
@ -48,11 +53,28 @@ function ContentView(props) {
|
|||||||
<div className="view-options text-center">
|
<div className="view-options text-center">
|
||||||
<ViewSelector onSelectView={selectView} active={View} message={message}/>
|
<ViewSelector onSelectView={selectView} active={View} message={message}/>
|
||||||
|
|
||||||
<a className="btn btn-default btn-xs" href={MessageUtils.getContentURL(flow, message)}>
|
<a className="btn btn-default btn-xs"
|
||||||
|
href={MessageUtils.getContentURL(flow, message)}
|
||||||
|
title="Download the content of the flow.">
|
||||||
<i className="fa fa-download"/>
|
<i className="fa fa-download"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a className="btn btn-default btn-xs"
|
||||||
|
onClick={() => ContentView.fileInput.click()}
|
||||||
|
title="Upload a file to replace the content."
|
||||||
|
>
|
||||||
|
<i className="fa fa-upload"/>
|
||||||
|
</a>
|
||||||
|
<input
|
||||||
|
ref={ref => ContentView.fileInput = ref}
|
||||||
|
className="hidden"
|
||||||
|
type="file"
|
||||||
|
onChange={e => {if(e.target.files.length > 0) onContentChange(e.target.files[0])}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,9 +82,11 @@ export default connect(
|
|||||||
state => ({
|
state => ({
|
||||||
contentView: state.ui.contentView,
|
contentView: state.ui.contentView,
|
||||||
displayLarge: state.ui.displayLarge,
|
displayLarge: state.ui.displayLarge,
|
||||||
|
isFlowEditorOpen : state.ui.isFlowEditorOpen
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
selectView: setContentView,
|
selectView: setContentView,
|
||||||
setDisplayLarge,
|
setDisplayLarge,
|
||||||
|
setModifiedFlowContent
|
||||||
}
|
}
|
||||||
)(ContentView)
|
)(ContentView)
|
||||||
|
@ -4,21 +4,13 @@ import { connect } from 'react-redux'
|
|||||||
import {closeFlowEditor} from '../../ducks/ui.js'
|
import {closeFlowEditor} from '../../ducks/ui.js'
|
||||||
import {openFlowEditor} from '../../ducks/ui.js'
|
import {openFlowEditor} from '../../ducks/ui.js'
|
||||||
|
|
||||||
// FlowEditorButton.propTypes = {
|
FlowEditorButton.propTypes = {
|
||||||
// isFlowEditorOpen: PropTypes.bool.isRequired,
|
|
||||||
// content: PropTypes.string.isRequired,
|
|
||||||
// onContentChange: PropTypes.func.isRequired
|
|
||||||
// }
|
|
||||||
|
|
||||||
class FlowEditorButton extends Component{
|
|
||||||
static propTypes = {
|
|
||||||
isFlowEditorOpen: PropTypes.bool.isRequired,
|
isFlowEditorOpen: PropTypes.bool.isRequired,
|
||||||
content: PropTypes.string.isRequired,
|
content: PropTypes.string.isRequired,
|
||||||
onContentChange: PropTypes.func.isRequired
|
onContentChange: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
function FlowEditorButton ({ isFlowEditorOpen, closeFlowEditor, openFlowEditor, onContentChange, content }) {
|
||||||
let { isFlowEditorOpen, closeFlowEditor, openFlowEditor, onContentChange, content } = this.props
|
|
||||||
return (
|
return (
|
||||||
<div className="edit-flow-container">
|
<div className="edit-flow-container">
|
||||||
{isFlowEditorOpen ?
|
{isFlowEditorOpen ?
|
||||||
@ -32,13 +24,12 @@ class FlowEditorButton extends Component{
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
state => ({
|
state => ({
|
||||||
isFlowEditorOpen: state.ui.isFlowEditorOpen,
|
isFlowEditorOpen: state.ui.isFlowEditorOpen,
|
||||||
content: state.flows.modifiedFlow.content
|
content: state.ui.modifiedFlow.content
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
closeFlowEditor,
|
closeFlowEditor,
|
||||||
|
@ -7,7 +7,7 @@ import ContentView from '../ContentView'
|
|||||||
import ValueEditor from '../ValueEditor'
|
import ValueEditor from '../ValueEditor'
|
||||||
import Headers from './Headers'
|
import Headers from './Headers'
|
||||||
import * as flowActions from '../../ducks/flows'
|
import * as flowActions from '../../ducks/flows'
|
||||||
import FlowEditorButton from './FlowEditorButton.jsx'
|
import FlowEditorButton from './FlowEditorButton'
|
||||||
|
|
||||||
|
|
||||||
class RequestLine extends Component {
|
class RequestLine extends Component {
|
||||||
|
@ -9,6 +9,9 @@ export const UPDATE_QUERY = 'UI_UPDATE_QUERY'
|
|||||||
export const SELECT_TAB = 'UI_SELECT_TAB'
|
export const SELECT_TAB = 'UI_SELECT_TAB'
|
||||||
export const SET_PROMPT = 'UI_SET_PROMPT'
|
export const SET_PROMPT = 'UI_SET_PROMPT'
|
||||||
export const SET_DISPLAY_LARGE = 'UI_SET_DISPLAY_LARGE'
|
export const SET_DISPLAY_LARGE = 'UI_SET_DISPLAY_LARGE'
|
||||||
|
export const OPEN_FLOW_EDITOR= 'UI_OPEN_FLOW_EDITOR'
|
||||||
|
export const CLOSE_FLOW_EDITOR = 'UI_CLOSE_FLOW_EDITOR'
|
||||||
|
export const SET_MODIFIED_FLOW_CONTENT = 'UI_SET_MODIFIED_FLOW'
|
||||||
|
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
activeMenu: 'Start',
|
activeMenu: 'Start',
|
||||||
@ -18,7 +21,9 @@ const defaultState = {
|
|||||||
promptOpen: false,
|
promptOpen: false,
|
||||||
contentView: 'ViewAuto',
|
contentView: 'ViewAuto',
|
||||||
query: {},
|
query: {},
|
||||||
panel: 'request'
|
panel: 'request',
|
||||||
|
modifiedFlow: {headers: "", content: ""},
|
||||||
|
isFlowEditorOpen: false
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action) {
|
export default function reducer(state = defaultState, action) {
|
||||||
@ -31,9 +36,10 @@ export default function reducer(state = defaultState, action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case flowsActions.SELECT:
|
case flowsActions.SELECT:
|
||||||
|
let s = {...state, isFlowEditorOpen: false}
|
||||||
if (action.flowIds.length && !state.isFlowSelected) {
|
if (action.flowIds.length && !state.isFlowSelected) {
|
||||||
return {
|
return {
|
||||||
...state,
|
...s,
|
||||||
displayLarge: false,
|
displayLarge: false,
|
||||||
activeMenu: 'Flow',
|
activeMenu: 'Flow',
|
||||||
isFlowSelected: true,
|
isFlowSelected: true,
|
||||||
@ -46,14 +52,14 @@ export default function reducer(state = defaultState, action) {
|
|||||||
activeMenu = 'Start'
|
activeMenu = 'Start'
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...state,
|
...s,
|
||||||
activeMenu,
|
activeMenu,
|
||||||
isFlowSelected: false,
|
isFlowSelected: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...s,
|
||||||
displayLarge: false,
|
displayLarge: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +84,7 @@ export default function reducer(state = defaultState, action) {
|
|||||||
case SELECT_TAB:
|
case SELECT_TAB:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
isFlowEditorOpen: false,
|
||||||
panel: action.panel
|
panel: action.panel
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +99,21 @@ export default function reducer(state = defaultState, action) {
|
|||||||
...state,
|
...state,
|
||||||
displayLarge: action.displayLarge,
|
displayLarge: action.displayLarge,
|
||||||
}
|
}
|
||||||
|
case OPEN_FLOW_EDITOR:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
isFlowEditorOpen: true
|
||||||
|
}
|
||||||
|
case CLOSE_FLOW_EDITOR:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
isFlowEditorOpen: false
|
||||||
|
}
|
||||||
|
case SET_MODIFIED_FLOW_CONTENT:
|
||||||
|
return{
|
||||||
|
...state,
|
||||||
|
modifiedFlow: {...state.modifiedFlow, content: action.content}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
@ -126,6 +147,18 @@ export function setDisplayLarge(displayLarge) {
|
|||||||
return { type: SET_DISPLAY_LARGE, displayLarge }
|
return { type: SET_DISPLAY_LARGE, displayLarge }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function openFlowEditor(){
|
||||||
|
return { type: OPEN_FLOW_EDITOR }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function closeFlowEditor(){
|
||||||
|
return { type: CLOSE_FLOW_EDITOR }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setModifiedFlowContent(content) {
|
||||||
|
return { type: SET_MODIFIED_FLOW_CONTENT, content }
|
||||||
|
}
|
||||||
|
|
||||||
export function onKeyDown(e) {
|
export function onKeyDown(e) {
|
||||||
if (e.ctrlKey) {
|
if (e.ctrlKey) {
|
||||||
return () => {
|
return () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user