Skip to content

Commit e8323dc

Browse files
luizrrodriguesmtwomey
authored andcommitted
Fix challenge.track validation
1 parent 98fadbb commit e8323dc

File tree

15 files changed

+86
-73
lines changed

15 files changed

+86
-73
lines changed

__tests__/shared/components/ChallengeTile/__mocks__/design.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
"technologies": "",
1616
"status": "COMPLETED",
1717
"legacy": {
18-
"track": "DESIGN",
1918
"forumId": 599349
2019
},
21-
"subTrack": "LOGO_DESIGN",
20+
"track": "Design",
21+
"type": "Challenge",
22+
"tags": "Logo Design",
2223
"name": "Sunshot - MapMySolar - SunGiver - Brand Concept Logo Design Challenge",
2324
"reviewType": "INTERNAL",
2425
"id": 30051608,
@@ -320,10 +321,11 @@
320321
"technologies": "",
321322
"status": "COMPLETED",
322323
"legacy": {
323-
"track": "DESIGN",
324324
"forumId": 598066
325325
},
326-
"subTrack": "LOGO_DESIGN",
326+
"track": "Design",
327+
"type": "Challenge",
328+
"tags": ["Logo Design"],
327329
"name": "2016 Topcoder Open Logo Design Challenge",
328330
"reviewType": "INTERNAL",
329331
"id": 30051059,
@@ -532,10 +534,11 @@
532534
"technologies": "",
533535
"status": "COMPLETED",
534536
"legacy": {
535-
"track": "DESIGN",
536537
"forumId": 596557
537538
},
538-
"subTrack": "LOGO_DESIGN",
539+
"track": "Design",
540+
"type": "Challenge",
541+
"tags": "Logo Design",
539542
"name": "ACME Logos Design Challenge",
540543
"reviewType": "INTERNAL",
541544
"id": 30050375,

