Skip to content

Commit 1128d52

Browse files
committed
RDM submission download support
1 parent d5acd6a commit 1128d52

File tree

7 files changed

+33
-8
lines changed

7 files changed

+33
-8
lines changed

src/shared/components/challenge-detail/Submissions/SubmissionRow/SubmissionHistoryRow/index.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const { getService } = services.submissions;
2121

2222
export default function SubmissionHistoryRow({
2323
isMM,
24+
isRDM,
2425
submission,
2526
finalScore,
2627
provisionalScore,
@@ -81,7 +82,7 @@ export default function SubmissionHistoryRow({
8182
</div>
8283
</div>
8384
{
84-
isLoggedIn && isMM
85+
isLoggedIn && (isMM || isRDM)
8586
&& (numWinners > 0 || challengeStatus === CHALLENGE_STATUS.COMPLETED) && (
8687
<div styleName="col-2 col center">
8788
<div styleName="mobile-header">Action</div>
@@ -121,6 +122,7 @@ SubmissionHistoryRow.defaultProps = {
121122

122123
SubmissionHistoryRow.propTypes = {
123124
isMM: PT.bool.isRequired,
125+
isRDM: PT.bool.isRequired,
124126
submission: PT.number.isRequired,
125127
finalScore: PT.oneOfType([
126128
PT.number,

src/shared/components/challenge-detail/Submissions/SubmissionRow/index.jsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import SubmissionHistoryRow from './SubmissionHistoryRow';
1919
import style from './style.scss';
2020

2121
export default function SubmissionRow({
22-
isMM, openHistory, member, submissions, score, toggleHistory, challengeStatus,
22+
isMM, isRDM, openHistory, member, submissions, score, toggleHistory, challengeStatus,
2323
isReviewPhaseComplete, finalRank, provisionalRank, onShowPopup, rating, viewAsTable,
2424
numWinners, auth, isLoggedIn,
2525
}) {
@@ -166,7 +166,8 @@ export default function SubmissionRow({
166166
Time
167167
</div>
168168
{
169-
isMM && (numWinners > 0 || challengeStatus === CHALLENGE_STATUS.COMPLETED) && (
169+
(isMM || isRDM)
170+
&& (numWinners > 0 || challengeStatus === CHALLENGE_STATUS.COMPLETED) && (
170171
<div styleName="col-2 col center">
171172
Action
172173
</div>
@@ -185,6 +186,7 @@ export default function SubmissionRow({
185186
<SubmissionHistoryRow
186187
isReviewPhaseComplete={isReviewPhaseComplete}
187188
isMM={isMM}
189+
isRDM={isRDM}
188190
challengeStatus={challengeStatus}
189191
submission={submissions.length - index}
190192
{...submissionHistory}
@@ -224,6 +226,7 @@ SubmissionRow.defaultProps = {
224226

225227
SubmissionRow.propTypes = {
226228
isMM: PT.bool.isRequired,
229+
isRDM: PT.bool.isRequired,
227230
openHistory: PT.bool.isRequired,
228231
member: PT.string.isRequired,
229232
challengeStatus: PT.string.isRequired,

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import React from 'react';
77
import PT from 'prop-types';
88
import moment from 'moment';
9-
import { isMM as checkIsMM } from 'utils/challenge';
9+
import { isMM as checkIsMM, isRDM as checkIsRDM } from 'utils/challenge';
1010
import _ from 'lodash';
1111
import { connect } from 'react-redux';
1212
import { config } from 'topcoder-react-utils';
@@ -309,6 +309,7 @@ class SubmissionsComponent extends React.Component {
309309
} = challenge;
310310

311311
const isMM = this.isMM();
312+
const isRDM = checkIsRDM(challenge);
312313
const isLoggedIn = !_.isEmpty(auth.tokenV3);
313314
const isReviewPhaseComplete = this.checkIsReviewPhaseComplete();
314315

@@ -604,7 +605,7 @@ class SubmissionsComponent extends React.Component {
604605
}
605606
{
606607
((numWinners > 0 || challenge.status === CHALLENGE_STATUS.COMPLETED)
607-
&& isMM && isLoggedIn) && (
608+
&& (isMM || isRDM) && isLoggedIn) && (
608609
<div styleName="block-download-all">
609610
<button
610611
disabled={downloadingAll}
@@ -845,6 +846,7 @@ class SubmissionsComponent extends React.Component {
845846
submissions={sortedSubmissions}
846847
isReviewPhaseComplete={isReviewPhaseComplete}
847848
isMM={isMM}
849+
isRDM={isRDM}
848850
key={submission.member}
849851
{...submission}
850852
challengeStatus={challenge.status}

src/shared/components/challenge-detail/Winners/Winner/index.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function getId(submissions, placement) {
1919
export default function Winner({
2020
isDesign,
2121
isMM,
22+
isRDM,
2223
prizes,
2324
submissions,
2425
viewable,
@@ -89,7 +90,7 @@ export default function Winner({
8990
</div>
9091
<div styleName="download-container">
9192
{
92-
((!winner.submissionDownloadLink || !viewable) && isMM && isLoggedIn) && (
93+
((!winner.submissionDownloadLink || !viewable) && (isMM || isRDM) && isLoggedIn) && (
9394
<button
9495
onClick={() => {
9596
// download submission
@@ -145,6 +146,7 @@ Winner.defaultProps = {
145146
Winner.propTypes = {
146147
isDesign: PT.bool.isRequired,
147148
isMM: PT.bool.isRequired,
149+
isRDM: PT.bool.isRequired,
148150
prizes: PT.arrayOf(PT.shape()),
149151
submissions: PT.arrayOf(PT.object).isRequired,
150152
viewable: PT.bool.isRequired,

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default function Winners({
2222
viewable,
2323
isDesign,
2424
isMM,
25+
isRDM,
2526
isLoggedIn,
2627
auth,
2728
challengeStatus,
@@ -31,7 +32,7 @@ export default function Winners({
3132
<div styleName="container">
3233
{
3334
((winners.length > 0 || challengeStatus === CHALLENGE_STATUS.COMPLETED)
34-
&& isMM && isLoggedIn) && (
35+
&& (isMM || isRDM) && isLoggedIn) && (
3536
<div styleName="block-download-all">
3637
<button
3738
disabled={downloadingAll}
@@ -80,6 +81,7 @@ export default function Winners({
8081
<Winner
8182
isDesign={isDesign}
8283
isMM={isMM}
84+
isRDM={isRDM}
8385
key={`${w.handle}-${w.placement}`}
8486
prizes={prizes}
8587
submissions={submissions}
@@ -101,6 +103,7 @@ Winners.defaultProps = {
101103
viewable: false,
102104
isDesign: false,
103105
isMM: false,
106+
isRDM: false,
104107
isLoggedIn: false,
105108
challengeStatus: '',
106109
};
@@ -112,6 +115,7 @@ Winners.propTypes = {
112115
viewable: PT.bool,
113116
isDesign: PT.bool,
114117
isMM: PT.bool,
118+
isRDM: PT.bool,
115119
isLoggedIn: PT.bool,
116120
challengeStatus: PT.string,
117121
auth: PT.shape().isRequired,

src/shared/containers/challenge-detail/index.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import _ from 'lodash';
1010
import communityActions from 'actions/tc-communities';
11-
import { isMM as checkIsMM } from 'utils/challenge';
11+
import { isMM as checkIsMM, isRDM as checkIsRDM } from 'utils/challenge';
1212
import LoadingPagePlaceholder from 'components/LoadingPagePlaceholder';
1313
import pageActions from 'actions/page';
1414
import ChallengeHeader from 'components/challenge-detail/Header';
@@ -439,6 +439,7 @@ class ChallengeDetailPageContainer extends React.Component {
439439

440440
const isEmpty = _.isEmpty(challenge);
441441
const isMM = checkIsMM(challenge);
442+
const isRDM = checkIsRDM(challenge);
442443
const isLegacyMM = isMM && Boolean(challenge.roundId);
443444

444445
if (isLoadingChallenge || isLoadingTerms) {
@@ -661,6 +662,7 @@ class ChallengeDetailPageContainer extends React.Component {
661662
submissions={challenge.submissions}
662663
isDesign={track.toLowerCase() === 'design'}
663664
isMM={isMM}
665+
isRDM={isRDM}
664666
isLoggedIn={isLoggedIn}
665667
auth={auth}
666668
/>

src/shared/utils/challenge.js

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ export function isMM(challenge) {
1313
return tags.includes('Marathon Match') || isMMType;
1414
}
1515

16+
/**
17+
* check if is rapid development match challenge
18+
* @param {Object} challenge challenge object
19+
*/
20+
export function isRDM(challenge) {
21+
const tags = _.get(challenge, 'tags') || [];
22+
const isMMType = challenge ? challenge.type === 'Rapid Development Match' : false;
23+
return tags.includes('Rapid Development Match') || isMMType;
24+
}
25+
1626
/**
1727
* Set challenge type to challenge
1828
* @param {Object} challenges challenge object

0 commit comments

Comments
 (0)