Commit 2c07a995 authored by Maxime Chaillet's avatar Maxime Chaillet

refresh all tabs when the redux store is updated.

parent 122b9475
......@@ -42,12 +42,9 @@ class App extends Component {
<Route exact path="/investigation/:investigationId/events" component={EventsPage} />
<Route exact path="/investigation/:investigationId/camera" component={CameraPage} />
<Route exact path="/selection" component={SelectionPage} />
<Route exact path="/selection/mint" component={MintSelectionPage} />
<Footer></Footer>
</div>
</Router>
......@@ -56,8 +53,6 @@ class App extends Component {
}
class DOIPage extends React.Component {
render() {
return (
......@@ -225,7 +220,6 @@ class OpenDataPage extends React.Component {
</div>
);
}
}
......
......@@ -60,7 +60,7 @@ class EventList extends React.Component {
<tbody>
{this.getItems().map((event, index) => {
if (event.type === "date") {
return <tr key={index}><td style={{ borderTop: '1px solid #f2f2f2', textAlign: 'center', fontSize: '18px', fontWeight: 'bold' }} colSpan={4} ><a name={event.anchor}></a> {event.text}</td></tr>;
return <tr key={index}><td style={{ borderTop: '1px solid #f2f2f2', textAlign: 'center', fontSize: '18px', fontWeight: 'bold' }} colSpan={5} ><a name={event.anchor}></a> {event.text}</td></tr>;
}
return <Event key={index} availableTags={this.props.availableTags} event={event} onEventClicked={this.props.onEventClicked} ></Event>
})}
......@@ -108,16 +108,10 @@ class Event extends React.Component {
if (event && event.tag && event.tag.length !== 0) {
event.tag.forEach(tagId => {
let tag = _.find(this.props.availableTags, (availableTag) => _.isEqual(availableTag._id, tagId))
if (tag) {
eventTags.push(tag);
}
if (tag) { eventTags.push(tag); };
});
debugger;
return eventTags;
}
debugger;
return null;
}
......@@ -130,7 +124,6 @@ class Event extends React.Component {
return <tr key={index} id='contentDocList'>
<td style={{ width: '16px', borderTop: '0' }}>
<EventIcon event={event} />
</td>
<td style={{ width: '16px', borderTop: '0', borderRight: '1px solid #f2f2f2' }}>
<OverlayTrigger placement="right" overlay={<Tooltip id="tooltip"> <p> Events created on {Moment(getOriginalEvent(event).creationDate).format("MMMM Do YYYY, h:mm:ss a")} </p> </Tooltip>}>
......@@ -141,7 +134,7 @@ class Event extends React.Component {
<LazyContentEvent event={event} />
{event.events && this.state.collapsed ? <Label style={{ color: "blue", backgroundColor: "white", cursor: "pointer" }} onClick={this.handleClick} >.... {event.events.length} command lines more</Label> : null}
</td>
<td style={{ width:'200px', border: 0 }}>
<td style={{ width: '200px', border: 0 }}>
<TagListInLine tags={this.getTags(event)} />
</td>
<td style={{ width: '50px', border: 0 }}>
......
......@@ -68,6 +68,7 @@ export class LogbookContainer extends React.Component {
}
render() {
debugger;
const { investigationId, user } = this.props;
const selectionFilter = getSelectionFiltersForMongoQuery(this.state.userSearchCriteria, this.state.sortingFilter, this.state.view);
......
......@@ -3,9 +3,10 @@ import { render } from 'react-dom';
import { PersistGate } from 'redux-persist/integration/react';
import { createStore, applyMiddleware } from 'redux';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import { KEY_PREFIX, REHYDRATE } from 'redux-persist/lib/constants'
import storage from 'redux-persist/lib/storage'; // localstorage
import { Provider } from 'react-redux';
import logger from 'redux-logger';
import logger from 'redux-logger';
import thunk from 'redux-thunk';
import reducer from './reducers';
import promise from "redux-promise-middleware";
......@@ -13,39 +14,84 @@ import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
const middleware = [ thunk ];
const middleware = [thunk];
const persistConfig = {
key: 'root',
storage,
key: 'root',
storage,
}
const persistedReducer = persistReducer(persistConfig, reducer)
const store = createStore(
persistedReducer,
applyMiddleware(...middleware, logger, promise(), thunk)
persistedReducer,
applyMiddleware(...middleware, logger, promise(), thunk)
)
const persistor = persistStore(store)
// Extracted from reat-persist-crosstab https://github.com/rt2zz/redux-persist-crosstab/blob/v4.0.0-0/index.js
function crosstabSync(store, persistConfig, crosstabConfig = {}) {
const blacklist = crosstabConfig.blacklist || null
const whitelist = crosstabConfig.whitelist || null
const keyPrefix = crosstabConfig.keyPrefix || KEY_PREFIX
const { key } = persistConfig
window.addEventListener('storage', handleStorageEvent, false)
function handleStorageEvent(e) {
if (e.key && e.key.indexOf(keyPrefix) === 0) {
if (e.oldValue === e.newValue) {
return
}
const statePartial = JSON.parse(e.newValue)
/* eslint-disable flowtype/no-weak-types */
const state = Object.keys(statePartial).reduce((state, reducerKey) => {
/* eslint-enable flowtype/no-weak-types */
if (whitelist && whitelist.indexOf(reducerKey) === -1) {
return state
}
if (blacklist && blacklist.indexOf(reducerKey) !== -1) {
return state
}
state[reducerKey] = JSON.parse(statePartial[reducerKey])
return state
}, {})
store.dispatch({
key,
payload: state,
type: REHYDRATE,
})
}
}
}
crosstabSync(store, persistConfig)
render(
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<App />
</PersistGate>
</Provider>,
document.getElementById('root')
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<App />
</PersistGate>
</Provider>,
document.getElementById('root')
)
registerServiceWorker();
store.subscribe(() => {
store.subscribe(() => {
})
store.dispatch((dispatch) => {
store.dispatch((dispatch) => {
//dispatch({type: "APPEND_BREADCRUMB", breadcrumbs: {name : "home", link: "/test"}});
//dispatch({type: LOGGED_IN, username: "reader", sessionId: "23432aasdfa"});
//dispatch({type: LOGGED_IN, username: "reader", sessionId: "23432aasdfa"});
}
}
)
......@@ -16,7 +16,6 @@ const logbookReducer = (state = initialState, action) => {
case SET_AVAILABLE_TAGS: {
state = {
...state,
availableTags: action.payload,
availableTagsReceptionStatus: FETCHED_STATUS
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment