Updates #1577
Squashed commit of the following:
commit a07ff51fb3f1eb58ab9a922d7bc11ed1d65ef3a7
Merge: 7db696814 2f515e8d8
Author: Ildar Kamalov <ik@adguard.com>
Date: Fri Jun 23 16:50:09 2023 +0300
Merge branch 'master' into AG-22207
commit 7db696814f2134fd3a3415cbcfa0ffdac1fabda3
Author: Ildar Kamalov <ik@adguard.com>
Date: Fri Jun 23 14:57:09 2023 +0300
fix changelog
commit bf9458b3f18697ca1fc504c51fa443934f76371f
Author: Ildar Kamalov <ik@adguard.com>
Date: Fri Jun 23 14:48:20 2023 +0300
changelog
commit bc2bf3f9507957afe63a654334b6e22858d1e41b
Author: Ildar Kamalov <ik@adguard.com>
Date: Fri Jun 23 13:28:28 2023 +0300
client: handle rewrite edit
74 lines
2.4 KiB
JavaScript
74 lines
2.4 KiB
JavaScript
import { handleActions } from 'redux-actions';
|
|
|
|
import * as actions from '../actions/rewrites';
|
|
|
|
const rewrites = handleActions(
|
|
{
|
|
[actions.getRewritesListRequest]: (state) => ({ ...state, processing: true }),
|
|
[actions.getRewritesListFailure]: (state) => ({ ...state, processing: false }),
|
|
[actions.getRewritesListSuccess]: (state, { payload }) => {
|
|
const newState = {
|
|
...state,
|
|
list: payload,
|
|
processing: false,
|
|
};
|
|
return newState;
|
|
},
|
|
|
|
[actions.addRewriteRequest]: (state) => ({ ...state, processingAdd: true }),
|
|
[actions.addRewriteFailure]: (state) => ({ ...state, processingAdd: false }),
|
|
[actions.addRewriteSuccess]: (state, { payload }) => {
|
|
const newState = {
|
|
...state,
|
|
list: [...state.list, payload],
|
|
processingAdd: false,
|
|
};
|
|
return newState;
|
|
},
|
|
|
|
[actions.deleteRewriteRequest]: (state) => ({ ...state, processingDelete: true }),
|
|
[actions.deleteRewriteFailure]: (state) => ({ ...state, processingDelete: false }),
|
|
[actions.deleteRewriteSuccess]: (state) => ({ ...state, processingDelete: false }),
|
|
|
|
[actions.updateRewriteRequest]: (state) => ({ ...state, processingUpdate: true }),
|
|
[actions.updateRewriteFailure]: (state) => ({ ...state, processingUpdate: false }),
|
|
[actions.updateRewriteSuccess]: (state) => {
|
|
const newState = {
|
|
...state,
|
|
processingUpdate: false,
|
|
};
|
|
return newState;
|
|
},
|
|
|
|
[actions.toggleRewritesModal]: (state, { payload }) => {
|
|
if (payload) {
|
|
const newState = {
|
|
...state,
|
|
modalType: payload.type || '',
|
|
isModalOpen: !state.isModalOpen,
|
|
currentRewrite: payload.currentRewrite,
|
|
};
|
|
return newState;
|
|
}
|
|
|
|
const newState = {
|
|
...state,
|
|
isModalOpen: !state.isModalOpen,
|
|
};
|
|
return newState;
|
|
},
|
|
},
|
|
{
|
|
processing: true,
|
|
processingAdd: false,
|
|
processingDelete: false,
|
|
processingUpdate: false,
|
|
isModalOpen: false,
|
|
modalType: '',
|
|
currentRewrite: {},
|
|
list: [],
|
|
},
|
|
);
|
|
|
|
export default rewrites;
|