diff options
Diffstat (limited to 'web/src/js/ducks')
-rw-r--r-- | web/src/js/ducks/eventLog.js | 15 | ||||
-rw-r--r-- | web/src/js/ducks/flows.js | 6 | ||||
-rw-r--r-- | web/src/js/ducks/utils/list.js | 5 | ||||
-rw-r--r-- | web/src/js/ducks/websocket.js | 4 |
4 files changed, 13 insertions, 17 deletions
diff --git a/web/src/js/ducks/eventLog.js b/web/src/js/ducks/eventLog.js index 50b24cd6..52eec1cd 100644 --- a/web/src/js/ducks/eventLog.js +++ b/web/src/js/ducks/eventLog.js @@ -17,8 +17,8 @@ const defaultState = { logId: 0, visible: false, filters: { debug: false, info: true, web: true }, - list: undefined, - view: undefined, + list: reduceList(undefined, {}), + view: reduceView(undefined, {}), } export default function reduce(state = defaultState, action) { @@ -40,7 +40,7 @@ export default function reduce(state = defaultState, action) { case ADD: const item = { - id: `log-${state.logId}`, + id: state.logId, message: action.message, level: action.level, } @@ -52,19 +52,14 @@ export default function reduce(state = defaultState, action) { } case RECEIVE: - const list = reduceList(state.list, listActions.receive(action.list)) return { ...state, - list, + list: reduceList(state.list, listActions.receive(action.list)), view: reduceView(state.view, viewActions.receive(list, log => state.filters[log.level])), } default: - return { - ...state, - list: reduceList(state.list, action), - view: reduceView(state.view, action), - } + return state } } diff --git a/web/src/js/ducks/flows.js b/web/src/js/ducks/flows.js index fc6b3f8c..f0b09530 100644 --- a/web/src/js/ducks/flows.js +++ b/web/src/js/ducks/flows.js @@ -112,8 +112,8 @@ export function revert(flow) { /** * @public */ -export function update(flow, body) { - fetchApi.put(`/flows/${flow.id}`, body) +export function update(flow, data) { + fetchApi.put(`/flows/${flow.id}`, data) return { type: REQUEST_ACTION } } @@ -139,7 +139,7 @@ export function download() { export function upload(file) { const body = new FormData() body.append('file', file) - fetchApi('/flows/dump', { method: 'post', body }) + fetchApi('/flows/dump', { method: 'post', body }) return { type: REQUEST_ACTION } } diff --git a/web/src/js/ducks/utils/list.js b/web/src/js/ducks/utils/list.js index a93b2d45..71042d91 100644 --- a/web/src/js/ducks/utils/list.js +++ b/web/src/js/ducks/utils/list.js @@ -26,6 +26,7 @@ export default function reduce(state = defaultState, action) { const data = [...state.data] const index = state.indexOf[action.id] + // FIXME: We should just swallow this if (index == null) { throw new Error('Item not found') } @@ -35,8 +36,7 @@ export default function reduce(state = defaultState, action) { return { ...state, data, - byId: { ...state.byId, [action.id]: null, [action.item.id]: action.item }, - indexOf: { ...state.indexOf, [action.id]: null, [action.item.id]: index }, + byId: { ...state.byId, [action.item.id]: action.item }, } } @@ -45,6 +45,7 @@ export default function reduce(state = defaultState, action) { const indexOf = { ...state.indexOf } const index = indexOf[action.id] + // FIXME: We should just swallow this if (index == null) { throw new Error('Item not found') } diff --git a/web/src/js/ducks/websocket.js b/web/src/js/ducks/websocket.js index aa0d7f7d..5ba7baef 100644 --- a/web/src/js/ducks/websocket.js +++ b/web/src/js/ducks/websocket.js @@ -79,7 +79,7 @@ export function onMessage(msg) { export function onDisconnect() { return dispatch => { - dispatch(eventLogActions.addLogEntry('WebSocket connection closed.')) + dispatch(eventLogActions.add('WebSocket connection closed.')) dispatch({ type: DISCONNECTED }) } } @@ -87,7 +87,7 @@ export function onDisconnect() { export function onError(error) { // @todo let event log subscribe WebSocketActions.ERROR return dispatch => { - dispatch(eventLogActions.addLogEntry('WebSocket connection error.')) + dispatch(eventLogActions.add('WebSocket connection error.')) dispatch({ type: ERROR, error }) } } |