2019-02-02 15:43:19 -06:00
|
|
|
import { DashboardState, DashboardLoadingState } from 'app/types/dashboard';
|
2019-02-05 06:49:35 -06:00
|
|
|
import { loadDashboardPermissions, setDashboardLoadingState, setDashboardModel, setDashboardLoadingSlow } from './actions';
|
2019-02-02 15:43:19 -06:00
|
|
|
import { reducerFactory } from 'app/core/redux';
|
2018-09-13 09:00:02 -05:00
|
|
|
import { processAclItems } from 'app/core/utils/acl';
|
|
|
|
|
2018-10-25 09:56:49 -05:00
|
|
|
export const initialState: DashboardState = {
|
2019-02-02 15:43:19 -06:00
|
|
|
loadingState: DashboardLoadingState.NotStarted,
|
2019-02-05 06:49:35 -06:00
|
|
|
isLoadingSlow: false,
|
2019-02-02 16:01:48 -06:00
|
|
|
model: null,
|
2018-09-13 09:00:02 -05:00
|
|
|
permissions: [],
|
|
|
|
};
|
|
|
|
|
2019-02-02 15:43:19 -06:00
|
|
|
export const dashboardReducer = reducerFactory(initialState)
|
|
|
|
.addMapper({
|
|
|
|
filter: loadDashboardPermissions,
|
|
|
|
mapper: (state, action) => ({
|
|
|
|
...state,
|
|
|
|
permissions: processAclItems(action.payload),
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
.addMapper({
|
|
|
|
filter: setDashboardLoadingState,
|
|
|
|
mapper: (state, action) => ({
|
|
|
|
...state,
|
|
|
|
loadingState: action.payload
|
|
|
|
}),
|
|
|
|
})
|
2019-02-02 16:01:48 -06:00
|
|
|
.addMapper({
|
|
|
|
filter: setDashboardModel,
|
|
|
|
mapper: (state, action) => ({
|
|
|
|
...state,
|
2019-02-05 06:49:35 -06:00
|
|
|
model: action.payload,
|
|
|
|
isLoadingSlow: false,
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
.addMapper({
|
|
|
|
filter: setDashboardLoadingSlow,
|
|
|
|
mapper: (state, action) => ({
|
|
|
|
...state,
|
|
|
|
isLoadingSlow: true,
|
2019-02-02 16:01:48 -06:00
|
|
|
}),
|
|
|
|
})
|
2019-02-03 03:55:58 -06:00
|
|
|
.create();
|
2018-09-13 09:00:02 -05:00
|
|
|
|
|
|
|
export default {
|
|
|
|
dashboard: dashboardReducer,
|
|
|
|
};
|