File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
components/ChallengeEditor Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ import { isBetaMode } from '../../util/cookie'
68
68
import MilestoneField from './Milestone-Field'
69
69
import DiscussionField from './Discussion-Field'
70
70
import CheckpointPrizesField from './CheckpointPrizes-Field'
71
+ import { canChangeDuration } from '../../util/phase'
71
72
72
73
const theme = {
73
74
container : styles . modalContainer
@@ -843,8 +844,7 @@ class ChallengeEditor extends Component {
843
844
const is2RoundDesignChallenge = isDesignChallenge && is2RoundChallenge
844
845
845
846
for ( let index = 0 ; index < phases . length ; ++ index ) {
846
- newChallenge . phases [ index ] . isDurationActive =
847
- moment ( newChallenge . phases [ index ] [ 'scheduledEndDate' ] ) . isAfter ( )
847
+ newChallenge . phases [ index ] . isDurationActive = canChangeDuration ( newChallenge . phases [ index ] )
848
848
if ( ( newChallenge . phases [ index ] . name === 'Submission' && ! is2RoundDesignChallenge ) || newChallenge . phases [ index ] . name === 'Checkpoint Submission' ) {
849
849
newChallenge . phases [ index ] . isStartTimeActive = true
850
850
} else {
Original file line number Diff line number Diff line change 4
4
import moment from 'moment'
5
5
import _ from 'lodash'
6
6
import 'moment-duration-format'
7
+ import { canChangeDuration } from './phase'
7
8
8
9
const HOUR_MS = 60 * 60 * 1000
9
10
const DAY_MS = 24 * HOUR_MS
@@ -120,7 +121,13 @@ export const getRoundFormattedDuration = (duration) => {
120
121
export const convertChallengePhaseFromSecondsToHours = ( phases ) => {
121
122
if ( phases ) {
122
123
_ . forEach ( phases , ( p ) => {
123
- p . duration = Math . floor ( p . duration / minuteToSecond )
124
+ if ( canChangeDuration ( p ) ) {
125
+ p . duration = Math . floor ( p . duration / minuteToSecond )
126
+ } else {
127
+ // use the same duration display as OR, as long as we aren't changing the fields that should be fine.
128
+ const duration = moment . duration ( moment ( p . scheduledEndDate ) . diff ( moment ( p . scheduledStartDate ) ) )
129
+ p . duration = Math . ceil ( duration . asMinutes ( ) )
130
+ }
124
131
} )
125
132
}
126
133
}
Original file line number Diff line number Diff line change
1
+ import moment from 'moment'
2
+
3
+ export const canChangeDuration = phase => {
4
+ if ( ! phase ) {
5
+ return false
6
+ }
7
+ return moment ( phase . scheduledEndDate ) . isAfter ( )
8
+ }
You can’t perform that action at this time.
0 commit comments