Skip to content

Commit f748346

Browse files
author
Martin Krulis
committed
Major redesign of routing-related internals (aggregated in one commit, it cannot be helped). Webapp updated to use react-router v4. Router is no longer interconnected with Redux. Routes and links have centralized declaration in routes.js. Language was removed from URLs (now it is stored in cookies + local storage). Async loads are now performed strictly on pages and root App component (when performing SSR).
1 parent 95f483e commit f748346

File tree

109 files changed

+1485
-1254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1485
-1254
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@
7777
"react-intl": "2.4.0",
7878
"react-motion": "^0.5.2",
7979
"react-redux": "^7.1.0",
80-
"react-responsive": "^1.1.3",
81-
"react-router": "3.2.3",
82-
"react-router-bootstrap": "^0.23.3",
83-
"react-router-redux": "^4.0.8",
80+
"react-responsive": "^7.0.0",
81+
"react-router": "^5.0.1",
82+
"react-router-dom": "^5.0.1",
83+
"react-router-bootstrap": "^0.25.0",
8484
"react-toggle": "4.0.2",
8585
"redux": "^4.0.4",
8686
"redux-actions": "^2.6.5",

src/client.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ import 'isomorphic-fetch';
33
import React from 'react';
44
import { render } from 'react-dom';
55
import { fromJS } from 'immutable';
6-
76
import { Provider } from 'react-redux';
8-
import { Router, useRouterHistory } from 'react-router';
9-
import { syncHistoryWithStore } from 'react-router-redux';
10-
import useScroll from 'scroll-behavior/lib/useStandardScroll';
11-
import createBrowserHistory from 'history/lib/createBrowserHistory';
7+
import { BrowserRouter } from 'react-router-dom';
128

139
import { configureStore } from './redux/store';
14-
import createRoutes from './pages/routes';
15-
16-
import { getToken } from './redux/middleware/authMiddleware';
10+
import { getToken, getInstanceId } from './redux/middleware/authMiddleware';
11+
import { getLang } from './redux/middleware/langMiddleware';
12+
import App from './containers/App';
1713

1814
// load the initial state form the server - if any
1915
let state;
@@ -22,18 +18,17 @@ const blacklist = ['userSwitching'];
2218
if (ini) {
2319
state = {};
2420
Object.keys(ini).map(key => {
25-
state[key] = blacklist.indexOf(key) >= 0 ? ini[key] : fromJS(ini[key]);
21+
state[key] = blacklist.includes(key) ? ini[key] : fromJS(ini[key]);
2622
});
2723
}
2824

29-
const createScrollHistory = useScroll(createBrowserHistory);
30-
const appHistory = useRouterHistory(createScrollHistory)();
31-
const store = configureStore(appHistory, state, getToken());
32-
const history = syncHistoryWithStore(appHistory, store);
25+
const store = configureStore(state, getToken(), getInstanceId(), getLang());
3326

3427
render(
3528
<Provider store={store}>
36-
<Router history={history} routes={createRoutes(store.getState)} />
29+
<BrowserRouter>
30+
<App />
31+
</BrowserRouter>
3732
</Provider>,
3833
document.getElementById('root')
3934
);

src/components/Assignments/Assignment/AssignmentTableRow/AssignmentTableRow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { Link } from 'react-router';
3+
import { Link } from 'react-router-dom';
44
import AssignmentStatusIcon from '../AssignmentStatusIcon/AssignmentStatusIcon';
55
import { FormattedMessage, intlShape, injectIntl } from 'react-intl';
66
import { LinkContainer } from 'react-router-bootstrap';

src/components/Assignments/ShadowAssignment/ShadowAssignmentsTable/ShadowAssignmentsTableRow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { Link } from 'react-router';
3+
import { Link } from 'react-router-dom';
44
import { FormattedMessage, FormattedNumber } from 'react-intl';
55
import { LinkContainer } from 'react-router-bootstrap';
66
import { defaultMemoize } from 'reselect';

src/components/Assignments/SolutionsTable/SolutionsTableRow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { FormattedMessage, FormattedNumber, injectIntl, intlShape } from 'react-intl';
4-
import { Link } from 'react-router';
4+
import { Link } from 'react-router-dom';
55
import { OverlayTrigger, Tooltip } from 'react-bootstrap';
66
import classnames from 'classnames';
77

src/components/Exercises/ExerciseDetail/ExerciseDetail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { FormattedMessage, FormattedNumber } from 'react-intl';
44
import { Table } from 'react-bootstrap';
5-
import { Link } from 'react-router';
5+
import { Link } from 'react-router-dom';
66

77
import Box from '../../widgets/Box';
88
import Markdown from '../../widgets/Markdown';

src/components/Exercises/ExercisesListItem/ExercisesListItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { FormattedMessage } from 'react-intl';
44
import { LinkContainer } from 'react-router-bootstrap';
5-
import { Link } from 'react-router';
5+
import { Link } from 'react-router-dom';
66

77
import DifficultyIcon from '../DifficultyIcon';
88
import UsersNameContainer from '../../../containers/UsersNameContainer';

src/components/Exercises/ExercisesName/ExercisesName.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { Link } from 'react-router';
3+
import { Link } from 'react-router-dom';
44

55
import withLinks from '../../../helpers/withLinks';
66
import { LocalizedExerciseName } from '../../helpers/LocalizedNames';

src/components/Groups/GroupsName/GroupsName.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { Link } from 'react-router';
3+
import { Link } from 'react-router-dom';
44
import withLinks from '../../../helpers/withLinks';
55
import { LocalizedGroupName } from '../../helpers/LocalizedNames';
66

src/components/Groups/ResultsTable/ResultsTable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
3-
import { Link } from 'react-router';
3+
import { Link } from 'react-router-dom';
44
import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
55
import { defaultMemoize } from 'reselect';
66
import { OverlayTrigger, Tooltip } from 'react-bootstrap';
@@ -256,6 +256,7 @@ class ResultsTable extends Component {
256256
groupName,
257257
intl: { locale },
258258
} = this.props;
259+
259260
return (
260261
<React.Fragment>
261262
<SortableTable

0 commit comments

Comments
 (0)