Skip to content

Commit

Permalink
Merge branch 'master' into fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SemaiCZE committed Nov 3, 2017
2 parents 4b61cee + 35cdc0a commit 8f84342
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 33 deletions.
13 changes: 7 additions & 6 deletions src/containers/GroupsNameContainer/GroupsNameContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import GroupsName, {

class GroupsNameContainer extends Component {
componentWillMount() {
GroupsNameContainer.loadData(this.props);
this.props.loadAsync();
}

componentWillReceiveProps(newProps) {
if (this.props.groupId !== newProps.groupId) {
GroupsNameContainer.loadData(newProps);
newProps.loadAsync();
}
}

static loadData = ({ loadGroupIfNeeded }) => {
loadGroupIfNeeded();
static loadAsync = ({ groupId }, dispatch) => {
dispatch(fetchPublicGroupIfNeeded(groupId));
};

render() {
Expand All @@ -38,14 +38,15 @@ class GroupsNameContainer extends Component {
GroupsNameContainer.propTypes = {
groupId: PropTypes.string.isRequired,
group: ImmutablePropTypes.map,
noLink: PropTypes.bool
noLink: PropTypes.bool,
loadAsync: PropTypes.func.isRequired
};

export default connect(
(state, { groupId }) => ({
group: publicGroupSelector(groupId)(state)
}),
(dispatch, { groupId }) => ({
loadGroupIfNeeded: () => dispatch(fetchPublicGroupIfNeeded(groupId))
loadAsync: () => GroupsNameContainer.loadAsync({ groupId }, dispatch)
})
)(GroupsNameContainer);
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import LicencesTable from '../../components/Instances/LicencesTable';
import { fetchInstanceLincences } from '../../redux/modules/licences';
import { getLicencesOfInstance } from '../../redux/selectors/licences';

import { clientOnly } from '../../helpers/clientOnly';

class LicencesTableContainer extends Component {
static loadAsync = ({ instanceId }, dispatch) =>
dispatch(fetchInstanceLincences(instanceId));
Expand Down Expand Up @@ -44,8 +42,6 @@ export default connect(
}),
(dispatch, { instance }) => ({
loadAsync: () =>
clientOnly(() =>
LicencesTableContainer.loadAsync({ instanceId: instance.id }, dispatch)
)
LicencesTableContainer.loadAsync({ instanceId: instance.id }, dispatch)
})
)(LicencesTableContainer);
12 changes: 5 additions & 7 deletions src/containers/UsersNameContainer/UsersNameContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ import UsersName, {
LoadingUsersName,
FailedUsersName
} from '../../components/Users/UsersName';
import { clientOnly } from '../../helpers/clientOnly';

class UsersNameContainer extends Component {
componentWillMount() {
this.props.loadData();
this.props.loadAsync();
}

componentWillReceiveProps(newProps) {
if (this.props.userId !== newProps.userId) {
newProps.loadData();
newProps.loadAsync();
}
}

static loadData = (userId, dispatch) => {
static loadAsync = ({ userId }, dispatch) => {
dispatch(fetchProfileIfNeeded(userId));
};

Expand Down Expand Up @@ -56,7 +55,7 @@ UsersNameContainer.propTypes = {
large: PropTypes.bool,
user: ImmutablePropTypes.map,
noLink: PropTypes.bool,
loadData: PropTypes.func.isRequired
loadAsync: PropTypes.func.isRequired
};

export default connect(
Expand All @@ -66,7 +65,6 @@ export default connect(
}),
(dispatch, { userId }) => ({
loadProfileIfNeeded: () => dispatch(fetchProfileIfNeeded(userId)),
loadData: () =>
clientOnly(() => UsersNameContainer.loadData(userId, dispatch))
loadAsync: () => UsersNameContainer.loadAsync({ userId }, dispatch)
})
)(UsersNameContainer);
1 change: 0 additions & 1 deletion src/helpers/clientOnly.js

This file was deleted.

6 changes: 2 additions & 4 deletions src/pages/Exercise/Exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import {
groupsSelector
} from '../../redux/selectors/groups';

import { clientOnly } from '../../helpers/clientOnly';
import withLinks from '../../hoc/withLinks';
import { getLocalizedName } from '../../helpers/getLocalizedData';

Expand All @@ -83,7 +82,7 @@ const messages = defineMessages({
class Exercise extends Component {
state = { forkId: null };

static loadAsync = (dispatch, exerciseId, userId) =>
static loadAsync = ({ exerciseId }, dispatch, userId) =>
Promise.all([
dispatch(fetchExerciseIfNeeded(exerciseId)),
dispatch(fetchReferenceSolutionsIfNeeded(exerciseId)),
Expand Down Expand Up @@ -482,8 +481,7 @@ export default withLinks(
};
},
(dispatch, { params: { exerciseId } }) => ({
loadAsync: userId =>
clientOnly(() => Exercise.loadAsync(dispatch, exerciseId, userId)),
loadAsync: userId => Exercise.loadAsync({ exerciseId }, dispatch, userId),
assignExercise: groupId =>
dispatch(assignExercise(groupId, exerciseId)),
push: url => dispatch(push(url)),
Expand Down
4 changes: 1 addition & 3 deletions src/pages/ReferenceSolution/ReferenceSolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Row, Col, Button } from 'react-bootstrap';

import withLinks from '../../hoc/withLinks';
import Page from '../../components/layout/Page';
import { clientOnly } from '../../helpers/clientOnly';

import {
fetchReferenceSolutionsIfNeeded,
Expand Down Expand Up @@ -212,8 +211,7 @@ export default withLinks(
referenceSolutions: referenceSolutionsSelector(exerciseId)(state)
}),
(dispatch, { params }) => ({
loadAsync: () =>
clientOnly(() => ReferenceSolution.loadAsync(params, dispatch)),
loadAsync: () => ReferenceSolution.loadAsync(params, dispatch),
refreshSolutionEvaluations: () => {
dispatch(fetchReferenceSolutions(params.exerciseId));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import ImmutablePropTypes from 'react-immutable-proptypes';

import withLinks from '../../hoc/withLinks';
import Page from '../../components/layout/Page';
import { clientOnly } from '../../helpers/clientOnly';

import { fetchReferenceSolutionsIfNeeded } from '../../redux/modules/referenceSolutions';
import { referenceSolutionsSelector } from '../../redux/selectors/referenceSolutions';
Expand Down Expand Up @@ -162,9 +161,7 @@ export default withLinks(
}),
(dispatch, { params }) => ({
loadAsync: () =>
clientOnly(() =>
ReferenceSolutionEvaluation.loadAsync(params, dispatch)
),
ReferenceSolutionEvaluation.loadAsync(params, dispatch),
downloadEvaluationArchive: e => {
e.preventDefault();
dispatch(downloadEvaluationArchive(params.evaluationId));
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Submission/Submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
isSuperAdmin
} from '../../redux/selectors/users';
import { loggedInUserIdSelector } from '../../redux/selectors/auth';
import { clientOnly } from '../../helpers/clientOnly';
import { getLocalizedName } from '../../helpers/getLocalizedData';

class Submission extends Component {
Expand Down Expand Up @@ -152,7 +151,7 @@ export default injectIntl(
isSuperAdmin(loggedInUserIdSelector(state))(state)
}),
(dispatch, { params }) => ({
loadAsync: () => clientOnly(() => Submission.loadAsync(params, dispatch))
loadAsync: () => Submission.loadAsync(params, dispatch)
})
)(Submission)
);
3 changes: 2 additions & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const renderWithoutSSR = (res, renderProps) => {
};

const renderPage = (res, store, renderProps) => {
let reduxState = serialize(store.getState(), { isJSON: true });
let html = renderToString(
<Provider store={store}>
<RouterContext {...renderProps} />
Expand All @@ -69,7 +70,7 @@ const renderPage = (res, store, renderProps) => {
res.render('index', {
html,
head,
reduxState: serialize(store.getState(), { isJSON: true }),
reduxState,
bundle,
style: '/style.css'
});
Expand Down

0 comments on commit 8f84342

Please sign in to comment.