Skip to content

Commit 79c1eb2

Browse files
authored
Merge pull request #6974 from topcoder-platform/develop
PROD - hide download buttons on submissions for Topcrowd / Phoenix challenges
2 parents 94b5fa2 + f77c875 commit 79c1eb2

File tree

7 files changed

+84
-41
lines changed

7 files changed

+84
-41
lines changed

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

+21-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import './styles.scss';
2727

2828
export default function Submission(props) {
2929
const {
30+
challenge,
3031
submissionObject,
3132
showScreeningDetails,
3233
track,
@@ -40,6 +41,15 @@ export default function Submission(props) {
4041
const onDownloadSubmission = onDownload.bind(1, submissionObject.id);
4142
const safeForDownloadCheck = safeForDownload(submissionObject.url);
4243

44+
// Determine if a challenge is for Topcrowd so we can edit the UI accordingly
45+
let isTopCrowdChallenge = false;
46+
if (challenge) {
47+
const isTopCrowdChallengeData = _.find(challenge.metadata, { name: 'is_platform' });
48+
if (isTopCrowdChallengeData) {
49+
isTopCrowdChallenge = isTopCrowdChallengeData.value;
50+
}
51+
}
52+
4353
return (
4454
<tr styleName="submission-row">
4555
<td styleName="id-col">
@@ -72,12 +82,16 @@ export default function Submission(props) {
7282
}
7383
<td styleName="action-col">
7484
<div>
75-
<button
76-
onClick={() => onDownloadSubmission(submissionObject.id)}
77-
type="button"
78-
>
79-
{ safeForDownloadCheck === true && <DownloadIcon /> }
80-
</button>
85+
{ !isTopCrowdChallenge
86+
? (
87+
<button
88+
onClick={() => onDownloadSubmission(submissionObject.id)}
89+
type="button"
90+
>
91+
{ safeForDownloadCheck === true && <DownloadIcon /> }
92+
</button>
93+
)
94+
: <span /> }
8195
{ /*
8296
TODO: At the moment we just fetch downloads from the legacy
8397
Topcoder Studio API, and we don't need any JS code to this.
@@ -121,6 +135,7 @@ Submission.defaultProps = {
121135
};
122136

123137
Submission.propTypes = {
138+
challenge: PT.shape().isRequired,
124139
submissionObject: PT.shape({
125140
id: PT.string,
126141
legacySubmissionId: PT.string,

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export default function SubmissionManagement(props) {
171171
{!loadingSubmissions
172172
&& (
173173
<SubmissionsTable
174+
challenge={challenge}
174175
submissionObjects={submissions}
175176
showDetails={showDetails}
176177
track={track}
@@ -212,13 +213,13 @@ SubmissionManagement.defaultProps = {
212213
};
213214

214215
SubmissionManagement.propTypes = {
216+
challenge: PT.shape().isRequired,
215217
showDetails: PT.shape().isRequired,
216218
onDelete: PT.func,
217219
onlineReviewUrl: PT.string,
218220
helpPageUrl: PT.string,
219221
onDownload: PT.func,
220222
onShowDetails: PT.func,
221-
challenge: PT.shape().isRequired,
222223
submissions: PT.arrayOf(PT.shape()),
223224
loadingSubmissions: PT.bool,
224225
challengeUrl: PT.string,

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

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import './styles.scss';
2626

2727
export default function SubmissionsTable(props) {
2828
const {
29+
challenge,
2930
submissionObjects,
3031
showDetails,
3132
track,
@@ -56,6 +57,7 @@ export default function SubmissionsTable(props) {
5657

5758
const submission = (
5859
<Submission
60+
challenge={challenge}
5961
submissionObject={subObject}
6062
showScreeningDetails={showDetails[subObject.id]}
6163
track={track}
@@ -140,6 +142,7 @@ SubmissionsTable.defaultProps = {
140142
};
141143

142144
SubmissionsTable.propTypes = {
145+
challenge: PT.shape().isRequired,
143146
submissionObjects: PT.arrayOf(SubShape),
144147
showDetails: PT.shape().isRequired,
145148
track: PT.string.isRequired,

src/shared/components/challenge-detail/MySubmissions/SubmissionsList/index.jsx

+33-26
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ class SubmissionsListView extends React.Component {
187187
timeClicked: false,
188188
};
189189

190+
// Determine if a challenge is for Topcrowd so we can edit the UI accordingly
191+
let isTopCrowdChallenge = false;
192+
const isTopCrowdChallengeData = _.find(challenge.metadata, { name: 'is_platform' });
193+
if (isTopCrowdChallengeData) {
194+
isTopCrowdChallenge = isTopCrowdChallengeData.value;
195+
} else {
196+
isTopCrowdChallenge = false;
197+
}
198+
190199
return (
191200
<div styleName="wrapper">
192201
<div styleName="submission-table">
@@ -432,25 +441,29 @@ class SubmissionsListView extends React.Component {
432441
<span>{moment(mySubmission.submissionTime).format('MMM DD, YYYY HH:mm:ss')}</span>
433442
</div>
434443
<div styleName="submission-table-column column-2-4">
435-
<button
436-
onClick={() => {
437-
// download submission
438-
const submissionsService = getService(auth.tokenV3);
439-
submissionsService.downloadSubmission(mySubmission.submissionId)
440-
.then((blob) => {
441-
const url = window.URL.createObjectURL(new Blob([blob]));
442-
const link = document.createElement('a');
443-
link.href = url;
444-
link.setAttribute('download', `submission-${mySubmission.submissionId}.zip`);
445-
document.body.appendChild(link);
446-
link.click();
447-
link.parentNode.removeChild(link);
448-
});
449-
}}
450-
type="button"
451-
>
452-
<DownloadIcon />
453-
</button>
444+
{ !isTopCrowdChallenge
445+
? (
446+
<button
447+
onClick={() => {
448+
// download submission
449+
const submissionsService = getService(auth.tokenV3);
450+
submissionsService.downloadSubmission(mySubmission.submissionId)
451+
.then((blob) => {
452+
const url = window.URL.createObjectURL(new Blob([blob]));
453+
const link = document.createElement('a');
454+
link.href = url;
455+
link.setAttribute('download', `submission-${mySubmission.submissionId}.zip`);
456+
document.body.appendChild(link);
457+
link.click();
458+
link.parentNode.removeChild(link);
459+
});
460+
}}
461+
type="button"
462+
>
463+
<DownloadIcon />
464+
</button>
465+
)
466+
: <span /> }
454467

455468
<button onClick={() => selectSubmission(mySubmission)} type="button">
456469
<ZoomIcon styleName="icon-zoom" />
@@ -523,13 +536,7 @@ SubmissionsListView.defaultProps = {
523536
SubmissionsListView.propTypes = {
524537
selectSubmission: PT.func,
525538
challengesUrl: PT.string.isRequired,
526-
challenge: PT.shape({
527-
id: PT.any,
528-
checkpoints: PT.arrayOf(PT.object),
529-
submissions: PT.arrayOf(PT.object),
530-
submissionViewable: PT.string,
531-
registrants: PT.any,
532-
}).isRequired,
539+
challenge: PT.shape().isRequired,
533540
hasRegistered: PT.bool.isRequired,
534541
unregistering: PT.bool.isRequired,
535542
submissionEnded: PT.bool.isRequired,

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,7 @@ MySubmissionsView.defaultProps = {
125125

126126
MySubmissionsView.propTypes = {
127127
challengesUrl: PT.string.isRequired,
128-
challenge: PT.shape({
129-
id: PT.any,
130-
checkpoints: PT.arrayOf(PT.object),
131-
submissions: PT.arrayOf(PT.object),
132-
submissionViewable: PT.string,
133-
registrants: PT.any,
134-
}).isRequired,
128+
challenge: PT.shape().isRequired,
135129
hasRegistered: PT.bool.isRequired,
136130
unregistering: PT.bool.isRequired,
137131
submissionEnded: PT.bool.isRequired,

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

+23-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default class Registrants extends React.Component {
5858

5959
this.getCheckPoint = this.getCheckPoint.bind(this);
6060
this.getCheckPointDate = this.getCheckPointDate.bind(this);
61+
this.getSubmissionDate = this.getSubmissionDate.bind(this);
6162
this.getFlagFirstTry = this.getFlagFirstTry.bind(this);
6263
this.sortRegistrants = this.sortRegistrants.bind(this);
6364
this.getRegistrantsSortParam = this.getRegistrantsSortParam.bind(this);
@@ -128,6 +129,23 @@ export default class Registrants extends React.Component {
128129
return final;
129130
}
130131

132+
/**
133+
* Get the submission date of a registrant (used when viewing the registrants tab anonymously)
134+
* @param {Object} registrant the registrant to return the submission date for
135+
*/
136+
getSubmissionDate(registrant) {
137+
const {
138+
statisticsData,
139+
} = this.props;
140+
console.log(JSON.stringify(statisticsData, null, 4));
141+
let submissionDate;
142+
const statistic = (statisticsData || []).find(x => x.handle === registrant.memberHandle);
143+
if (statistic && statistic.submissions && statistic.submissions.length > 0) {
144+
submissionDate = statistic.submissions.sort()[0].created;
145+
}
146+
return submissionDate;
147+
}
148+
131149
/**
132150
* Check if it have flag for first try
133151
* @param {Object} registrant registrant info
@@ -413,7 +431,10 @@ export default class Registrants extends React.Component {
413431
if (checkpoint) {
414432
checkpoint = formatDate(checkpoint);
415433
}
416-
const final = this.getFinal(r);
434+
let final = this.getFinal(r);
435+
if (!final) {
436+
final = this.getSubmissionDate(r);
437+
}
417438

418439
return (
419440
<div styleName="row" key={r.memberHandle} role="row">
@@ -523,6 +544,7 @@ Registrants.propTypes = {
523544
type: PT.string,
524545
track: PT.string,
525546
}).isRequired,
547+
statisticsData: PT.arrayOf(PT.shape()).isRequired,
526548
results: PT.arrayOf(PT.shape()),
527549
checkpointResults: PT.shape(),
528550
registrants: PT.arrayOf(PT.shape()),

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

+1
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ class ChallengeDetailPageContainer extends React.Component {
565565
)
566566
}
567567
results={results2}
568+
statisticsData={statisticsData}
568569
registrantsSort={registrantsSort}
569570
notFoundCountryFlagUrl={notFoundCountryFlagUrl}
570571
onGetFlagImageFail={(countryInfo) => {

0 commit comments

Comments
 (0)