fleet/frontend/redux/nodes/components/ManageHostsPage/reducer.js
Mike Stone 630ba45448 756 status labels (#967)
* API client to get status label summary

* Handle status label counts in state

* Display status counts in hosts side panel
2017-01-16 15:59:01 -05:00

55 lines
1.1 KiB
JavaScript

import {
GET_STATUS_LABEL_COUNTS_FAILURE,
GET_STATUS_LABEL_COUNTS_SUCCESS,
LOAD_STATUS_LABEL_COUNTS,
SET_DISPLAY,
} from './actions';
export const initialState = {
display: 'Grid',
status_labels: {
errors: {},
loading_counts: false,
online_count: 0,
offline_count: 0,
mia_count: 0,
},
};
export default (state = initialState, { type, payload }) => {
switch (type) {
case GET_STATUS_LABEL_COUNTS_FAILURE:
return {
...state,
status_labels: {
...state.status_labels,
errors: payload.errors,
loading_counts: false,
},
};
case GET_STATUS_LABEL_COUNTS_SUCCESS:
return {
...state,
status_labels: {
...payload.status_labels,
errors: {},
loading_counts: false,
},
};
case LOAD_STATUS_LABEL_COUNTS:
return {
...state,
status_labels: {
...state.status_labels,
loading_counts: true,
},
};
case SET_DISPLAY:
return {
...state,
display: payload.display,
};
default:
return state;
}
};