Skip to content

Commit 8be49cf

Browse files
committed
Add current phase to the challenge table and other fixes
#1502 #1496 #1495
1 parent 4e3757f commit 8be49cf

File tree

6 files changed

+128
-49
lines changed

6 files changed

+128
-49
lines changed

src/components/Buttons/PrimaryButton/index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,26 @@ import styles from './PrimaryButton.module.scss'
88

99
const PrimaryButton = React.forwardRef(
1010
(
11-
{ type, text, link, onClick, submit, disabled, onMouseEnter, onMouseLeave },
11+
{ type, text, link, onClick, submit, disabled, onMouseEnter, onMouseLeave, href },
1212
ref
1313
) => {
14+
if (!_.isEmpty(href)) {
15+
return (
16+
<a
17+
type={submit ? 'submit' : 'button'}
18+
className={cn(styles.container, styles[type])}
19+
onClick={submit ? null : onClick}
20+
disabled={disabled}
21+
onMouseEnter={onMouseEnter}
22+
onMouseLeave={onMouseLeave}
23+
ref={ref}
24+
href={href}
25+
target='_blank'
26+
>
27+
<span>{text}</span>
28+
</a>
29+
)
30+
}
1431
if (_.isEmpty(link)) {
1532
return (
1633
<button
@@ -44,6 +61,7 @@ PrimaryButton.propTypes = {
4461
type: PropTypes.string.isRequired,
4562
text: PropTypes.string.isRequired,
4663
link: PropTypes.string,
64+
href: PropTypes.string,
4765
onClick: PropTypes.func,
4866
submit: PropTypes.bool,
4967
disabled: PropTypes.bool,

src/components/ChallengeEditor/Submissions/Submissions.module.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ $base-unit: 5px;
2323
margin-right: auto;
2424

2525
.top-title {
26-
margin-top: -50px;
26+
margin-top: -30px;
27+
margin-bottom: 20px;
2728
text-align: center;
2829
display: flex;
2930
justify-content: center;
30-
gap: 20px;
31+
gap: 40px;
3132
}
3233

3334
div {
@@ -412,6 +413,10 @@ $base-unit: 5px;
412413
color: $member-red !important;
413414
}
414415

416+
.btnManageSubmissions {
417+
height: 40px;
418+
}
419+
415420
.btnDownloadAll {
416421
text-decoration: none;
417422
background-color: transparent;

src/components/ChallengeEditor/Submissions/index.js

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import PT from 'prop-types'
88
import moment from 'moment'
99
import _ from 'lodash'
1010
import { STUDIO_URL, SUBMISSION_REVIEW_APP_URL, getTCMemberURL } from '../../../config/constants'
11+
import { PrimaryButton } from '../../Buttons'
1112
import cn from 'classnames'
1213
import ReactSVG from 'react-svg'
1314
import {
@@ -306,54 +307,62 @@ class SubmissionsComponent extends React.Component {
306307
return (
307308
<div className={cn(styles.container, styles.dev, styles['non-mm'])}>
308309
<div className={styles['top-title']} >
309-
<a href={`${SUBMISSION_REVIEW_APP_URL}/${challenge.legacyId}`} target='_blank'>
310-
Manage Submissions
311-
</a>
312-
<button
313-
className={styles.btnDownloadAll}
314-
disabled={downloadingAll}
315-
onClick={async () => {
316-
const reactLib = getTopcoderReactLib()
317-
const { getService } = reactLib.services.submissions
318-
// download submission
319-
this.setState({
320-
downloadingAll: true
321-
})
322-
const submissionsService = getService(token)
323-
const allFiles = []
324-
let downloadedFile = 0
325-
const checkToCompressFiles = () => {
326-
if (downloadedFile === sortedSubmissions.length) {
327-
if (downloadedFile > 0) {
328-
compressFiles(allFiles, 'all-submissions.zip', () => {
310+
311+
<div className={styles.btnManageSubmissions} >
312+
<PrimaryButton
313+
text='Manage Submissions'
314+
type='info'
315+
href={`${SUBMISSION_REVIEW_APP_URL}/${challenge.legacyId}`}
316+
/>
317+
</div>
318+
319+
<div className={styles.btnManageSubmissions} >
320+
<PrimaryButton
321+
text='Download All'
322+
type='info'
323+
disabled={downloadingAll}
324+
onClick={async () => {
325+
const reactLib = getTopcoderReactLib()
326+
const { getService } = reactLib.services.submissions
327+
// download submission
328+
this.setState({
329+
downloadingAll: true
330+
})
331+
const submissionsService = getService(token)
332+
const allFiles = []
333+
let downloadedFile = 0
334+
const checkToCompressFiles = () => {
335+
if (downloadedFile === sortedSubmissions.length) {
336+
if (downloadedFile > 0) {
337+
compressFiles(allFiles, 'all-submissions.zip', () => {
338+
this.setState({
339+
downloadingAll: false
340+
})
341+
})
342+
} else {
329343
this.setState({
330344
downloadingAll: false
331345
})
332-
})
333-
} else {
334-
this.setState({
335-
downloadingAll: false
336-
})
346+
}
337347
}
338348
}
339-
}
340-
checkToCompressFiles()
341-
_.forEach(sortedSubmissions, (submission) => {
342-
const mmSubmissionId = submission.id
343-
submissionsService.downloadSubmission(mmSubmissionId)
344-
.then((blob) => {
345-
const file = new window.File([blob], `submission-${mmSubmissionId}.zip`)
346-
allFiles.push(file)
347-
downloadedFile += 1
348-
checkToCompressFiles()
349-
}).catch(() => {
350-
downloadedFile += 1
351-
checkToCompressFiles()
352-
})
353-
})
354-
}}>
355-
Download All
356-
</button>
349+
checkToCompressFiles()
350+
_.forEach(sortedSubmissions, (submission) => {
351+
const mmSubmissionId = submission.id
352+
submissionsService.downloadSubmission(mmSubmissionId)
353+
.then((blob) => {
354+
const file = new window.File([blob], `submission-${mmSubmissionId}.zip`)
355+
allFiles.push(file)
356+
downloadedFile += 1
357+
checkToCompressFiles()
358+
}).catch(() => {
359+
downloadedFile += 1
360+
checkToCompressFiles()
361+
})
362+
})
363+
}}
364+
/>
365+
</div>
357366
</div>
358367
<div className={styles.head}>
359368
{!isF2F && !isBugHunt && (

src/components/ChallengeEditor/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,10 +837,15 @@ class ChallengeEditor extends Component {
837837
if (this.state && this.state) {
838838
const { phases } = this.state.challenge
839839
let newChallenge = _.cloneDeep(this.state.challenge)
840+
const isDesignChallenge = newChallenge.trackId === DES_TRACK_ID
841+
const is2RoundChallenge =
842+
newChallenge.timelineTemplateId === MULTI_ROUND_CHALLENGE_TEMPLATE_ID
843+
const is2RoundDesignChallenge = isDesignChallenge && is2RoundChallenge
844+
840845
for (let index = 0; index < phases.length; ++index) {
841846
newChallenge.phases[index].isDurationActive =
842847
moment(newChallenge.phases[index]['scheduledEndDate']).isAfter()
843-
if (newChallenge.phases[index].name === 'Submission' || newChallenge.phases[index].name === 'Checkpoint Submission') {
848+
if ((newChallenge.phases[index].name === 'Submission' && !is2RoundDesignChallenge) || newChallenge.phases[index].name === 'Checkpoint Submission') {
844849
newChallenge.phases[index].isStartTimeActive = true
845850
} else {
846851
newChallenge.phases[index].isStartTimeActive = index <= 0

src/components/ChallengesComponent/ChallengeCard/index.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ class ChallengeCard extends React.Component {
120120
isSaving: false,
121121
isCheckChalengePermission: false,
122122
hasEditChallengePermission: false,
123-
loginUserRoleInProject: ''
123+
loginUserRoleInProject: '',
124+
currentPhase: this.getCurrentPhase(props.challenge),
125+
forumLink: this.getForumLink(props.challenge)
124126
}
125127
this.onUpdateConfirm = this.onUpdateConfirm.bind(this)
126128
this.onUpdateLaunch = this.onUpdateLaunch.bind(this)
@@ -130,6 +132,31 @@ class ChallengeCard extends React.Component {
130132
this.onLaunchChallenge = this.onLaunchChallenge.bind(this)
131133
}
132134

135+
getCurrentPhase (challenge) {
136+
return challenge.phases.filter((p) => p.isOpen).map((p) => p.name).join(' / ') || '-'
137+
}
138+
139+
getForumLink (challenge) {
140+
const discussionsHaveUrls = (challenge.discussions || []).filter((p) => !!p.url)
141+
return discussionsHaveUrls.length ? discussionsHaveUrls[0].url : ''
142+
}
143+
144+
componentDidUpdate (prevProps) {
145+
const { challenge } = this.props
146+
if (!_.isEqual(challenge.phases, prevProps.challenge.phases)) {
147+
// eslint-disable-next-line react/no-did-update-set-state
148+
this.setState({
149+
currentPhase: this.getCurrentPhase(challenge)
150+
})
151+
}
152+
if (!_.isEqual(challenge.discussions, prevProps.challenge.discussions)) {
153+
// eslint-disable-next-line react/no-did-update-set-state
154+
this.setState({
155+
forumLink: this.getForumLink(challenge)
156+
})
157+
}
158+
}
159+
133160
onUpdateConfirm (value) {
134161
this.setState({ isConfirm: value })
135162
}
@@ -202,7 +229,7 @@ class ChallengeCard extends React.Component {
202229
}
203230

204231
render () {
205-
const { isLaunch, isConfirm, isSaving, isDeleteLaunch, isCheckChalengePermission, hasEditChallengePermission } = this.state
232+
const { isLaunch, isConfirm, isSaving, isDeleteLaunch, isCheckChalengePermission, hasEditChallengePermission, currentPhase, forumLink } = this.state
206233
const { setActiveProject, challenge, reloadChallengeList, isBillingAccountExpired, disableHover, getStatusText, challengeTypes, loginUserRoleInProject } = this.props
207234
const deleteMessage = isCheckChalengePermission
208235
? 'Checking permissions...'
@@ -279,6 +306,9 @@ class ChallengeCard extends React.Component {
279306
<div className={styles.col3}>
280307
{renderStatus(challenge.status.toUpperCase(), getStatusText)}
281308
</div>
309+
<div className={styles.col3}>
310+
{currentPhase}
311+
</div>
282312
{
283313
!isReadOnly && (
284314
<div className={styles.col6}>
@@ -292,6 +322,10 @@ class ChallengeCard extends React.Component {
292322
<div className={styles.col6}>
293323
<a className={styles.link} href={communityAppUrl} target='_blank'>CA</a>
294324
</div>
325+
<div className={styles.col6}>
326+
{forumLink ? (<a className={styles.link} href={forumLink} target='_blank'>CA</a>)
327+
: (<a className={styles.link} href='javascript:void(0)'>Forum</a>)}
328+
</div>
295329
</div>
296330
)
297331
}

src/components/ChallengesComponent/ChallengeList/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,9 +764,17 @@ class ChallengeList extends Component {
764764
{this.renderSortIcon('status')}
765765
</span>
766766
</div>
767+
<div
768+
className={cn(styles.col3)}
769+
>
770+
<span className={styles.filterItem}>
771+
Phase
772+
</span>
773+
</div>
767774
{!isReadOnly ? (<div className={styles.col6}>&nbsp;</div>) : null}
768775
<div className={styles.col6}>&nbsp;</div>
769776
<div className={styles.col6}>&nbsp;</div>
777+
<div className={styles.col6}>&nbsp;</div>
770778
</div>
771779

772780
{isLoading

0 commit comments

Comments
 (0)