aboutsummaryrefslogtreecommitdiffstats
path: root/web/src
diff options
context:
space:
mode:
Diffstat (limited to 'web/src')
-rw-r--r--web/src/js/ducks/eventLog.js4
-rw-r--r--web/src/js/ducks/flows.js4
-rw-r--r--web/src/js/ducks/utils/list.js19
-rwxr-xr-xweb/src/js/ducks/utils/view.js14
-rwxr-xr-xweb/src/js/ducks/views.js5
-rwxr-xr-xweb/src/js/ducks/views/main.js10
6 files changed, 35 insertions, 21 deletions
diff --git a/web/src/js/ducks/eventLog.js b/web/src/js/ducks/eventLog.js
index b957d01b..7a4f2d5e 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: null,
- view: null,
+ list: undefined,
+ view: undefined,
}
export default function reduce(state = defaultState, action) {
diff --git a/web/src/js/ducks/flows.js b/web/src/js/ducks/flows.js
index 058e1203..f732f536 100644
--- a/web/src/js/ducks/flows.js
+++ b/web/src/js/ducks/flows.js
@@ -15,8 +15,8 @@ export const UNKNOWN_CMD = 'FLOWS_UNKNOWN_CMD'
export const FETCH_ERROR = 'FLOWS_FETCH_ERROR'
const defaultState = {
- list: null,
- views: null,
+ list: undefined,
+ views: undefined,
}
export default function reduce(state = defaultState, action) {
diff --git a/web/src/js/ducks/utils/list.js b/web/src/js/ducks/utils/list.js
index 9649dde3..e66a8549 100644
--- a/web/src/js/ducks/utils/list.js
+++ b/web/src/js/ducks/utils/list.js
@@ -11,22 +11,27 @@ const defaultState = {
}
export default function reduce(state = defaultState, action) {
- if (state.pendingActions && action.type !== RECEIVE) {
- return {
- ...state,
- pendingActions: [...state.pendingActions, action]
- }
- }
-
switch (action.type) {
case SET:
+ if (state.pendingActions) {
+ return {
+ ...state,
+ pendingActions: [...state.pendingActions, action]
+ }
+ }
return {
...state,
data: { ...state.data, [action.id]: null, [action.item.id]: action.item }
}
case CLEAR:
+ if (state.pendingActions) {
+ return {
+ ...state,
+ pendingActions: [...state.pendingActions, action]
+ }
+ }
return {
...state,
data: { ...state.data, [action.id]: null }
diff --git a/web/src/js/ducks/utils/view.js b/web/src/js/ducks/utils/view.js
index 31331cf9..3b552378 100755
--- a/web/src/js/ducks/utils/view.js
+++ b/web/src/js/ducks/utils/view.js
@@ -15,21 +15,23 @@ const defaultState = {
export default function reduce(state = defaultState, action) {
switch (action.type) {
- case UPDATE_FILTER:
+ case UPDATE_FILTER: {
const data = _.values(action.list.data).filter(action.filter).sort(action.sorter)
return {
...state,
data,
indexOf: _.fromPairs(data.map((item, index) => [item.id, index])),
}
+ }
- case UPDATE_SORTER:
- const data = state.data.slice().sort(action.sorter)
+ case UPDATE_SORTER: {
+ const data = [...state.data].sort(action.sorter)
return {
...state,
data,
indexOf: _.fromPairs(data.map((item, index) => [item.id, index]))
}
+ }
case ADD:
if (state.indexOf[action.item.id] != null || !action.filter(action.item)) {
@@ -49,7 +51,7 @@ export default function reduce(state = defaultState, action) {
...sortedRemove(state, action.id),
}
- case UPDATE:
+ case UPDATE: {
if (state.indexOf[action.item.id] == null) {
return
}
@@ -64,14 +66,16 @@ export default function reduce(state = defaultState, action) {
...nextState,
...sortedInsert(nextState, action.item, action.sorter)
}
+ }
- case RECEIVE:
+ case RECEIVE: {
const data = _.values(action.list.data).filter(action.filter).sort(action.sorter)
return {
...state,
data,
indexOf: _.fromPairs(data.map((item, index) => [item.id, index])),
}
+ }
default:
return state
diff --git a/web/src/js/ducks/views.js b/web/src/js/ducks/views.js
index 88b4d355..e1e46c2e 100755
--- a/web/src/js/ducks/views.js
+++ b/web/src/js/ducks/views.js
@@ -2,6 +2,11 @@ import { combineReducers } from 'redux'
import * as viewActions from './utils/view'
import main from './views/main.js'
+export const ADD = 'FLOW_VIEWS_ADD'
+export const UPDATE = 'FLOW_VIEWS_UPDATE'
+export const REMOVE = 'FLOW_VIEWS_REMOVE'
+export const RECEIVE = 'FLOW_VIEWS_RECEIVE'
+
export default combineReducers({
main,
})
diff --git a/web/src/js/ducks/views/main.js b/web/src/js/ducks/views/main.js
index 5e063f4b..3bcbdd01 100755
--- a/web/src/js/ducks/views/main.js
+++ b/web/src/js/ducks/views/main.js
@@ -1,10 +1,10 @@
import reduceView, * as viewActions from '../utils/list'
import * as viewsActions from '../views'
-export const UPDATE_FILTER = 'MAIN_VIEW_UPDATE_FILTER'
-export const UPDATE_SORTER = 'MAIN_VIEW_UPDATE_SORTER'
-export const UPDATE_HIGHLIGHT = 'MAIN_VIEW_UPDATE_HIGHLIGHT'
-export const SELECT = 'MAIN_VIEW_SELECT'
+export const UPDATE_FILTER = 'FLOW_VIEWS_MAIN_UPDATE_FILTER'
+export const UPDATE_SORTER = 'FLOW_VIEWS_MAIN_UPDATE_SORTER'
+export const UPDATE_HIGHLIGHT = 'FLOW_VIEWS_MAIN_UPDATE_HIGHLIGHT'
+export const SELECT = 'FLOW_VIEWS_MAIN_SELECT'
const sortKeyFuns = {
@@ -32,7 +32,7 @@ const defaultState = {
selected: [],
filter: null,
sorter: { column: null, desc: false },
- view: null,
+ view: undefined,
}
export default function reduce(state = defaultState, action) {