Skip to content

Commit a635b03

Browse files
authored
Merge pull request #14 from topcoder-platform/integration-v5-challenge-api
Integration v5 challenge api
2 parents 8514b0a + bb61c2c commit a635b03

File tree

15 files changed

+41
-111
lines changed

15 files changed

+41
-111
lines changed

__tests__/shared/components/Dashboard/SRM/__snapshots__/index.jsx.snap

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ exports[`Matches shallow shapshot 1`] = `
6060
<div
6161
className="src-shared-components-Dashboard-SRM-___styles__srms-links___JFdeQ"
6262
>
63-
<a
64-
href="https://www.topcoder-dev.com/my-srms/"
65-
>
66-
View Past SRMS
67-
</a>
6863
<a
6964
href="https://arena.topcoder-dev.com"
7065
>

__tests__/shared/components/challenge-listing/ChallengeCard/__snapshots__/index.jsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ exports[`Matches shallow shapshot shapshot 1 1`] = `
4949
newChallengeDetails={false}
5050
onTechTagClicked={[Function]}
5151
openChallengesInNewTabs={false}
52-
userHandle=""
52+
userId=""
5353
/>
5454
`;
5555

@@ -93,7 +93,7 @@ exports[`Matches shallow shapshot shapshot 2 1`] = `
9393
newChallengeDetails={false}
9494
onTechTagClicked={[Function]}
9595
openChallengesInNewTabs={false}
96-
userHandle=""
96+
userId=""
9797
/>
9898
`;
9999

@@ -133,6 +133,6 @@ exports[`Matches shallow shapshot shapshot 3 1`] = `
133133
newChallengeDetails={false}
134134
onTechTagClicked={[Function]}
135135
openChallengesInNewTabs={false}
136-
userHandle=""
136+
userId=""
137137
/>
138138
`;

__tests__/shared/components/challenge-listing/Listing/__snapshots__/Bucket.jsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ exports[`Matches shallow shapshot 1`] = `
8989
setFilterState={[MockFunction]}
9090
setSort={[MockFunction]}
9191
sort=""
92-
userHandle=""
92+
userId=""
9393
/>
9494
</StaticRouter>
9595
`;
@@ -240,7 +240,7 @@ exports[`Matches shallow shapshot 2`] = `
240240
setFilterState={[MockFunction]}
241241
setSort={[MockFunction]}
242242
sort=""
243-
userHandle=""
243+
userId=""
244244
/>
245245
</StaticRouter>
246246
`;
@@ -278,7 +278,7 @@ exports[`Matches shallow shapshot 3`] = `
278278
setFilterState={[MockFunction]}
279279
setSort={[MockFunction]}
280280
sort=""
281-
userHandle=""
281+
userId=""
282282
/>
283283
</StaticRouter>
284284
`;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
136136
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
137137
"tc-ui": "^1.0.12",
138-
"topcoder-react-lib": "1000.19.7",
138+
"topcoder-react-lib": "1000.19.8",
139139
"topcoder-react-ui-kit": "^1.0.11",
140140
"topcoder-react-utils": "0.7.8",
141141
"turndown": "^4.0.2",

src/shared/components/Dashboard/CurrentActivity/Challenges/index.jsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,6 @@ export default function Challenges({
140140
/>
141141
</Sticky>
142142
</div>
143-
<div styleName="linksContainer">
144-
<a
145-
href={`${config.URL.BASE}/my-challenges/?status=completed`}
146-
styleName="link"
147-
>
148-
Past Challenges
149-
</a>
150-
</div>
151143
</div>
152144
);
153145
}

src/shared/components/Dashboard/CurrentActivity/Challenges/style.scss

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,6 @@
2121
}
2222
}
2323

24-
.link {
25-
@include tc-body-md;
26-
27-
&,
28-
&:active,
29-
&:focus,
30-
&:visited {
31-
color: $tc-dark-blue-110;
32-
}
33-
34-
&:hover {
35-
color: $tc-dark-blue-70;
36-
}
37-
}
38-
39-
.linksContainer {
40-
padding: 30px 20px 0;
41-
text-align: center;
42-
}
43-
4424
.loading {
4525
margin: 40px 20px 30px;
4626
}

src/shared/components/Dashboard/SRM/index.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ const SRM = (props) => {
4343
</div>
4444
</section>
4545
<div styleName="srms-links">
46-
<a href={`${config.URL.BASE}/my-srms/`}>
47-
View Past SRMS
48-
</a>
4946
<a href={config.URL.ARENA}>
5047
Launch Arena
5148
</a>

src/shared/components/challenge-detail/Specification/index.jsx

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -211,46 +211,9 @@ export default function ChallengeDetailsView(props) {
211211
: (
212212
<div>
213213
{
214-
privateDescription
215-
&& (
216-
<article>
217-
<h2 styleName="h2">
218-
Challenge Details
219-
</h2>
220-
{
221-
editMode ? (
222-
<Editor
223-
connector={toolbarConnector}
224-
id="privateDescription"
225-
initialMode={EDITOR_MODES.WYSIWYG}
226-
ref={n => n && n.setHtml(privateDescription)}
227-
/>
228-
) : (
229-
<SpecificationComponent
230-
bodyText={privateDescription}
231-
format={descriptionFormat}
232-
/>
233-
)
234-
}
235-
<p styleName="p" />
236-
<p styleName="p note">
237-
Please read the challenge specification carefully and
238-
watch the forums for any questions or feedback
239-
concerning this challenge. It is important that you
240-
monitor any updates provided by the client or Studio
241-
Admins in the forums. Please post any questions you
242-
might have for the client in the forums.
243-
</p>
244-
</article>
245-
)
246-
}
247-
{
248-
privateDescription
214+
description
249215
&& (
250216
<article>
251-
<h2 styleName="h2">
252-
Full Description & Project Guide
253-
</h2>
254217
{
255218
editMode ? (
256219
<Editor
@@ -261,7 +224,7 @@ export default function ChallengeDetailsView(props) {
261224
/>
262225
) : (
263226
<SpecificationComponent
264-
bodyText={privateDescription}
227+
bodyText={description}
265228
format={descriptionFormat}
266229
/>
267230
)

src/shared/components/challenge-listing/ChallengeCard/Status/index.jsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export default function ChallengeStatus(props) {
6060
newChallengeDetails,
6161
selectChallengeDetailsTab,
6262
openChallengesInNewTabs,
63+
userId,
6364
} = props;
6465

6566
/* TODO: Split into a separate ReactJS component! */
@@ -130,7 +131,7 @@ export default function ChallengeStatus(props) {
130131
challenge,
131132
detailLink,
132133
} = props;
133-
const timeDiff = getTimeLeft((challenge.allPhases || challenge.phases || []).find(p => p.name === 'Registration'), 'to register');
134+
const timeDiff = getTimeLeft((challenge.allPhases || challenge.phases || []).find(p => p.name === 'Registration'), 'to go');
134135
let timeNote = timeDiff.text;
135136
/* TODO: This is goofy, makes the trick, but should be improved. The idea
136137
* here is that the standard "getTimeLeft" method, for positive times,
@@ -210,28 +211,19 @@ export default function ChallengeStatus(props) {
210211
const allPhases = challenge.phases || [];
211212

212213
let statusPhase = allPhases
213-
.filter(p => p.name !== 'Registration')
214+
.filter(p => p.name !== 'Registration' && p.isOpen)
214215
.sort((a, b) => moment(a.scheduledEndDate).diff(b.scheduledEndDate))[0];
215216

216217
if (!statusPhase && subTrack === 'FIRST_2_FINISH' && allPhases.length) {
217218
statusPhase = _.clone(allPhases[0]);
218219
statusPhase.name = 'Submission';
219220
}
220221

221-
const registrationPhase = allPhases
222-
.find(p => p.name === 'Registration');
223-
const isRegistrationOpen = registrationPhase
224-
&& (
225-
registrationPhase.isOpen
226-
|| moment(registrationPhase.scheduledEndDate).diff(new Date()) > 0);
227-
228-
229222
let phaseMessage = STALLED_MSG;
230223
if (statusPhase) phaseMessage = statusPhase.name;
231224
else if (status === 'Draft') phaseMessage = DRAFT_MSG;
232225

233-
// TODO: Find equivalent of !challenge.users[userHandle]
234-
const showRegisterInfo = isRegistrationOpen;
226+
const showRegisterInfo = challenge.registrationOpen === 'Yes' && !challenge.users[userId];
235227

236228
return (
237229
<div styleName={showRegisterInfo ? 'challenge-progress with-register-button' : 'challenge-progress'}>
@@ -278,7 +270,7 @@ export default function ChallengeStatus(props) {
278270
isLate={moment().isAfter(statusPhase.scheduledEndDate)}
279271
/>
280272
<div styleName="time-left">
281-
{getTimeLeft(statusPhase, 'to register').text}
273+
{getTimeLeft(statusPhase, 'to go').text}
282274
</div>
283275
</div>
284276
) : <ChallengeProgressBar color="gray" value="100" />
@@ -304,6 +296,7 @@ ChallengeStatus.defaultProps = {
304296
detailLink: '',
305297
openChallengesInNewTabs: false,
306298
className: '',
299+
userId: '',
307300
};
308301

309302
ChallengeStatus.propTypes = {
@@ -314,4 +307,5 @@ ChallengeStatus.propTypes = {
314307
openChallengesInNewTabs: PT.bool, // eslint-disable-line react/no-unused-prop-types
315308
selectChallengeDetailsTab: PT.func.isRequired,
316309
className: PT.string,
310+
userId: PT.string,
317311
};

src/shared/components/challenge-listing/ChallengeCard/index.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function ChallengeCard({
3333
openChallengesInNewTabs,
3434
sampleWinnerProfile,
3535
selectChallengeDetailsTab,
36-
userHandle,
36+
userId,
3737
domRef,
3838
}) {
3939
const challenge = passedInChallenge;
@@ -116,7 +116,7 @@ function ChallengeCard({
116116
openChallengesInNewTabs={openChallengesInNewTabs}
117117
sampleWinnerProfile={sampleWinnerProfile}
118118
selectChallengeDetailsTab={selectChallengeDetailsTab}
119-
userHandle={userHandle}
119+
userId={userId}
120120
/>
121121
</div>
122122
</div>
@@ -130,7 +130,7 @@ ChallengeCard.defaultProps = {
130130
onTechTagClicked: _.noop,
131131
openChallengesInNewTabs: false,
132132
sampleWinnerProfile: undefined,
133-
userHandle: '',
133+
userId: '',
134134
expandedTags: [],
135135
expandTag: null,
136136
domRef: null,
@@ -145,7 +145,7 @@ ChallengeCard.propTypes = {
145145
openChallengesInNewTabs: PT.bool,
146146
sampleWinnerProfile: PT.shape(),
147147
selectChallengeDetailsTab: PT.func.isRequired,
148-
userHandle: PT.string,
148+
userId: PT.string,
149149
expandedTags: PT.arrayOf(PT.number),
150150
expandTag: PT.func,
151151
domRef: PT.func,

src/shared/components/challenge-listing/LeaderboardAvatar/style.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ $leader-radius-4: $corner-radius * 2;
6868
background: $tc-dark-blue-30;
6969
color: $tc-dark-blue-100;
7070
}
71+
72+
&.placement-5 {
73+
background: $tc-dark-blue-30;
74+
color: $tc-dark-blue-100;
75+
}
76+
77+
&.placement-6 {
78+
background: $tc-dark-blue-30;
79+
color: $tc-dark-blue-100;
80+
}
7181
}
7282

7383
.hidden {

src/shared/components/challenge-listing/Listing/Bucket/index.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function Bucket({
4242
setFilterState,
4343
setSort,
4444
sort,
45-
userHandle,
45+
userId,
4646
expandedTags,
4747
expandTag,
4848
activeBucket,
@@ -109,7 +109,7 @@ export default function Bucket({
109109
prizeMode={prizeMode}
110110
key={item.id}
111111
selectChallengeDetailsTab={selectChallengeDetailsTab}
112-
userHandle={userHandle}
112+
userId={userId}
113113
expandedTags={expandedTags}
114114
expandTag={expandTag}
115115
domRef={addToRefs}
@@ -187,7 +187,7 @@ Bucket.defaultProps = {
187187
newChallengeDetails: false,
188188
openChallengesInNewTabs: false,
189189
sort: null,
190-
userHandle: '',
190+
userId: '',
191191
expandedTags: [],
192192
expandTag: null,
193193
activeBucket: '',
@@ -214,7 +214,7 @@ Bucket.propTypes = {
214214
setFilterState: PT.func.isRequired,
215215
setSort: PT.func.isRequired,
216216
sort: PT.string,
217-
userHandle: PT.string,
217+
userId: PT.string,
218218
expandedTags: PT.arrayOf(PT.number),
219219
expandTag: PT.func,
220220
activeBucket: PT.string,

src/shared/components/challenge-listing/Listing/index.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function Listing({
4545
expandTag,
4646
pastSearchTimestamp,
4747
}) {
48-
const buckets = getBuckets(_.get(auth.user, 'handle'));
48+
const buckets = getBuckets(_.get(auth.user, 'userId'));
4949
const isChallengesAvailable = (bucket) => {
5050
const filter = Filter.getFilterFunction(buckets[bucket].filter);
5151
const clonedChallenges = _.clone(challenges);
@@ -117,7 +117,7 @@ function Listing({
117117
setFilterState={setFilterState}
118118
setSort={sort => setSort(bucket, sort)}
119119
sort={sorts[bucket]}
120-
userHandle={_.get(auth, 'user.handle')}
120+
userId={_.get(auth, 'user.userId')}
121121
activeBucket={activeBucket}
122122
searchTimestamp={searchTimestamp}
123123
/>
@@ -183,7 +183,7 @@ Listing.propTypes = {
183183
auth: PT.shape({
184184
tokenV3: PT.string,
185185
user: PT.shape({
186-
handle: PT.string,
186+
userId: PT.string,
187187
}),
188188
}).isRequired,
189189
challenges: PT.arrayOf(PT.shape()),

src/shared/containers/challenge-listing/Sidebar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class SidebarContainer extends React.Component {
6262
user,
6363
} = this.props;
6464

65-
const buckets = getBuckets(user && user.handle);
65+
const buckets = getBuckets(user && user.userId);
6666

6767
if (extraBucket) {
6868
buckets[extraBucket.name] = extraBucket;

src/shared/utils/challenge-listing/buckets.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,12 @@ export const NO_LIVE_CHALLENGES_CONFIG = {
132132

133133
/**
134134
* Returns configuration of all possible challenge buckets.
135-
* @param {String} userHandle Handle of the authenticated
135+
* @param {String} userId id of the authenticated
136136
* user to filter out My Challenges.
137137
*/
138-
export function getBuckets(userHandle) {
138+
export function getBuckets(userId) {
139139
const res = _.cloneDeep(BUCKET_DATA);
140-
// TODO: Find equivalent of users
141-
res[BUCKETS.MY].filter.users = [userHandle];
140+
res[BUCKETS.MY].filter.users = [userId];
142141
return res;
143142
}
144143

0 commit comments

Comments
 (0)