__tests__/shared/components/ChallengeTile/__mocks__/develop.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
"technologies": "CSS, HTML, JavaScript",
2323
"status": "COMPLETED",
2424
"legacy": {
25-
"track": "DEVELOP",
2625
"forumId": 39153
2726
},
28-
"subTrack": "FIRST_2_FINISH",
27+
"track": "Development",
28+
"type": "First2Finish",
2929
"name": "$100 Eaton PX 2.0 Petting Zoo - MDC Web Enhancement F2F Challenge",
3030
"reviewType": "INTERNAL",
3131
"id": 30060905,
@@ -165,10 +165,10 @@
165165
"technologies": "ReactJS",
166166
"status": "COMPLETED",
167167
"legacy": {
168-
"track": "DEVELOP",
169168
"forumId": 39151
170169
},
171-
"subTrack": "FIRST_2_FINISH",
170+
"track": "Development",
171+
"type": "First2Finish",
172172
"name": "$100 Eaton PX 2.0 Petting Zoo - ReactJS Enhancement F2F Challenge",
173173
"reviewType": "INTERNAL",
174174
"id": 30060903,
@@ -323,10 +323,10 @@
323323
"technologies": "Angular 2+, Express, JSON, Node.js",
324324
"status": "COMPLETED",
325325
"legacy": {
326-
"track": "DEVELOP",
327326
"forumId": 38951
328327
},
329-
"subTrack": "FIRST_2_FINISH",
328+
"track": "Development",
329+
"type": "First2Finish",
330330
"name": "$500 BG800 Online Course Mock Rest API F2F Challenge",
331331
"reviewType": "INTERNAL",
332332
"id": 30060687,
@@ -630,11 +630,11 @@
630630
"updatedBy": "22841596",
631631
"technologies": "JavaScript, ReactJS",
632632
"status": "COMPLETED",
633-
"legacy": {
634-
"track": "DEVELOP",
633+
"legacy": {
635634
"forumId": 38702
636635
},
637-
"subTrack": "FIRST_2_FINISH",
636+
"track": "Development",
637+
"type": "First2Finish",
638638
"name": "John Hancock - Giving Tuesday - General image handling",
639639
"reviewType": "INTERNAL",
640640
"id": 30060425,

__tests__/shared/components/ChallengeTile/__mocks__/marathon.json

Lines changed: 12 additions & 20 deletions
Large diffs are not rendered by default.

__tests__/shared/components/ChallengeTile/__snapshots__/index.jsx.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exports[`renders design 1`] = `
1212
}
1313
>
1414
<div
15-
className="src-shared-components-ChallengeTile-___style__challenge___1vlh0 src-shared-components-ChallengeTile-___style__tile-view___1stZU src-shared-components-ChallengeTile-___style__DESIGN___Qvjqd"
15+
className="src-shared-components-ChallengeTile-___style__challenge___1vlh0 src-shared-components-ChallengeTile-___style__tile-view___1stZU src-shared-components-ChallengeTile-___style__design___1wk2u"
1616
>
1717
<div
1818
className="src-shared-components-ChallengeTile-___style__completed-challenge___3w5tT"
@@ -30,7 +30,7 @@ exports[`renders design 1`] = `
3030
<p
3131
className="src-shared-components-ChallengeTile-___style__subtrack-color___2AJaw"
3232
>
33-
LOGO DESIGN
33+
Challenge
3434
</p>
3535
<p
3636
className="src-shared-components-ChallengeTile-___style__date-completed___22F18"
@@ -42,7 +42,7 @@ exports[`renders design 1`] = `
4242
className="src-shared-components-ChallengeTile-___style__challenge-card__bottom___CYUWj"
4343
>
4444
<div
45-
className="src-shared-components-ChallengeTile-___style__challenge-details___3xZDW src-shared-components-ChallengeTile-___style__DATA_SCIENCE___1b8GD"
45+
className="src-shared-components-ChallengeTile-___style__challenge-details___3xZDW src-shared-components-ChallengeTile-___style__data-science___2SGr7"
4646
>
4747
<div
4848
className="src-shared-components-ChallengeTile-___style__design-challenge-user-place___3v-1O"
@@ -91,7 +91,7 @@ exports[`renders develop 1`] = `
9191
}
9292
>
9393
<div
94-
className="src-shared-components-ChallengeTile-___style__challenge___1vlh0 src-shared-components-ChallengeTile-___style__tile-view___1stZU src-shared-components-ChallengeTile-___style__DEVELOP___GgzgV"
94+
className="src-shared-components-ChallengeTile-___style__challenge___1vlh0 src-shared-components-ChallengeTile-___style__tile-view___1stZU src-shared-components-ChallengeTile-___style__development___19vlt"
9595
>
9696
<div
9797
className="src-shared-components-ChallengeTile-___style__completed-challenge___3w5tT"
@@ -109,7 +109,7 @@ exports[`renders develop 1`] = `
109109
<p
110110
className="src-shared-components-ChallengeTile-___style__subtrack-color___2AJaw"
111111
>
112-
FIRST 2 FINISH
112+
First2Finish
113113
</p>
114114
<p
115115
className="src-shared-components-ChallengeTile-___style__date-completed___22F18"
@@ -131,7 +131,7 @@ exports[`renders develop 1`] = `
131131
className="src-shared-components-ChallengeTile-___style__challenge-card__bottom___CYUWj"
132132
>
133133
<div
134-
className="src-shared-components-ChallengeTile-___style__challenge-details___3xZDW src-shared-components-ChallengeTile-___style__DATA_SCIENCE___1b8GD"
134+
className="src-shared-components-ChallengeTile-___style__challenge-details___3xZDW src-shared-components-ChallengeTile-___style__data-science___2SGr7"
135135
>
136136
<div
137137
className="src-shared-components-ChallengeTile-___style__dev-challenge-user-place___2tS8j"
@@ -196,7 +196,7 @@ exports[`renders marathon 1`] = `
196196
}
197197
>
198198
<div
199-
className="src-shared-components-ChallengeTile-___style__challenge___1vlh0 src-shared-components-ChallengeTile-___style__tile-view___1stZU src-shared-components-ChallengeTile-___style__DATA_SCIENCE___1b8GD"
199+
className="src-shared-components-ChallengeTile-___style__challenge___1vlh0 src-shared-components-ChallengeTile-___style__tile-view___1stZU src-shared-components-ChallengeTile-___style__data-science___2SGr7"
200200
>
201201
<div
202202
className="src-shared-components-ChallengeTile-___style__completed-challenge___3w5tT"
@@ -211,7 +211,7 @@ exports[`renders marathon 1`] = `
211211
<p
212212
className="src-shared-components-ChallengeTile-___style__subtrack-color___2AJaw"
213213
>
214-
MARATHON MATCH
214+
Challenge
215215
</p>
216216
<p
217217
className="src-shared-components-ChallengeTile-___style__date-completed___22F18"
@@ -223,7 +223,7 @@ exports[`renders marathon 1`] = `
223223
className="src-shared-components-ChallengeTile-___style__challenge-card__bottom___CYUWj"
224224
>
225225
<div
226-
className="src-shared-components-ChallengeTile-___style__challenge-details___3xZDW src-shared-components-ChallengeTile-___style__DATA_SCIENCE___1b8GD"
226+
className="src-shared-components-ChallengeTile-___style__challenge-details___3xZDW src-shared-components-ChallengeTile-___style__data-science___2SGr7"
227227
>
228228
<div
229229
className="src-shared-components-ChallengeTile-___style__marathon-score___V-afd"

src/shared/components/ChallengeTile/index.jsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import _ from 'lodash';
66
import React from 'react';
77
import PT from 'prop-types';
88
import { Link } from 'react-router-dom';
9-
import { formatDate } from 'utils/tc';
9+
import { formatDate, COMPETITION_TRACKS } from 'utils/tc';
10+
import { isMM } from 'utils/challenge';
1011
import ReactImageFallback from 'react-image-fallback';
1112
import InviteOnly from 'assets/images/ico-invite-only-prj.svg';
1213
import WinnerRibbon from 'assets/images/ico-winner-ribbon.svg';
@@ -73,23 +74,27 @@ class ChallengeTile extends React.Component {
7374
challenge,
7475
} = this.props;
7576

76-
const { track } = challenge.legacy;
77+
const { track, type } = challenge;
7778

78-
const outStyleName = `challenge tile-view ${track}`;
79+
const outStyleName = `challenge tile-view ${track.replace(' ', '-').toLowerCase()}`;
7980
const extraStyle = {
8081
width: '285px',
8182
padding: '15px',
8283
margin: '10px 5px',
8384
};
8485

85-
const roundId = track === 'DATA_SCIENCE' ? _.get(challenge, 'rounds.0.id') : 0;
86+
const isDataScience = track === COMPETITION_TRACKS.DATA_SCIENCE;
87+
const isDevelopment = track === COMPETITION_TRACKS.DEVELOP;
88+
const isDesign = track === COMPETITION_TRACKS.DESIGN;
89+
90+
const roundId = isDataScience ? _.get(challenge, 'rounds.0.id') : 0;
8691

8792
return (
8893
<div styleName="challenge tile" style={extraStyle}>
8994
<div styleName={outStyleName}>
9095
<div styleName="completed-challenge">
9196
<header>
92-
{ track !== 'DATA_SCIENCE' && (!challenge.isPrivate
97+
{ !isDataScience && (!challenge.isPrivate
9398
? (
9499
<Link to={`/challenges/${challenge.id}`} styleName="name">
95100
<span>
@@ -102,15 +107,15 @@ class ChallengeTile extends React.Component {
102107
</span>
103108
)) }
104109

105-
{ track === 'DATA_SCIENCE'
110+
{ isDataScience
106111
&& (
107112
<a styleName="name" href={`https://community.topcoder.com/longcontest/stats/?module=ViewOverview&rd=${roundId}`}>
108113
{ challenge.name }
109114
</a>
110115
) }
111116

