2017-05-16 13:34:00 +02:00
|
|
|
import {LOAD_CONFIG_SUCCESS} from './actions'
|
2018-09-17 18:55:39 +02:00
|
|
|
import {LOAD_ROUTESERVERS_SUCCESS} from 'components/routeservers/actions'
|
2017-05-16 13:34:00 +02:00
|
|
|
|
|
|
|
const initialState = {
|
2018-07-05 10:30:52 +02:00
|
|
|
routes_columns: {},
|
|
|
|
routes_columns_order: [],
|
|
|
|
neighbours_columns: {},
|
|
|
|
neighbours_columns_order: [],
|
2018-08-03 12:22:10 +02:00
|
|
|
lookup_columns: {},
|
|
|
|
lookup_columns_order: [],
|
2018-06-26 16:59:01 +02:00
|
|
|
prefix_lookup_enabled: false,
|
2018-08-03 17:04:31 +02:00
|
|
|
content: {},
|
|
|
|
noexport_load_on_demand: true, // we have to assume this
|
2018-09-07 11:40:03 +02:00
|
|
|
// otherwise fetch will start.
|
2018-08-09 23:24:58 +02:00
|
|
|
bgp_communities: {},
|
2018-09-17 18:55:39 +02:00
|
|
|
|
|
|
|
blackholes: {}, // Map blackholes to routeservers
|
2018-09-17 22:33:22 +02:00
|
|
|
asns: {}, // Map ASNs to routeservers
|
2017-05-16 13:34:00 +02:00
|
|
|
};
|
|
|
|
|
2018-09-17 18:55:39 +02:00
|
|
|
const _handleRouteserversConfig = function(state, payload) {
|
|
|
|
let blackholes = {};
|
2018-09-17 22:33:22 +02:00
|
|
|
let asns = {};
|
2018-09-17 18:55:39 +02:00
|
|
|
for (const rs of payload.routeservers) {
|
|
|
|
blackholes[rs.id] = rs.blackholes;
|
2018-09-17 22:33:22 +02:00
|
|
|
asns[rs.is] = rs.asn;
|
2018-09-17 18:55:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
blackholes: blackholes,
|
2018-09-17 22:33:22 +02:00
|
|
|
asns: asns,
|
2018-09-17 18:55:39 +02:00
|
|
|
});
|
|
|
|
}
|
2017-05-16 13:34:00 +02:00
|
|
|
|
|
|
|
export default function reducer(state = initialState, action) {
|
|
|
|
switch(action.type) {
|
|
|
|
case LOAD_CONFIG_SUCCESS:
|
2018-07-05 10:30:52 +02:00
|
|
|
return Object.assign({}, state, {
|
|
|
|
routes_columns: action.payload.routes_columns,
|
|
|
|
routes_columns_order: action.payload.routes_columns_order,
|
|
|
|
|
|
|
|
neighbours_columns: action.payload.neighbours_columns,
|
|
|
|
neighbours_columns_order: action.payload.neighbours_columns_order,
|
|
|
|
|
2018-08-03 12:22:10 +02:00
|
|
|
lookup_columns: action.payload.lookup_columns,
|
|
|
|
lookup_columns_order: action.payload.lookup_columns_order,
|
|
|
|
|
2018-08-03 17:04:31 +02:00
|
|
|
prefix_lookup_enabled: action.payload.prefix_lookup_enabled,
|
|
|
|
|
2018-08-09 23:24:58 +02:00
|
|
|
bgp_communities: action.payload.bgp_communities,
|
2018-08-03 17:04:31 +02:00
|
|
|
noexport_load_on_demand: action.payload.noexport.load_on_demand
|
2018-07-05 10:30:52 +02:00
|
|
|
});
|
2018-09-17 18:55:39 +02:00
|
|
|
|
|
|
|
case LOAD_ROUTESERVERS_SUCCESS:
|
|
|
|
return _handleRouteserversConfig(state, action.payload);
|
2017-05-16 13:34:00 +02:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|