Chore: remove redux-logger (#34220)

This commit is contained in:
Zoltán Bedi 2021-05-17 16:43:40 +02:00 committed by GitHub
parent d3d4c774e6
commit e1741695ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 2 additions and 117 deletions

View File

@ -129,7 +129,6 @@
"@types/react-transition-group": "4.4.0",
"@types/react-virtualized-auto-sizer": "1.0.0",
"@types/react-window": "1.8.1",
"@types/redux-logger": "3.0.7",
"@types/redux-mock-store": "1.0.2",
"@types/reselect": "2.2.0",
"@types/semver": "^6.0.0",
@ -297,7 +296,6 @@
"react-virtualized-auto-sizer": "1.0.2",
"react-window": "1.8.5",
"redux": "4.0.5",
"redux-logger": "3.0.6",
"redux-thunk": "2.3.0",
"regenerator-runtime": "0.13.3",
"reselect": "4.0.0",

View File

@ -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);
};

View File

@ -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 });
});
});
});

View File

@ -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;

View File

@ -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,
};

View File

@ -1,9 +1,7 @@
import { configureStore as reduxConfigureStore, getDefaultMiddleware } from '@reduxjs/toolkit';
import { createLogger } from 'redux-logger';
import { ThunkMiddleware } from 'redux-thunk';
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 { buildInitialState } from '../core/reducers/navModel';
@ -15,14 +13,6 @@ export function addRootReducer(reducers: any) {
}
export function configureStore(initialState?: Partial<StoreState>) {
const logger = createLogger({
predicate: (getState) => {
return getState().application.logActions;
},
});
const middleware = process.env.NODE_ENV !== 'production' ? [toggleLogActionsMiddleware, logger] : [];
const reduxDefaultMiddleware = getDefaultMiddleware<StoreState>({
thunk: true,
serializableCheck: false,
@ -31,7 +21,7 @@ export function configureStore(initialState?: Partial<StoreState>) {
const store = reduxConfigureStore<StoreState>({
reducer: createRootReducer(),
middleware: [...reduxDefaultMiddleware, ...middleware] as [ThunkMiddleware<StoreState>],
middleware: (reduxDefaultMiddleware as unknown) as [ThunkMiddleware<StoreState>],
devTools: process.env.NODE_ENV !== 'production',
preloadedState: {
navIndex: buildInitialState(),

View File

@ -1,3 +0,0 @@
export interface ApplicationState {
logActions: boolean;
}

View File

@ -12,7 +12,6 @@ import { UserAdminState, UserListAdminState, UsersState, UserState } from './use
import { OrganizationState } from './organization';
import { AppNotificationsState } from './appNotifications';
import { PluginsState } from './plugins';
import { ApplicationState } from './application';
import { LdapState } from './ldap';
import { PanelEditorState } from '../features/dashboard/components/PanelEditor/state/reducers';
import { ApiKeysState } from './apiKeys';
@ -35,7 +34,6 @@ export interface StoreState {
appNotifications: AppNotificationsState;
user: UserState;
plugins: PluginsState;
application: ApplicationState;
ldap: LdapState;
apiKeys: ApiKeysState;
userAdmin: UserAdminState;

View File

@ -4797,13 +4797,6 @@
dependencies:
"@types/react" "*"
"@types/redux-logger@3.0.7":
version "3.0.7"
resolved "https://registry.yarnpkg.com/@types/redux-logger/-/redux-logger-3.0.7.tgz#163f6f6865c69c21d56f9356dc8d741718ec0db0"
integrity sha512-oV9qiCuowhVR/ehqUobWWkXJjohontbDGLV88Be/7T4bqMQ3kjXwkFNL7doIIqlbg3X2PC5WPziZ8/j/QHNQ4A==
dependencies:
redux "^3.6.0"
"@types/redux-mock-store@1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@types/redux-mock-store/-/redux-mock-store-1.0.2.tgz#c27d5deadfb29d8514bdb0fc2cadae6feea1922d"
@ -9022,11 +9015,6 @@ dedent@^0.7.0:
resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c"
integrity sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=
deep-diff@^0.3.5:
version "0.3.8"
resolved "https://registry.yarnpkg.com/deep-diff/-/deep-diff-0.3.8.tgz#c01de63efb0eec9798801d40c7e0dae25b582c84"
integrity sha1-wB3mPvsO7JeYgB1Ax+Da4ltYLIQ=
deep-equal@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.0.tgz#3103cdf8ab6d32cf4a8df7865458f2b8d33f3745"
@ -14446,11 +14434,6 @@ locate-path@^6.0.0:
dependencies:
p-locate "^5.0.0"
lodash-es@^4.2.1:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.15.tgz#21bd96839354412f23d7a10340e5eac6ee455d78"
integrity sha512-rlrc3yU3+JNOpZ9zj5pQtxnx2THmvRykwL4Xlxoa8I9lHBlVbbyPhgyPMioxVZ4NqyxaVVtaJnzsyOidQIhyyQ==
lodash._reinterpolate@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
@ -19084,13 +19067,6 @@ redent@^3.0.0:
indent-string "^4.0.0"
strip-indent "^3.0.0"
redux-logger@3.0.6:
version "3.0.6"
resolved "https://registry.yarnpkg.com/redux-logger/-/redux-logger-3.0.6.tgz#f7555966f3098f3c88604c449cf0baf5778274bf"
integrity sha1-91VZZvMJjzyIYExEnPC69XeCdL8=
dependencies:
deep-diff "^0.3.5"
redux-mock-store@1.5.4:
version "1.5.4"
resolved "https://registry.yarnpkg.com/redux-mock-store/-/redux-mock-store-1.5.4.tgz#90d02495fd918ddbaa96b83aef626287c9ab5872"
@ -19111,16 +19087,6 @@ redux@4.0.5, redux@^4.0.0, redux@^4.0.4, redux@^4.0.5:
loose-envify "^1.4.0"
symbol-observable "^1.2.0"
redux@^3.6.0:
version "3.7.2"
resolved "https://registry.yarnpkg.com/redux/-/redux-3.7.2.tgz#06b73123215901d25d065be342eb026bc1c8537b"
integrity sha512-pNqnf9q1hI5HHZRBkj3bAngGZW/JMCmexDlOxw4XagXY2o1327nHH54LoTjiPJ0gizoqPDRqWyX/00g0hD6w+A==
dependencies:
lodash "^4.2.1"
lodash-es "^4.2.1"
loose-envify "^1.1.0"
symbol-observable "^1.0.3"
reflect.ownkeys@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/reflect.ownkeys/-/reflect.ownkeys-0.2.0.tgz#749aceec7f3fdf8b63f927a04809e90c5c0b3460"
@ -21081,7 +21047,7 @@ svgo@^1.0.0:
unquote "~1.1.1"
util.promisify "~1.0.0"
symbol-observable@^1.0.3, symbol-observable@^1.0.4, symbol-observable@^1.1.0, symbol-observable@^1.2.0:
symbol-observable@^1.0.4, symbol-observable@^1.1.0, symbol-observable@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==