summaryrefslogtreecommitdiffstats
path: root/workflow/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js
diff options
context:
space:
mode:
Diffstat (limited to 'workflow/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js')
-rw-r--r--workflow/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js40
1 files changed, 19 insertions, 21 deletions
diff --git a/workflow/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js b/workflow/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js
index 9816a96f..cbd7ab70 100644
--- a/workflow/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js
+++ b/workflow/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js
@@ -15,20 +15,16 @@
*/
import {
- LIMIT,
NAME,
ASC,
- UPDATE,
- SORT
+ UPDATE_WORKFLOW,
+ RESET_WORKFLOW
} from 'features/catalog/catalogConstants';
export const initialState = {
- workflows: {
- size: LIMIT,
- page: -1,
- results: [],
- total: 0
- },
+ hasMore: true,
+ results: [],
+ total: 0,
sort: {
[NAME]: ASC
}
@@ -37,21 +33,23 @@ export const initialState = {
const catalogReducer = (state = initialState, action) => {
const { type, payload } = action;
+ let results;
+
switch (type) {
- case UPDATE:
- return {
- ...state,
- workflows: {
- ...state.workflows,
- ...payload,
- results: [...state.workflows.results, ...payload.results]
- }
- };
+ case RESET_WORKFLOW:
+ return { ...initialState, sort: state.sort };
+
+ case UPDATE_WORKFLOW:
+ results =
+ payload.page === 0
+ ? [...payload.results]
+ : [...state.results, ...payload.results];
- case SORT:
return {
- ...initialState,
- sort: { ...payload.sort }
+ ...state,
+ ...payload,
+ results,
+ hasMore: results.length < payload.total
};
default: