Skip to content

Issue 4450 fix #4494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
dfeec86
<Registrants> update propTypes with new param in V5 API
luizrrodrigues May 27, 2020
b9c25b0
Fix regex to challengeId (to support UUID)
luizrrodrigues Jun 2, 2020
069bf7c
Update prizeSets.type from Challenge Prize to placement
luizrrodrigues Jun 3, 2020
4bd1737
Updated URL params :challengeId to allow legacyID and UUID
luizrrodrigues Jun 3, 2020
a018d7e
Added validation if receive challenge tags before get recommendedChal…
luizrrodrigues Jun 4, 2020
6acb8ef
Update vars to match with V5 API
luizrrodrigues Jun 4, 2020
28e4c44
Fix lint
luizrrodrigues Jun 4, 2020
d76a92f
Merge branch 'issue-4378' into issue-4408
luizrrodrigues Jun 6, 2020
6f21672
Added default colorStyle to all members (temp solution)
luizrrodrigues Jun 8, 2020
f75b3d4
Reactivated the proxy-get to support calls to resources_api
luizrrodrigues Jun 8, 2020
16b5896
Challenge listing - Added check if challenge.events is empty
luizrrodrigues Jun 8, 2020
0777387
Merge pull request #4487 from rashmi73/issue_4482
sushilshinde Jun 8, 2020
e36c4c4
Challenge Details - Fix isRegistered function
luizrrodrigues Jun 8, 2020
e6fdf24
Merge branch 'integration-v5-challenge-api' into issue-4408
luizrrodrigues Jun 8, 2020
94f7383
Merge pull request #4489 from rashmi73/issue_4482
sushilshinde Jun 8, 2020
4e28176
fix: for #4384
sushilshinde Jun 8, 2020
8e48f49
Merge pull request #4431 from topcoder-platform/issue-4408
sushilshinde Jun 8, 2020
9c7d6ce
fix: #4480,#4408,#4381
sushilshinde Jun 8, 2020
ce10cf6
Merge pull request #26 from topcoder-platform/integration-v5-challeng…
PrakashDurlabhji Jun 8, 2020
cff0134
Update index.jsx
PrakashDurlabhji Jun 8, 2020
6cf48d3
Merge branch 'integration-v5-challenge-api' into issue_4450
PrakashDurlabhji Jun 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Application from 'shared';
import config from 'config';
import express from 'express';
import fetch from 'isomorphic-fetch';
import { logger } from 'topcoder-react-lib';
import { logger, services } from 'topcoder-react-lib';
import fs from 'fs';
import moment from 'moment';
import path from 'path';
Expand Down Expand Up @@ -160,19 +160,21 @@ async function onExpressJsSetup(server) {

/* Proxy endpoint for GET requests (to fetch data from resources prohibiting
* cross-origin requests). */
/* server.use(
server.use(
'/community-app-assets/api/proxy-get',
checkAuthorizationHeader, async (req, res, next) => {
const tokenM2M = await services.api.getTcM2mToken();
try {
let data = await fetch(req.query.url);
let data = await fetch(req.query.url, {
headers: { Authorization: `Bearer ${tokenM2M}` },
});
data = await data.text();
res.send(data);
} catch (err) {
next(err);
}
},
);
*/

/* Proxy endpoint for POST requests (to fetch data from resources prohibiting
* cross-origin requests). */
Expand Down
2 changes: 1 addition & 1 deletion src/server/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ workbox.routing.registerRoute(/\/challenges(\/)?(\?.*)?$/, async ({ event, url }
}, 'GET');

// Serve challenge details pages like: /challenges/12345678
workbox.routing.registerRoute(/\/challenges\/\d+(\/)?(.*)/, async ({ event, url }) => {
workbox.routing.registerRoute(/\/challenges\/(([\w]{4,12}-?){5}|\d+)\/?(\?.*)?/, async ({ event, url }) => {
if (url.pathname.endsWith('/')) {
// Remove ending '/' char
url.pathname = url.pathname.substring(0, url.pathname.length - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function ChallengesCard({
<TrackIcon
track={track}
subTrack={challenge.subTrack}
tcoEligible={challenge.events && challenge.events.length > 0 ? challenge.events[0].eventName : ''}
tcoEligible={!_.isEmpty(challenge.events) ? challenge.events[0].eventName : ''}
isDataScience={challenge.isDataScience}
challengesUrl={challengesUrl}
/>
Expand Down
46 changes: 26 additions & 20 deletions src/shared/components/challenge-detail/Registrants/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function formatDate(date) {
}

function getDate(arr, handle) {
const results = arr.filter(a => _.toString(a.submitter || a.handle) === _.toString(handle))
const results = arr.filter(a => _.toString(a.submitter || a.memberHandle) === _.toString(handle))
.sort((a, b) => new Date(b.submissionTime || b.submissionDate).getTime()
- new Date(a.submissionTime || a.submissionDate).getTime());
return results[0] ? (results[0].submissionTime || results[0].submissionDate) : '';
Expand All @@ -32,7 +32,7 @@ function passedCheckpoint(checkpoints, handle, results) {
}

function getPlace(results, handle, places) {
const found = _.find(results, w => _.toString(w.handle) === _.toString(handle)
const found = _.find(results, w => _.toString(w.memberHandle) === _.toString(handle)
&& w.placement <= places && w.submissionStatus !== 'Failed Review');

if (found) {
Expand Down Expand Up @@ -99,7 +99,7 @@ export default class Registrants extends React.Component {

let checkpoint;
if (twoRounds) {
checkpoint = getDate(checkpoints, registrant.handle);
checkpoint = getDate(checkpoints, registrant.memberHandle);
if (!checkpoint
&& moment(registrant.submissionDate).isBefore(checkpointDate)) {
checkpoint = registrant.submissionDate;
Expand Down Expand Up @@ -188,8 +188,8 @@ export default class Registrants extends React.Component {
break;
}
case 'Username': {
valueA = `${a.handle}`.toLowerCase();
valueB = `${b.handle}`.toLowerCase();
valueA = `${a.memberHandle}`.toLowerCase();
valueB = `${b.memberHandle}`.toLowerCase();
valueIsString = true;
break;
}
Expand Down Expand Up @@ -239,22 +239,22 @@ export default class Registrants extends React.Component {
onSortChange,
} = this.props;
const {
prizes,
prizeSets,
legacy,
} = challenge;
const { track } = legacy;
const { sortedRegistrants } = this.state;
const { field, sort } = this.getRegistrantsSortParam();
const revertSort = (sort === 'desc') ? 'asc' : 'desc';
const isDesign = track.toLowerCase() === 'design';
const isF2F = challenge.subTrack.indexOf('FIRST_2_FINISH') > -1;
const isBugHunt = challenge.subTrack.indexOf('BUG_HUNT') > -1;
const isF2F = challenge.type.toLowerCase().indexOf('first2finish') > -1;
const isBugHunt = challenge.type.toLowerCase() === 'bug hunt';

const checkpoints = challenge.checkpoints || [];

const twoRounds = challenge.round1Introduction
&& challenge.round2Introduction;
const places = prizes.length;
const places = prizeSets.find(ps => ps.type === 'placement').prizes.lenght;
return (
<div styleName={`container ${twoRounds ? 'design' : ''}`} role="table" aria-label="Registrants">
<div styleName="head" role="row">
Expand Down Expand Up @@ -379,8 +379,14 @@ export default class Registrants extends React.Component {
<div styleName="body" role="rowgroup">
{
sortedRegistrants.map((r) => {
const placement = getPlace(results, r.handle, places);
const colorStyle = JSON.parse(r.colorStyle.replace(/(\w+):\s*([^;]*)/g, '{"$1": "$2"}'));
const placement = getPlace(results, r.memberHandle, places);
/*
* TODO: Need check as get this back, currenlty V5 API missing this data
* = JSON.parse(r.colorStyle.replace(/(\w+):\s*([^;]*)/g, '{"$1": "$2"}'));
*/
const colorStyle = {
color: '#000000',
};
let checkpoint = this.getCheckPoint(r);
if (checkpoint) {
checkpoint = formatDate(checkpoint);
Expand All @@ -393,7 +399,7 @@ export default class Registrants extends React.Component {
}

return (
<div styleName="row" key={r.handle} role="row">
<div styleName="row" key={r.memberHandle} role="row">
{
!isDesign && !isF2F && !isBugHunt && (
<div styleName="col-2">
Expand All @@ -411,19 +417,19 @@ export default class Registrants extends React.Component {
<div styleName="col-3">
<span role="cell">
<a
href={`${window.origin}/members/${r.handle}`}
href={`${window.origin}/members/${r.memberHandle}`}
style={colorStyle}
target={`${_.includes(window.origin, 'www') ? '_self' : '_blank'}`}
>
{r.handle}
{r.memberHandle}
</a>
</span>
</div>
<div styleName="col-4">
<div styleName="sm-only title">
Registration Date
</div>
<span role="cell">{formatDate(r.registrationDate)}</span>
<span role="cell">{formatDate(r.created)}</span>
</div>
{
twoRounds
Expand All @@ -437,7 +443,7 @@ export default class Registrants extends React.Component {
{checkpoint}
</span>
{
passedCheckpoint(checkpoints, r.handle, checkpointResults)
passedCheckpoint(checkpoints, r.memberHandle, checkpointResults)
&& <CheckMark styleName="passed" />
}
</div>
Expand Down Expand Up @@ -482,16 +488,16 @@ Registrants.propTypes = {
challenge: PT.shape({
phases: PT.arrayOf(PT.shape({
actualEndDate: PT.string,
phaseType: PT.string.isRequired,
name: PT.string.isRequired,
scheduledEndDate: PT.string,
})).isRequired,
allPhases: PT.arrayOf(PT.shape()),
checkpoints: PT.arrayOf(PT.shape()),
legacy: PT.shape({
track: PT.any,
track: PT.string,
}),
subTrack: PT.any,
prizes: PT.arrayOf(PT.number).isRequired,
type: PT.string,
prizeSets: PT.arrayOf(PT.shape()).isRequired,
registrants: PT.arrayOf(PT.shape()).isRequired,
round1Introduction: PT.string,
round2Introduction: PT.string,
Expand Down
12 changes: 12 additions & 0 deletions src/shared/components/challenge-detail/Specification/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ export default function ChallengeDetailsView(props) {
description
&& (
<article>
<h2 styleName="h2">
Challenge Summary
</h2>
{
editMode ? (
<Editor
Expand All @@ -229,6 +232,15 @@ export default function ChallengeDetailsView(props) {
/>
)
}
<p styleName="p" />
<p styleName="p note">
Please read the challenge specification carefully and
watch the forums for any questions or feedback
concerning this challenge. It is important that you
monitor any updates provided by the client or Studio
Admins in the forums. Please post any questions you
might have for the client in the forums.
</p>
</article>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ class SubmissionsComponent extends React.Component {
</div>
);

const isF2F = challenge.subTrack.indexOf('FIRST_2_FINISH') > -1;
const isBugHunt = challenge.subTrack.indexOf('BUG_HUNT') > -1;
const isF2F = challenge.type.toLowerCase().indexOf('first2finish') > -1;
const isBugHunt = challenge.type.toLowerCase() === 'bug hunt';

// copy colorStyle from registrants to submissions
_.forEach(sortedSubmissions, (s) => {
Expand Down Expand Up @@ -785,7 +785,7 @@ SubmissionsComponent.propTypes = {
registrants: PT.any,
allPhases: PT.any,
phases: PT.any,
subTrack: PT.any,
type: PT.any,
}).isRequired,
toggleSubmissionHistory: PT.func.isRequired,
submissionHistoryOpen: PT.shape({}).isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function ChallengeCard({
<TrackIcon
track={track}
subTrack={subTrack}
tcoEligible={challenge.events && challenge.events.length > 0 ? challenge.events[0].eventName : ''}
tcoEligible={!_.isEmpty(challenge.events) ? challenge.events[0].eventName : ''}
isDataScience={challenge.isDataScience}
/>
</span>
Expand Down
7 changes: 4 additions & 3 deletions src/shared/containers/challenge-detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function isRegistered(details, registrants, handle) {
if (details && details.roles && details.roles.includes('Submitter')) {
return true;
}
if (_.find(registrants, r => _.toString(r.handle) === _.toString(handle))) {
if (_.find(registrants, r => _.toString(r.memberHandle) === _.toString(handle))) {
return true;
}
return false;
Expand Down Expand Up @@ -231,6 +231,7 @@ class ChallengeDetailPageContainer extends React.Component {
challenge
&& challenge.id === challengeId
&& !loadingRecommendedChallengesUUID
&& recommendedTechnology
&& (
!recommendedChallenges[recommendedTechnology]
|| (
Expand Down Expand Up @@ -731,15 +732,15 @@ function mapStateToProps(state, props) {
if (challenge.submissions) {
challenge.submissions = challenge.submissions.map(submission => ({
...submission,
registrant: _.find(challenge.registrants, { handle: submission.submitter }),
registrant: _.find(challenge.registrants, { memberHandle: submission.createdBy }),
}));
}

if (mmSubmissions) {
mmSubmissions = mmSubmissions.map((submission) => {
let registrant;
let { member } = submission;
if (auth.user.handle === submission.member) {
if (auth.user.handle === submission.memberHandle) {
mySubmissions = submission.submissions || [];
mySubmissions = mySubmissions.map((mySubmission, index) => {
// eslint-disable-next-line no-param-reassign
Expand Down
12 changes: 6 additions & 6 deletions src/shared/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ function generateSsrOptions(req) {
const res = {
auth: getAuthTokens(req),
};
if (req.url.match(/^\/challenges\/\d+\/my-submissions/)) {
const challengeId = req.url.match(/\d+/)[0];
if (req.url.match(/^\/challenges\/(([\w]{4,12}-?){5}|\d+)\/my-submissions/)) {
const challengeId = req.url.match(/(([\w]{4,12}-?){5}|\d+)/)[0];
_.set(res, 'challenge.challengeDetails.id', challengeId);
_.set(res, 'challenge.challengeDetails.mySubmission', true);
} else if (req.url.match(/\/challenges\/\d+([?/].*)?$/)) {
const challengeId = req.url.match(/\d+/)[0];
} else if (req.url.match(/\/challenges\/(([\w]{4,12}-?){5}|\d+)\/?(\?.*)?$/)) {
const challengeId = req.url.match(/(([\w]{4,12}-?){5}|\d+)/)[0];
_.set(res, 'challenge.challengeDetails.id', challengeId);
}

Expand All @@ -62,8 +62,8 @@ function generateSsrOptions(req) {
let entity;

// if it's challenge details page
if (req.url.match(/^\/challenges\/\d+/)) {
const challengeId = req.url.match(/\d+/)[0];
if (req.url.match(/^\/challenges\/(([\w]{4,12}-?){5}|\d+)/)) {
const challengeId = req.url.match(/(([\w]{4,12}-?){5}|\d+)/)[0];
entity = { type: 'challenge', id: challengeId };
}

Expand Down
4 changes: 2 additions & 2 deletions src/shared/reducers/reviewOpportunity.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { reducers } from 'topcoder-react-lib';
*/
export function factory(req) {
const options = {};
if (req && req.url.match(/^\/challenges\/\d{8}\/review-opportunities/)) {
if (req && req.url.match(/^\/challenges\/(([\w]{4,12}-?){5}|\d+)\/review-opportunities/)) {
options.auth = getAuthTokens(req);
const challengeId = req.url.match(/\d+/)[0];
const challengeId = req.url.match(/(([\w]{4,12}-?){5}|\d+)/)[0];
_.set(options, 'reviewOpportunity.challenge.id', challengeId);
}

Expand Down
4 changes: 2 additions & 2 deletions src/shared/reducers/terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ export function factory(req) {
let entity;

// if it's challenge details page
if (req.url.match(/^\/challenges\/\d+/)) {
const challengeId = req.url.match(/\d+/)[0];
if (req.url.match(/^\/challenges\/(([\w]{4,12}-?){5}|\d+)/)) {
const challengeId = req.url.match(/(([\w]{4,12}-?){5}|\d+)/)[0];
entity = { type: 'challenge', id: challengeId };
}

Expand Down
6 changes: 3 additions & 3 deletions src/shared/routes/Communities/Comcast/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ export default function CS({ base, meta }) {
communityId: meta.communityId,
})}
exact
path={`${base}/work/:challengeId(\\d{8}|\\d{5})`}
path={`${base}/work/:challengeId(((([\\w]{4,12}-?){5}|\\d+)))`}
/>
<Route
component={routeProps => Submission({
...routeProps,
challengesUrl: `${base}/work`,
})}
exact
path={`${base}/work/:challengeId(\\d{8}|\\d{5})/submit`}
path={`${base}/work/:challengeId(((([\\w]{4,12}-?){5}|\\d+)))/submit`}
/>
<Route
component={routeProps => SubmissionManagement({
...routeProps,
challengesUrl: `${base}/work`,
})}
exact
path={`${base}/work/:challengeId(\\d{8}|\\d{5})/my-submissions`}
path={`${base}/work/:challengeId(((([\\w]{4,12}-?){5}|\\d+))/my-submissions`}
/>
<Route
component={TermsDetail}
Expand Down
6 changes: 3 additions & 3 deletions src/shared/routes/Topcoder/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export default function Topcoder() {
<Route
component={ReviewOpportunityDetails}
exact
path="/challenges/:challengeId(\d{8}|\d{5})/review-opportunities"
path="/challenges/:challengeId(((([\w]{4,12}-?){5}|\d+)))/review-opportunities"
/>
<Route component={Scoreboard} exact path="/scoreboard/:challengeId(\d+)" />
<Route component={Scoreboard} exact path="/scoreboard/:challengeId(((([\w]{4,12}-?){5}|\d+)))" />
<Route
component={SubmissionManagement}
exact
Expand All @@ -78,7 +78,7 @@ export default function Topcoder() {
<Route
component={Submission}
exact
path="/challenges/:challengeId(\d{8}|\d{5})/submit"
path="/challenges/:challengeId(((([\w]{4,12}-?){5}|\d+)))/submit"
/>
<Route
component={Profile}
Expand Down