You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
940 B
46 lines
940 B
7 years ago
|
import _ from 'lodash';
|
||
|
import getSectionState from 'Utilities/State/getSectionState';
|
||
|
import updateSectionState from 'Utilities/State/updateSectionState';
|
||
|
|
||
|
const whitelistedProperties = [
|
||
|
'isFetching',
|
||
|
'isPopulated',
|
||
|
'error',
|
||
|
'isFetchingSchema',
|
||
|
'schemaPopulated',
|
||
|
'schemaError',
|
||
|
'schema',
|
||
|
'selectedSchema',
|
||
|
'isSaving',
|
||
|
'saveError',
|
||
|
'isTesting',
|
||
|
'isDeleting',
|
||
|
'deleteError',
|
||
|
'pendingChanges',
|
||
|
'filterKey',
|
||
|
'filterValue',
|
||
|
'page',
|
||
|
'sortKey',
|
||
|
'sortDirection'
|
||
|
];
|
||
|
|
||
|
const blacklistedProperties = [
|
||
|
'section',
|
||
|
'id'
|
||
|
];
|
||
|
|
||
|
function createSetReducer(section) {
|
||
|
return (state, { payload }) => {
|
||
|
if (section === payload.section) {
|
||
|
const newState = Object.assign(getSectionState(state, section),
|
||
|
_.omit(payload, blacklistedProperties));
|
||
|
|
||
|
return updateSectionState(state, section, newState);
|
||
|
}
|
||
|
|
||
|
return state;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export default createSetReducer;
|