-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding shadow assignments to students' group overviews at dashboard.
- Loading branch information
1 parent
1c4c6be
commit 41e1539
Showing
10 changed files
with
109 additions
and
25 deletions.
There are no files selected for viewing
15 changes: 0 additions & 15 deletions
15
src/components/Assignments/Assignment/AssignmentTableRow/NoAssignmentTableRow.js
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/components/Assignments/Assignment/AssignmentTableRow/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { default } from './AssignmentTableRow'; | ||
export { default as LoadingAssignmentTableRow } from './LoadingAssignmentTableRow'; | ||
export { default as NoAssignmentTableRow } from './NoAssignmentTableRow'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/containers/ShadowAssignmentsTableContainer/ShadowAssignmentsTableContainer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import ImmutablePropTypes from 'react-immutable-proptypes'; | ||
import { connect } from 'react-redux'; | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
import ShadowAssignmentsTable from '../../components/Assignments/ShadowAssignment/ShadowAssignmentsTable'; | ||
import ResourceRenderer from '../../components/helpers/ResourceRenderer'; | ||
import { LoadingIcon } from '../../components/icons'; | ||
|
||
import { fetchShadowAssignmentsForGroup } from '../../redux/modules/shadowAssignments'; | ||
import { groupsShadowAssignmentsSelector } from '../../redux/selectors/groups'; | ||
import { loggedUserIsSupervisorOfSelector, loggedUserIsAdminOfSelector } from '../../redux/selectors/usersGroups'; | ||
|
||
class ShadowAssignmentsTableContainer extends Component { | ||
componentDidMount() { | ||
this.props.loadAsync(); | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
if (this.props.groupId !== prevProps.groupId || this.props.userId !== prevProps.userId) { | ||
this.props.loadAsync(); | ||
} | ||
} | ||
|
||
render() { | ||
const { userId, shadowAssignments, isGroupAdmin, isGroupSupervisor, hideEmpty = false } = this.props; | ||
return hideEmpty && shadowAssignments.size === 0 ? null : ( | ||
<ResourceRenderer | ||
resource={shadowAssignments} | ||
loading={ | ||
<div className="text-center p-2"> | ||
<LoadingIcon gapRight /> | ||
<FormattedMessage id="generic.loading" defaultMessage="Loading..." /> | ||
</div> | ||
}> | ||
{() => ( | ||
<ShadowAssignmentsTable | ||
shadowAssignments={shadowAssignments} | ||
isAdmin={isGroupAdmin || isGroupSupervisor} | ||
userId={userId} | ||
/> | ||
)} | ||
</ResourceRenderer> | ||
); | ||
} | ||
} | ||
|
||
ShadowAssignmentsTableContainer.propTypes = { | ||
groupId: PropTypes.string.isRequired, | ||
userId: PropTypes.string.isRequired, | ||
hideEmpty: PropTypes.bool, | ||
shadowAssignments: ImmutablePropTypes.list, | ||
isGroupAdmin: PropTypes.bool, | ||
isGroupSupervisor: PropTypes.bool, | ||
loadAsync: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default connect( | ||
(state, { groupId }) => ({ | ||
shadowAssignments: groupsShadowAssignmentsSelector(state, groupId), | ||
isGroupSupervisor: loggedUserIsSupervisorOfSelector(state)(groupId), | ||
isGroupAdmin: loggedUserIsAdminOfSelector(state)(groupId), | ||
}), | ||
(dispatch, { groupId, userId = null }) => ({ | ||
loadAsync: () => dispatch(fetchShadowAssignmentsForGroup(groupId)), | ||
}) | ||
)(ShadowAssignmentsTableContainer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import ShadowAssignmentsTableContainer from './ShadowAssignmentsTableContainer'; | ||
export default ShadowAssignmentsTableContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters