2019-05-30 15:26:19 +01:00
|
|
|
import { handleActions } from 'redux-actions';
|
|
|
|
|
|
|
|
import * as actions from '../actions/access';
|
|
|
|
|
|
|
|
const access = handleActions(
|
|
|
|
{
|
|
|
|
[actions.getAccessListRequest]: state => ({ ...state, processing: true }),
|
|
|
|
[actions.getAccessListFailure]: state => ({ ...state, processing: false }),
|
|
|
|
[actions.getAccessListSuccess]: (state, { payload }) => {
|
|
|
|
const {
|
|
|
|
allowed_clients,
|
|
|
|
disallowed_clients,
|
|
|
|
blocked_hosts,
|
|
|
|
} = payload;
|
|
|
|
const newState = {
|
|
|
|
...state,
|
2019-06-03 14:39:02 +01:00
|
|
|
allowed_clients: (allowed_clients && allowed_clients.join('\n')) || '',
|
|
|
|
disallowed_clients: (disallowed_clients && disallowed_clients.join('\n')) || '',
|
|
|
|
blocked_hosts: (blocked_hosts && blocked_hosts.join('\n')) || '',
|
2019-06-03 14:08:50 +01:00
|
|
|
processing: false,
|
2019-05-30 15:26:19 +01:00
|
|
|
};
|
|
|
|
return newState;
|
|
|
|
},
|
|
|
|
|
|
|
|
[actions.setAccessListRequest]: state => ({ ...state, processingSet: true }),
|
|
|
|
[actions.setAccessListFailure]: state => ({ ...state, processingSet: false }),
|
|
|
|
[actions.setAccessListSuccess]: (state) => {
|
|
|
|
const newState = {
|
|
|
|
...state,
|
|
|
|
processingSet: false,
|
|
|
|
};
|
|
|
|
return newState;
|
|
|
|
},
|
2020-01-30 10:58:54 +00:00
|
|
|
|
|
|
|
[actions.toggleClientBlockRequest]: state => ({ ...state, processingSet: true }),
|
|
|
|
[actions.toggleClientBlockFailure]: state => ({ ...state, processingSet: false }),
|
2020-02-04 12:48:07 +00:00
|
|
|
[actions.toggleClientBlockSuccess]: (state, { payload }) => {
|
|
|
|
const {
|
|
|
|
allowed_clients,
|
|
|
|
disallowed_clients,
|
|
|
|
blocked_hosts,
|
|
|
|
} = payload;
|
|
|
|
const newState = {
|
|
|
|
...state,
|
|
|
|
allowed_clients: (allowed_clients && allowed_clients.join('\n')) || '',
|
|
|
|
disallowed_clients: (disallowed_clients && disallowed_clients.join('\n')) || '',
|
|
|
|
blocked_hosts: (blocked_hosts && blocked_hosts.join('\n')) || '',
|
|
|
|
processingSet: false,
|
|
|
|
};
|
|
|
|
return newState;
|
|
|
|
},
|
2019-05-30 15:26:19 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
processing: true,
|
|
|
|
processingSet: false,
|
2019-06-03 14:39:02 +01:00
|
|
|
allowed_clients: '',
|
|
|
|
disallowed_clients: '',
|
|
|
|
blocked_hosts: '',
|
2019-05-30 15:26:19 +01:00
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
export default access;
|