aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/ducks/ui/flow.js
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-08-13 10:27:53 -0700
committerGitHub <noreply@github.com>2016-08-13 10:27:53 -0700
commitb39c6e08832cecedc95047b00280c2240461f83b (patch)
treed6230b65e9f487568f0714bc940af2f13183a39c /web/src/js/ducks/ui/flow.js
parent9da55e20477f10155fb79ba66fdc21cca760e40d (diff)
parent8b43972b95f002e8a5d8a85b7a53f43f16711362 (diff)
downloadmitmproxy-b39c6e08832cecedc95047b00280c2240461f83b.tar.gz
mitmproxy-b39c6e08832cecedc95047b00280c2240461f83b.tar.bz2
mitmproxy-b39c6e08832cecedc95047b00280c2240461f83b.zip
Merge pull request #1441 from mitmproxy/integrate_mitmproxy_contentviews
Integrate mitmproxy contentviews
Diffstat (limited to 'web/src/js/ducks/ui/flow.js')
-rw-r--r--web/src/js/ducks/ui/flow.js67
1 files changed, 60 insertions, 7 deletions
diff --git a/web/src/js/ducks/ui/flow.js b/web/src/js/ducks/ui/flow.js
index c9435676..fb2a846d 100644
--- a/web/src/js/ducks/ui/flow.js
+++ b/web/src/js/ducks/ui/flow.js
@@ -3,28 +3,38 @@ import { getDiff } from "../../utils"
import _ from 'lodash'
-export const SET_CONTENT_VIEW = 'UI_FLOWVIEW_SET_CONTENT_VIEW',
- DISPLAY_LARGE = 'UI_FLOWVIEW_DISPLAY_LARGE',
- SET_TAB = "UI_FLOWVIEW_SET_TAB",
- START_EDIT = 'UI_FLOWVIEW_START_EDIT',
- UPDATE_EDIT = 'UI_FLOWVIEW_UPDATE_EDIT',
- UPLOAD_CONTENT = 'UI_FLOWVIEW_UPLOAD_CONTENT'
+export const SET_CONTENT_VIEW = 'UI_FLOWVIEW_SET_CONTENT_VIEW',
+ DISPLAY_LARGE = 'UI_FLOWVIEW_DISPLAY_LARGE',
+ SET_TAB = "UI_FLOWVIEW_SET_TAB",
+ START_EDIT = 'UI_FLOWVIEW_START_EDIT',
+ UPDATE_EDIT = 'UI_FLOWVIEW_UPDATE_EDIT',
+ UPLOAD_CONTENT = 'UI_FLOWVIEW_UPLOAD_CONTENT',
+ SET_SHOW_FULL_CONTENT = 'UI_SET_SHOW_FULL_CONTENT',
+ SET_CONTENT_VIEW_DESCRIPTION = "UI_SET_CONTENT_VIEW_DESCRIPTION",
+ SET_CONTENT = "UI_SET_CONTENT"
const defaultState = {
displayLarge: false,
+ contentViewDescription: '',
+ showFullContent: false,
modifiedFlow: false,
- contentView: 'ViewAuto',
+ contentView: 'Auto',
tab: 'request',
+ content: [],
+ maxContentLines: 80,
}
export default function reducer(state = defaultState, action) {
+ let wasInEditMode = !!(state.modifiedFlow)
switch (action.type) {
case START_EDIT:
return {
...state,
modifiedFlow: action.flow,
+ contentView: 'Edit',
+ showFullContent: true
}
case UPDATE_EDIT:
@@ -38,6 +48,9 @@ export default function reducer(state = defaultState, action) {
...state,
modifiedFlow: false,
displayLarge: false,
+ contentView: (wasInEditMode ? 'Auto' : state.contentView),
+ viewDescription: '',
+ showFullContent: false,
}
case flowsActions.UPDATE:
@@ -49,23 +62,47 @@ export default function reducer(state = defaultState, action) {
...state,
modifiedFlow: false,
displayLarge: false,
+ contentView: (wasInEditMode ? 'Auto' : state.contentView),
+ viewDescription: '',
+ showFullContent: false
}
} else {
return state
}
+ case SET_CONTENT_VIEW_DESCRIPTION:
+ return {
+ ...state,
+ viewDescription: action.description
+ }
+
+ case SET_SHOW_FULL_CONTENT:
+ return {
+ ...state,
+ showFullContent: action.show
+ }
case SET_TAB:
return {
...state,
tab: action.tab,
displayLarge: false,
+ showFullContent: false
}
case SET_CONTENT_VIEW:
return {
...state,
contentView: action.contentView,
+ showFullContent: action.contentView == 'Edit'
+ }
+
+ case SET_CONTENT:
+ let isFullContentShown = action.content.length < state.maxContentLines
+ return {
+ ...state,
+ content: action.content,
+ showFullContent: isFullContentShown
}
case DISPLAY_LARGE:
@@ -98,6 +135,22 @@ export function updateEdit(update) {
return { type: UPDATE_EDIT, update }
}
+export function setContentViewDescription(description) {
+ return { type: SET_CONTENT_VIEW_DESCRIPTION, description }
+}
+
+export function setShowFullContent(show) {
+ return { type: SET_SHOW_FULL_CONTENT, show }
+}
+
+export function updateEdit(update) {
+ return { type: UPDATE_EDIT, update }
+}
+
+export function setContent(content){
+ return { type: SET_CONTENT, content}
+}
+
export function stopEdit(flow, modifiedFlow) {
let diff = getDiff(flow, modifiedFlow)
return flowsActions.update(flow, diff)