mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Grafana/Loki: Adds support for new Loki endpoints and metrics * Adds `/loki/` prefix to new loki endpoints and updates response interfaces * Improved legacy support * Removed changes related to plugin.json and added Loki-specific hacks * Fixes live streaming for legacy loki datasources
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { applyMiddleware, compose, createStore } from 'redux';
|
|
import thunk from 'redux-thunk';
|
|
import { createLogger } from 'redux-logger';
|
|
|
|
import { setStore } from './store';
|
|
import { StoreState } from 'app/types/store';
|
|
import { toggleLogActionsMiddleware } from 'app/core/middlewares/application';
|
|
import { addReducer, createRootReducer } from '../core/reducers/root';
|
|
import { ActionOf } from 'app/core/redux';
|
|
|
|
export function addRootReducer(reducers: any) {
|
|
// this is ok now because we add reducers before configureStore is called
|
|
// in the future if we want to add reducers during runtime
|
|
// we'll have to solve this in a more dynamic way
|
|
addReducer(reducers);
|
|
}
|
|
|
|
export function configureStore() {
|
|
const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
|
|
|
const logger = createLogger({
|
|
predicate: (getState: () => StoreState) => {
|
|
return getState().application.logActions;
|
|
},
|
|
});
|
|
const storeEnhancers =
|
|
process.env.NODE_ENV !== 'production'
|
|
? applyMiddleware(toggleLogActionsMiddleware, thunk, logger)
|
|
: applyMiddleware(thunk);
|
|
|
|
const store = createStore<StoreState, ActionOf<any>, any, any>(
|
|
createRootReducer(),
|
|
{},
|
|
composeEnhancers(storeEnhancers)
|
|
);
|
|
setStore(store);
|
|
return store;
|
|
}
|