Skip to content

Commit

Permalink
Fix dashboard SIS panel to correctly fetch public groups instead of g…
Browse files Browse the repository at this point in the history
…roups when accessing group names.
  • Loading branch information
Martin Krulis committed Nov 26, 2017
1 parent e806161 commit 1929e28
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
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
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)
);

0 comments on commit 1929e28

Please sign in to comment.