-
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 collective update functions for exercise assignments (e.g., sy…
…ncing multiple assignments with the exercise at once).
- Loading branch information
1 parent
1d36bc4
commit 6a635c8
Showing
18 changed files
with
425 additions
and
81 deletions.
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
src/components/Assignments/Assignment/AssignmentSyncIcon/AssignmentSyncIcon.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,57 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { OverlayTrigger, Popover } from 'react-bootstrap'; | ||
|
||
import DateTime from '../../../widgets/DateTime'; | ||
import { WarningIcon } from '../../../icons'; | ||
import { isUpToDate } from '../assignmentSyncHelper'; | ||
|
||
const AssignmentSyncIcon = ({ id, syncInfo, ...props }) => { | ||
return !isUpToDate(syncInfo) ? ( | ||
<OverlayTrigger | ||
placement="bottom" | ||
overlay={ | ||
<Popover id={`assginmentsync-${id}`}> | ||
<Popover.Title> | ||
<FormattedMessage | ||
id="app.assignment.syncRequiredTitle" | ||
defaultMessage="The exercise data are newer than assignment data" | ||
/> | ||
</Popover.Title> | ||
<Popover.Content> | ||
<p> | ||
<FormattedMessage | ||
id="app.assignment.syncRequired" | ||
defaultMessage="Exercise was updated at <strong>{exerciseUpdated}</strong>, but the assignment was synchronized with the exercise at <strong>{assignmentUpdated}</strong>!" | ||
values={{ | ||
exerciseUpdated: <DateTime unixts={syncInfo.updatedAt.exercise} emptyPlaceholder="??" />, | ||
assignmentUpdated: <DateTime unixts={syncInfo.updatedAt.assignment} emptyPlaceholder="??" />, | ||
strong: contents => <strong>{contents}</strong>, | ||
}} | ||
/> | ||
</p> | ||
|
||
{!syncInfo.isSynchronizationPossible && ( | ||
<p> | ||
<WarningIcon className="text-danger" gapRight /> | ||
<FormattedMessage | ||
id="app.assignment.syncIsNotPossible" | ||
defaultMessage="The exercise is not in a consistent state, synchronization is not possible at the moment." | ||
/> | ||
</p> | ||
)} | ||
</Popover.Content> | ||
</Popover> | ||
}> | ||
<WarningIcon {...props} className={syncInfo.isSynchronizationPossible ? 'text-warning' : 'text-danger'} /> | ||
</OverlayTrigger> | ||
) : null; | ||
}; | ||
|
||
AssignmentSyncIcon.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
syncInfo: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default AssignmentSyncIcon; |
2 changes: 2 additions & 0 deletions
2
src/components/Assignments/Assignment/AssignmentSyncIcon/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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import AssignmentSyncIcon from './AssignmentSyncIcon'; | ||
export default AssignmentSyncIcon; |
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
Oops, something went wrong.