aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-07-25 17:45:42 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-07-25 17:45:42 -0700
commit03a596d1d92e12125f0624626b040dc2919e24c6 (patch)
treee88128bcc7d01aae1ad44b9c0e0daa72e1327bcd /web
parent67bfc1df147f8a6daa847146625d8887a44ac338 (diff)
downloadmitmproxy-03a596d1d92e12125f0624626b040dc2919e24c6.tar.gz
mitmproxy-03a596d1d92e12125f0624626b040dc2919e24c6.tar.bz2
mitmproxy-03a596d1d92e12125f0624626b040dc2919e24c6.zip
simplify stop edit
Diffstat (limited to 'web')
-rw-r--r--web/src/js/components/ContentView/ContentLoader.jsx6
-rw-r--r--web/src/js/components/ValueEditor/ValueEditor.jsx2
-rw-r--r--web/src/js/ducks/ui/flow.js33
3 files changed, 22 insertions, 19 deletions
diff --git a/web/src/js/components/ContentView/ContentLoader.jsx b/web/src/js/components/ContentView/ContentLoader.jsx
index 094ce18b..ba6702ca 100644
--- a/web/src/js/components/ContentView/ContentLoader.jsx
+++ b/web/src/js/components/ContentView/ContentLoader.jsx
@@ -45,12 +45,12 @@ export default View => class extends React.Component {
this.state.request.abort()
}
// We have a few special cases where we do not need to make an HTTP request.
- if(props.message.contentLength === 0 || props.message.contentLength === null){
- return this.setState({request: undefined, content: ""})
- }
if(props.message.content !== undefined) {
return this.setState({request: undefined, content: props.message.content})
}
+ if(props.message.contentLength === 0 || props.message.contentLength === null){
+ return this.setState({request: undefined, content: ""})
+ }
let requestUrl = MessageUtils.getContentURL(props.flow, props.message)
diff --git a/web/src/js/components/ValueEditor/ValueEditor.jsx b/web/src/js/components/ValueEditor/ValueEditor.jsx
index dd9c2cde..852f82c4 100644
--- a/web/src/js/components/ValueEditor/ValueEditor.jsx
+++ b/web/src/js/components/ValueEditor/ValueEditor.jsx
@@ -59,7 +59,7 @@ export default class ValueEditor extends Component {
return (
<div
ref={input => this.input = input}
- tabIndex={!this.props.readonly && "0"}
+ tabIndex={this.props.readonly ? undefined : 0}
className={className}
contentEditable={this.state.editable || undefined}
onFocus={this.onFocus}
diff --git a/web/src/js/ducks/ui/flow.js b/web/src/js/ducks/ui/flow.js
index 100bc771..c9435676 100644
--- a/web/src/js/ducks/ui/flow.js
+++ b/web/src/js/ducks/ui/flow.js
@@ -8,7 +8,6 @@ export const SET_CONTENT_VIEW = 'UI_FLOWVIEW_SET_CONTENT_VIEW',
SET_TAB = "UI_FLOWVIEW_SET_TAB",
START_EDIT = 'UI_FLOWVIEW_START_EDIT',
UPDATE_EDIT = 'UI_FLOWVIEW_UPDATE_EDIT',
- STOP_EDIT = 'UI_FLOWVIEW_STOP_EDIT',
UPLOAD_CONTENT = 'UI_FLOWVIEW_UPLOAD_CONTENT'
@@ -34,12 +33,6 @@ export default function reducer(state = defaultState, action) {
modifiedFlow: _.merge({}, state.modifiedFlow, action.update)
}
- case STOP_EDIT:
- return {
- ...state,
- modifiedFlow: false
- }
-
case flowsActions.SELECT:
return {
...state,
@@ -47,6 +40,21 @@ export default function reducer(state = defaultState, action) {
displayLarge: false,
}
+ case flowsActions.UPDATE:
+ // There is no explicit "stop edit" event.
+ // We stop editing when we receive an update for
+ // the currently edited flow from the server
+ if (action.item.id === state.modifiedFlow.id) {
+ return {
+ ...state,
+ modifiedFlow: false,
+ displayLarge: false,
+ }
+ } else {
+ return state
+ }
+
+
case SET_TAB:
return {
...state,
@@ -90,12 +98,7 @@ export function updateEdit(update) {
return { type: UPDATE_EDIT, update }
}
-export function stopEdit(flow, modified_flow) {
- let diff = getDiff(flow, modified_flow)
- return (dispatch) => {
- dispatch(flowsActions.update(flow, diff)).then(() => {
- dispatch(flowsActions.updateFlow(modified_flow))
- dispatch({ type: STOP_EDIT })
- })
- }
+export function stopEdit(flow, modifiedFlow) {
+ let diff = getDiff(flow, modifiedFlow)
+ return flowsActions.update(flow, diff)
}