Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing a fiew bugs #143

Merged
merged 2 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NODE_ENV=production
API_BASE=https://recodex.projekty.ms.mff.cuni.cz:4000/v1
PORT=443
# WEBPACK_DEV_SERVER_PORT=8081 # might be usefull for dev environment, if port 8081 is necessary for something
# If the REDUX_DEV_SERVER_PORT is not defined, the server will not be started.
# REDUX_DEV_SERVER_PORT=8082

TITLE=ReCodEx
Expand Down
22 changes: 16 additions & 6 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import Express from 'express';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
Expand All @@ -9,7 +8,7 @@ import remotedev from 'remotedev-server';

const PORT = process.env.PORT || 8080;
const WEBPACK_DEV_SERVER_PORT = process.env.WEBPACK_DEV_SERVER_PORT || 8081;
const REDUX_DEV_SERVER_PORT = process.env.REDUX_DEV_SERVER_PORT || 8082;
const REDUX_DEV_SERVER_PORT = process.env.REDUX_DEV_SERVER_PORT || null;

let app = new Express();
app.set('view engine', 'ejs');
Expand Down Expand Up @@ -39,10 +38,21 @@ var server = new WebpackDevServer(webpack(config), {
stats: { colors: true }
});

remotedev({
hostname: '127.0.0.1',
port: REDUX_DEV_SERVER_PORT
});
if (REDUX_DEV_SERVER_PORT) {
console.log(
`${colors.yellow('ReduxDevServer')} is running on ${colors.underline(
`http://localhost:${REDUX_DEV_SERVER_PORT}`
)}`
);
remotedev({
hostname: '127.0.0.1',
port: REDUX_DEV_SERVER_PORT
});
} else {
console.log(
'No ReduxDevServer port defined, using embeded redux dev tools instead.'
);
}

server.listen(WEBPACK_DEV_SERVER_PORT, 'localhost', () => {
console.log(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Button from '../../components/widgets/FlatButton';
import { LinkContainer } from 'react-router-bootstrap';
import Icon from 'react-fontawesome';

import { fetchGroupsIfNeeded } from '../../redux/modules/groups';
import { fetchPublicGroupsIfNeeded } from '../../redux/modules/publicGroups';
import { fetchSisStatusIfNeeded } from '../../redux/modules/sisStatus';
import {
fetchSisSupervisedCourses,
Expand All @@ -21,7 +21,7 @@ import { sisPossibleParentsSelector } from '../../redux/selectors/sisPossiblePar
import { sisStateSelector } from '../../redux/selectors/sisStatus';
import { sisSupervisedCoursesSelector } from '../../redux/selectors/sisSupervisedCourses';
import { loggedInUserIdSelector } from '../../redux/selectors/auth';
import { groupDataAccessorSelector } from '../../redux/selectors/groups';
import { publicGroupDataAccessorSelector } from '../../redux/selectors/publicGroups';

import UsersNameContainer from '../UsersNameContainer';
import ResourceRenderer from '../../components/helpers/ResourceRenderer';
Expand Down Expand Up @@ -72,7 +72,12 @@ class SisSupervisorGroupsContainer extends Component {
.then(res => res.value)
.then(parents =>
parents.map(parent =>
dispatch(fetchGroupsIfNeeded(...parent.parentGroupsIds))
dispatch(
fetchPublicGroupsIfNeeded(
parent.id,
...parent.parentGroupsIds
)
)
)
)
)
Expand Down Expand Up @@ -341,7 +346,7 @@ export default injectIntl(
currentUserId,
sisCourses: sisSupervisedCoursesSelector(state),
sisPossibleParents: sisPossibleParentsSelector(state),
groupsAccessor: groupDataAccessorSelector(state)
groupsAccessor: publicGroupDataAccessorSelector(state)
};
},
dispatch => ({
Expand Down
6 changes: 2 additions & 4 deletions src/pages/AssignmentStats/AssignmentStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { fetchGroupIfNeeded } from '../../redux/modules/groups';

import Page from '../../components/layout/Page';
import ResourceRenderer from '../../components/helpers/ResourceRenderer';
import { LocalizedExerciseName } from '../../components/helpers/LocalizedNames';
import HierarchyLineContainer from '../../containers/HierarchyLineContainer';

class AssignmentStats extends Component {
Expand Down Expand Up @@ -53,10 +54,7 @@ class AssignmentStats extends Component {
resource={assignment}
title={
<ResourceRenderer resource={assignment}>
{assignment =>
<span>
{assignment.name}
</span>}
{assignment => <LocalizedExerciseName entity={assignment} />}
</ResourceRenderer>
}
description={
Expand Down
9 changes: 8 additions & 1 deletion src/pages/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
fetchGroupsIfNeeded,
fetchInstanceGroupsIfNeeded
} from '../../redux/modules/groups';
import { fetchPublicGroupsIfNeeded } from '../../redux/modules/publicGroups';

import {
getUser,
Expand Down Expand Up @@ -86,7 +87,13 @@ class Dashboard extends Component {
groups.map(({ value: group }) =>
Promise.all([
dispatch(fetchAssignmentsForGroup(group.id)),
dispatch(fetchGroupsStatsIfNeeded(group.id))
dispatch(fetchGroupsStatsIfNeeded(group.id)),
dispatch(
fetchPublicGroupsIfNeeded(
group.id,
...group.parentGroupsIds
)
)
])
)
)
Expand Down
1 change: 1 addition & 0 deletions src/redux/modules/publicGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const { actions, reduceActions } = factory({
* Actions
*/

export const fetchPublicGroupsIfNeeded = actions.fetchIfNeeded;
export const fetchPublicGroupIfNeeded = actions.fetchOneIfNeeded;

export const fetchInstancePublicGroups = instanceId =>
Expand Down
7 changes: 7 additions & 0 deletions src/redux/selectors/publicGroups.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { createSelector } from 'reselect';
import { Map } from 'immutable';

/**
* Select groups part of the state
*/
const EMPTY_MAP = Map();

export const publicGroupsSelectors = state =>
state.publicGroups.get('resources');

export const publicGroupSelector = id =>
createSelector(publicGroupsSelectors, groups => groups.get(id));

export const publicGroupDataAccessorSelector = createSelector(
publicGroupsSelectors,
groups => groupId => groups.getIn([groupId, 'data'], EMPTY_MAP)
);
24 changes: 16 additions & 8 deletions src/redux/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import filter from 'redux-storage-decorator-filter';
import { actionTypes as authActionTypes } from './modules/auth';
import { actionTypes as switchingActionTypes } from './modules/userSwitching';

const REDUX_DEV_SERVER_PORT = process.env.REDUX_DEV_SERVER_PORT !== 'undefined' ? process.env.REDUX_DEV_SERVER_PORT : 8082;
const REDUX_DEV_SERVER_PORT =
process.env.REDUX_DEV_SERVER_PORT !== 'undefined'
? process.env.REDUX_DEV_SERVER_PORT
: null;

const engine = filter(createEngine('recodex/store'), ['userSwitching']);

Expand All @@ -36,17 +39,22 @@ const getMiddleware = history => [
)
];

const composeEnhancers = composeWithDevTools({
realtime: true,
name: 'ReCodEx',
host: '127.0.0.1',
port: REDUX_DEV_SERVER_PORT
});
const composeEnhancers = REDUX_DEV_SERVER_PORT
? composeWithDevTools({
realtime: true,
name: 'ReCodEx',
host: '127.0.0.1',
port: REDUX_DEV_SERVER_PORT
})
: f => f;

const dev = history =>
composeEnhancers(
compose(
applyMiddleware(...getMiddleware(history), loggerMiddleware(!canUseDOM))
applyMiddleware(...getMiddleware(history), loggerMiddleware(!canUseDOM)),
!REDUX_DEV_SERVER_PORT && canUseDOM && window.devToolsExtension // if no server is in place and dev tools are available, use them
? window.devToolsExtension()
: f => f
)
);

Expand Down