mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: remove redux-logger (#34220)
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
import { AnyAction, Dispatch, Middleware, MiddlewareAPI } from 'redux';
|
||||
|
||||
import { StoreState } from 'app/types/store';
|
||||
import { toggleLogActions } from '../reducers/application';
|
||||
|
||||
export const toggleLogActionsMiddleware: Middleware<{}, StoreState> = (store: MiddlewareAPI<Dispatch, StoreState>) => (
|
||||
next: Dispatch
|
||||
) => (action: AnyAction) => {
|
||||
const isLogActionsAction = action.type === toggleLogActions.type;
|
||||
if (isLogActionsAction) {
|
||||
return next(action);
|
||||
}
|
||||
|
||||
const logActionsTrue =
|
||||
window && window.location && window.location.search && window.location.search.indexOf('logActions=true') !== -1;
|
||||
const logActionsFalse =
|
||||
window && window.location && window.location.search && window.location.search.indexOf('logActions=false') !== -1;
|
||||
const logActions = store.getState().application.logActions;
|
||||
|
||||
if (logActionsTrue && !logActions) {
|
||||
store.dispatch(toggleLogActions());
|
||||
}
|
||||
|
||||
if (logActionsFalse && logActions) {
|
||||
store.dispatch(toggleLogActions());
|
||||
}
|
||||
|
||||
return next(action);
|
||||
};
|
||||
@@ -1,16 +0,0 @@
|
||||
import { reducerTester } from '../../../test/core/redux/reducerTester';
|
||||
import { applicationReducer, toggleLogActions } from './application';
|
||||
import { ApplicationState } from '../../types/application';
|
||||
|
||||
describe('applicationReducer', () => {
|
||||
describe('when toggleLogActions is dispatched', () => {
|
||||
it('then state should be correct', () => {
|
||||
reducerTester<ApplicationState>()
|
||||
.givenReducer(applicationReducer, { logActions: false })
|
||||
.whenActionIsDispatched(toggleLogActions())
|
||||
.thenStateShouldEqual({ logActions: true })
|
||||
.whenActionIsDispatched(toggleLogActions())
|
||||
.thenStateShouldEqual({ logActions: false });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import { ApplicationState } from 'app/types/application';
|
||||
|
||||
export const initialState: ApplicationState = {
|
||||
logActions: false,
|
||||
};
|
||||
|
||||
const applicationSlice = createSlice({
|
||||
name: 'application',
|
||||
initialState,
|
||||
reducers: {
|
||||
toggleLogActions: (state) => ({ ...state, logActions: !state.logActions }),
|
||||
},
|
||||
});
|
||||
|
||||
export const { toggleLogActions } = applicationSlice.actions;
|
||||
export const applicationReducer = applicationSlice.reducer;
|
||||
@@ -1,9 +1,7 @@
|
||||
import { navIndexReducer as navIndex } from './navModel';
|
||||
import { appNotificationsReducer as appNotifications } from './appNotification';
|
||||
import { applicationReducer as application } from './application';
|
||||
|
||||
export default {
|
||||
navIndex,
|
||||
appNotifications,
|
||||
application,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user