112117
<p styleName="subtrack-color">
113-
{underscoreReplace(challenge.subTrack)}
118+
{underscoreReplace(type)}
114119
</p>
115120
<p styleName="date-completed">
116121
{formatDate(challenge.submissionEndDate)}
@@ -124,8 +129,8 @@ class ChallengeTile extends React.Component {
124129
}
125130
</header>
126131
<div styleName="challenge-card__bottom">
127-
<div styleName="challenge-details DATA_SCIENCE">
128-
{ track === 'DATA_SCIENCE' && challenge.subTrack
132+
<div styleName="challenge-details data-science">
133+
{ isMM(challenge)
129134
&& (
130135
<div styleName="marathon-score">
131136
<p styleName="score">
@@ -136,7 +141,7 @@ class ChallengeTile extends React.Component {
136141
</p>
137142
</div>
138143
) }
139-
{ track === 'DEVELOP'
144+
{ isDevelopment
140145
&& (
141146
<div styleName="dev-challenge-user-place">
142147
<div styleName="tile-view">
@@ -193,7 +198,7 @@ class ChallengeTile extends React.Component {
193198
)
194199
}
195200
{
196-
track === 'DESIGN' && !challenge.isPrivate
201+
isDesign && !challenge.isPrivate
197202
&& (
198203
<div styleName="design-challenge-user-place">
199204
<div styleName="tile-view">
@@ -313,7 +318,7 @@ class ChallengeTile extends React.Component {
313318
</div>
314319

315320
<p styleName="roles">
316-
{ track !== 'DATA_SCIENCE'
321+
{ track !== COMPETITION_TRACKS.DATA_SCIENCE
317322
&& (
318323
<span>
319324
<span>

src/shared/components/ChallengeTile/style.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
}
7878

7979
// Dynamic colors based on track
80-
.DESIGN {
80+
.design {
8181
&.tile-view {
8282
header {
8383
border-left: 3px solid #21b2f1;
@@ -94,7 +94,7 @@
9494
}
9595
}
9696

97-
.DEVELOP {
97+
.development {
9898
&.tile-view {
9999
header {
100100
border-left: 3px solid #05c14f;
@@ -111,7 +111,7 @@
111111
}
112112
}
113113

114-
.DATA_SCIENCE {
114+
.data-science {
115115
&.tile-view {
116116
header {
117117
border-left: 3px solid #fc9a00;

src/shared/components/SubmissionManagement/Submission/index.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import _ from 'lodash';
1515
import moment from 'moment';
1616
import React from 'react';
1717
import { config } from 'topcoder-react-utils';
18+
import { COMPETITION_TRACKS } from 'utils/tc';
1819

1920
import PT from 'prop-types';
2021

@@ -49,7 +50,7 @@ export default function Submission(props) {
4950
{formatDate(submissionObject.created)}
5051
</td>
5152
{
52-
track === 'Design' && (
53+
track === COMPETITION_TRACKS.DESIGN && (
5354
<td styleName="status-col">
5455
{submissionObject.screening
5556
&& (
@@ -66,7 +67,7 @@ export default function Submission(props) {
6667
<div>
6768
<a
6869
href={
69-
track === 'Design'
70+
track === COMPETITION_TRACKS.DESIGN
7071
? `${config.URL.ONLINE_REVIEW}/review/actions/DownloadContestSubmission?uid=${submissionObject.id}`
7172
: submissionObject.download
7273
}

src/shared/components/SubmissionManagement/SubmissionsTable/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import React from 'react';
1919
import PT from 'prop-types';
2020
import shortid from 'shortid';
2121
import moment from 'moment';
22+
import { COMPETITION_TRACKS } from 'utils/tc';
2223
import Submission from '../Submission';
2324
import ScreeningDetails from '../ScreeningDetails';
2425
import './styles.scss';
@@ -101,7 +102,7 @@ export default function SubmissionsTable(props) {
101102
<th>
102103
Submission Date
103104
</th>
104-
{track === 'Design' && (
105+
{track === COMPETITION_TRACKS.DESIGN && (
105106
<th styleName="status">
106107
Screening Status
107108
</th>

src/shared/components/SubmissionPage/Submit/index.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import PT from 'prop-types';
1414
import { PrimaryButton } from 'topcoder-react-ui-kit';
1515
import { config } from 'topcoder-react-utils';
1616
import LoadingIndicator from 'components/LoadingIndicator';
17+
import { COMPETITION_TRACKS } from 'utils/tc';
1718

1819
import FilestackFilePicker from '../FilestackFilePicker';
1920

@@ -192,14 +193,14 @@ class Submit extends React.Component {
192193
</div>
193194
<div styleName="right">
194195
<div styleName="submission-hints">
195-
{ track === 'DEVELOP' ? (
196+
{ track === COMPETITION_TRACKS.DEVELOP ? (
196197
<div>
197198
{isChallengeBelongToTopgearGroup
198199
? (<p>Enter the URL to your submission.</p>)
199200
: (<p>Upload your entire submission as a single zip file.</p>)}
200201
</div>
201202
) : null }
202-
{ track === 'DESIGN' ? (
203+
{ track === COMPETITION_TRACKS.DESIGN ? (
203204
<div>
204205
<ol>
205206
<li>Place your submission files into a &quot;Submission.zip&quot; file.</li>

src/shared/components/SubmissionPage/Uploading/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import RobotSad from 'assets/images/robot-embarassed.svg';
1414
import { PrimaryButton, Button } from 'topcoder-react-ui-kit';
1515
import './styles.scss';
1616

17+
import { COMPETITION_TRACKS } from 'utils/tc';
18+
1719
const Uploading = ({
1820
challengeId,
1921
challengeName,
@@ -156,7 +158,7 @@ const Uploading = ({
156158
submitDone && !error
157159
&& (
158160
<div styleName="button-container">
159-
{ track === 'DESIGN' ? (
161+
{ track === COMPETITION_TRACKS.DESIGN ? (
160162
<span>
161163
<Button
162164
onClick={() => reset()}

0 commit comments

Comments
 (0)