diff --git a/openbis_ng_ui/src/js/components/AppController.js b/openbis_ng_ui/src/js/components/AppController.js index 1d84b4353fcbff0548bdf6c1a7fa733a398a8376..34e2ef349b0801ec6e71c69b42e14c5fc7fe634e 100644 --- a/openbis_ng_ui/src/js/components/AppController.js +++ b/openbis_ng_ui/src/js/components/AppController.js @@ -1,6 +1,6 @@ import React from 'react' -class AppController { +export class AppController { constructor() { this.LastObjectModificationsContext = React.createContext() } @@ -61,4 +61,14 @@ class AppController { } } -export default new AppController() +let INSTANCE = new AppController() + +export function setInstance(instance) { + INSTANCE = instance +} + +export function getInstance() { + return INSTANCE +} + +export default INSTANCE diff --git a/openbis_ng_ui/src/js/store/actions/app.js b/openbis_ng_ui/src/js/store/actions/app.js index 53cc8818a1cf335dca94a6a0a9c13451f337865f..aacb241ce5aac25d7f1c9f0576a1e2414aee55f9 100644 --- a/openbis_ng_ui/src/js/store/actions/app.js +++ b/openbis_ng_ui/src/js/store/actions/app.js @@ -14,7 +14,6 @@ const SET_SEARCH = 'SET_SEARCH' const SET_SESSION = 'SET_SESSION' const SET_ERROR = 'SET_ERROR' const SET_ROUTE = 'SET_ROUTE' -const SET_LAST_OBJECT_MODIFICATION = 'SET_LAST_OBJECT_MODIFICATION' const init = () => ({ type: INIT @@ -123,15 +122,6 @@ const setRoute = route => ({ } }) -const setLastObjectModification = (type, operation, timestamp) => ({ - type: SET_LAST_OBJECT_MODIFICATION, - payload: { - type, - operation, - timestamp - } -}) - export default { INIT, CLEAR, @@ -149,7 +139,6 @@ export default { SET_SESSION, SET_ERROR, SET_ROUTE, - SET_LAST_OBJECT_MODIFICATION, init, clear, login, @@ -165,6 +154,5 @@ export default { setSearch, setSession, setError, - setRoute, - setLastObjectModification + setRoute } diff --git a/openbis_ng_ui/src/js/store/reducers/db/db.js b/openbis_ng_ui/src/js/store/reducers/db/db.js deleted file mode 100644 index 4f3e6eba01ce5544532b0ed8eb077f9c1f83406b..0000000000000000000000000000000000000000 --- a/openbis_ng_ui/src/js/store/reducers/db/db.js +++ /dev/null @@ -1,29 +0,0 @@ -import { combineReducers } from 'redux' -import actions from '@src/js/store/actions/actions.js' - -export default combineReducers({ - lastObjectModifications -}) - -function lastObjectModifications(state = {}, action) { - switch (action.type) { - case actions.SET_LAST_OBJECT_MODIFICATION: { - const { type, operation, timestamp } = action.payload - if ( - !state[type] || - !state[type][operation] || - state[type][operation] < timestamp - ) { - return { - ...state, - [type]: { ...state[type], [operation]: timestamp } - } - } else { - return state - } - } - default: { - return state - } - } -} diff --git a/openbis_ng_ui/src/js/store/reducers/reducers.js b/openbis_ng_ui/src/js/store/reducers/reducers.js index 32c1f6454ada6c43b5f0ae007b6bb86ccedf3ab6..90bf93921ed5d6dc9d5e9574385677ee78e4a38a 100644 --- a/openbis_ng_ui/src/js/store/reducers/reducers.js +++ b/openbis_ng_ui/src/js/store/reducers/reducers.js @@ -1,6 +1,5 @@ import { combineReducers } from 'redux' import actions from '@src/js/store/actions/actions.js' -import db from '@src/js/store/reducers/db/db.js' import ui from '@src/js/store/reducers/ui/ui.js' import session from '@src/js/store/reducers/session/session.js' import route from '@src/js/store/reducers/route/route.js' @@ -13,7 +12,6 @@ export default function root(state = {}, action) { } return combineReducers({ initialized, - db, ui, session, route diff --git a/openbis_ng_ui/src/js/store/selectors/app.js b/openbis_ng_ui/src/js/store/selectors/app.js index 4615fd1cfc39fb17354f6b1265ccc129246dfc98..662fd1712a74f49c4ace029797a09210d1e349dc 100644 --- a/openbis_ng_ui/src/js/store/selectors/app.js +++ b/openbis_ng_ui/src/js/store/selectors/app.js @@ -29,10 +29,6 @@ const getSession = state => { return state.session } -const getLastObjectModifications = state => { - return state.db.lastObjectModifications -} - export default { getInitialized, getLoading, @@ -40,6 +36,5 @@ export default { getRoute, getCurrentPage, getError, - getSession, - getLastObjectModifications + getSession } diff --git a/openbis_ng_ui/srcTest/js/components/common/ComponentTest.js b/openbis_ng_ui/srcTest/js/components/common/ComponentTest.js index c1ba7f33f0cb0a11101e394bfb44d1212f74ef19..6ac9170d685a34b39108f052dc6c20f63b7afb0a 100644 --- a/openbis_ng_ui/srcTest/js/components/common/ComponentTest.js +++ b/openbis_ng_ui/srcTest/js/components/common/ComponentTest.js @@ -2,6 +2,8 @@ import React from 'react' import { Provider } from 'react-redux' import { mount } from 'enzyme' import { createStore } from '@src/js/store/store.js' +import AppController from '@src/js/components/AppController.js' +import ComponentContext from '@srcTest/js/components/common/ComponentContext.js' import ThemeProvider from '@srcTest/js/components/common/theme/ThemeProvider.jsx' import openbis from '@srcTest/js/services/openbis.js' import actions from '@src/js/store/actions/actions.js' @@ -23,6 +25,8 @@ export default class ComponentTest { async mount() { document.body.innerHTML = '<div></div>' + AppController.init(new ComponentContext()) + const reactWrapper = mount( <Provider store={this.getStore()}> <ThemeProvider>