Skip to content

Commit 318c33a

Browse files
authored
Merge pull request #6849 from topcoder-platform/develop
PROD Lint fixes and RDM downloading
2 parents 1744656 + 60c98db commit 318c33a

File tree

13 files changed

+124
-97
lines changed

13 files changed

+124
-97
lines changed

.eslintrc

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
"jsx-a11y/anchor-is-valid": false,
55
"import/no-cycle": [2, { "maxDepth": 1 }],
66
"react/forbid-prop-types": false,
7-
"react/no-unknown-property": false,
8-
"react/jsx-no-bind": false,
9-
"react/destructuring-assignment": false,
10-
"react/no-array-index-key": false
7+
"react/no-unknown-property": ["error", { "ignore": ["styleName"] }]
118
},
129
"env": {
1310
"browser": true

src/shared/components/Contentful/AppComponent/index.jsx

+40-22
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,59 @@ import PathSelector from 'components/MemberPath/PathSelector';
1818
const { fireErrorMessage } = errors;
1919

2020
export function AppComponentSwitch(appComponent) {
21-
if (appComponent.fields.type === 'TCO-Leaderboard') {
21+
const {
22+
fields: {
23+
type,
24+
theme,
25+
props,
26+
props: {
27+
leaderboardApiUrl,
28+
title,
29+
podiumSpots,
30+
isCopilot,
31+
hasChallengeHistory,
32+
tcoPointsApiUrl,
33+
memberLimit,
34+
isAlgo,
35+
} = {},
36+
},
37+
sys: { id },
38+
} = appComponent;
39+
if (type === 'TCO-Leaderboard') {
2240
return (
2341
<Leaderboard
24-
id={appComponent.sys.id}
25-
apiUrl={appComponent.fields.props.leaderboardApiUrl}
26-
title={appComponent.fields.props.title}
27-
podiumSpots={appComponent.fields.props.podiumSpots}
28-
isCopilot={appComponent.fields.props.isCopilot}
29-
hasChallengeHistory={appComponent.fields.props.hasChallengeHistory}
30-
tcoPointsApiUrl={appComponent.fields.props.tcoPointsApiUrl}
31-
memberLimit={appComponent.fields.props.memberLimit}
32-
isAlgo={appComponent.fields.props.isAlgo}
33-
key={appComponent.sys.id}
34-
themeName={appComponent.fields.theme}
42+
id={id}
43+
apiUrl={leaderboardApiUrl}
44+
title={title}
45+
podiumSpots={podiumSpots}
46+
isCopilot={isCopilot}
47+
hasChallengeHistory={hasChallengeHistory}
48+
tcoPointsApiUrl={tcoPointsApiUrl}
49+
memberLimit={memberLimit}
50+
isAlgo={isAlgo}
51+
key={id}
52+
themeName={theme}
3553
/>
3654
);
3755
}
38-
if (appComponent.fields.type === 'RecruitCRM-Jobs') {
39-
return <RecruitCRMJobs {...appComponent.fields.props} key={appComponent.sys.id} />;
56+
if (type === 'RecruitCRM-Jobs') {
57+
return <RecruitCRMJobs {...props} key={id} />;
4058
}
41-
if (appComponent.fields.type === 'EmailSubscribeForm') {
42-
return <EmailSubscribeForm {...appComponent.fields.props} key={appComponent.sys.id} />;
59+
if (type === 'EmailSubscribeForm') {
60+
return <EmailSubscribeForm {...props} key={id} />;
4361
}
44-
if (appComponent.fields.type === 'GSheet') {
45-
return <GSheet {...appComponent.fields.props} key={appComponent.sys.id} />;
62+
if (type === 'GSheet') {
63+
return <GSheet {...props} key={id} />;
4664
}
47-
if (appComponent.fields.type === 'MemberPath') {
65+
if (type === 'MemberPath') {
4866
return (
4967
<PathSelector
50-
{...appComponent.fields.props}
51-
key={appComponent.sys.id}
68+
{...props}
69+
key={id}
5270
/>
5371
);
5472
}
55-
fireErrorMessage(`Unsupported app component type ${appComponent.fields.type}`, '');
73+
fireErrorMessage(`Unsupported app component type ${type}`, '');
5674
return null;
5775
}
5876

src/shared/components/Contentful/Viewport/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export function ViewportLoader(props) {
272272
}
273273

274274
if (query) {
275-
queries.push({ ...props.query, content_type: 'viewport' });
275+
queries.push({ ...query, content_type: 'viewport' });
276276
}
277277

278278
return (

src/shared/components/Gigs/ReferralCode/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function ReferralCode(props) {
2525
const [growSurfState, setGrowSurfState] = useState(growSurf);
2626
const [copyBtnText, setCopyBtnText] = useState('COPY');
2727
useEffect(() => {
28-
setGrowSurfState(props.growSurf);
28+
setGrowSurfState(growSurf);
2929
}, [growSurf]);
3030

3131
return (

src/shared/components/Settings/Account/LinkedAccount/ExistingLink.jsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,15 @@ export default function ExistingLink(props) {
6464
return (
6565
<div role="link" styleName={`external-link-tile ${pending ? 'external-link-tile--pending' : ''}`} onClick={e => openLink(e, link)}>
6666
<div styleName="ext-link-tile_edit-header">
67-
<div role="button" onClick={e => onConfirmDeleteLink(e, link)} styleName={`ext-link-tile_edit-header_delete ${link.deleting ? 'ext-link-tile_edit-header_delete--disabled' : ''}`} prevent-event-propagation="true" />
67+
<div
68+
role="button"
69+
onClick={(e) => {
70+
e.preventDefault();
71+
e.stopPropagation();
72+
onConfirmDeleteLink(e, link);
73+
}}
74+
styleName={`ext-link-tile_edit-header_delete ${link.deleting ? 'ext-link-tile_edit-header_delete--disabled' : ''}`}
75+
/>
6876
</div>
6977
<div styleName="top">
7078
<div styleName="logo">
@@ -94,7 +102,7 @@ export default function ExistingLink(props) {
94102
<p className={!pending ? 'hidden' : ''} styleName="link-title">
95103
Loading data. This will take a few minutes.
96104
</p>
97-
<a styleName="link-url" id="link-url" href={prependProtocol(link.URL)} target="_blank" rel="noopener noreferrer" prevent-event-propagation="true">
105+
<a styleName="link-url" id="link-url" href={prependProtocol(link.URL)} target="_blank" rel="noopener noreferrer">
98106
{prependProtocol(link.URL)}
99107
</a>
100108
</div>

src/shared/components/challenge-detail/Header/TabSelector/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ export default function ChallengeViewSelector(props) {
404404
</div>
405405
<div styleName="sort-body">
406406
{
407-
sortOptions.map((option, index) => (
407+
sortOptions.map(option => (
408408
<div
409-
map={`sort-option-${index}`}
409+
key={`sort-option-${option.name}`}
410410
styleName="sort-item"
411411
onClick={() => {
412412
setSelectedSortOption(option.name);

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

+53-52
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,59 @@ class SubmissionsComponent extends React.Component {
478478
) : null
479479
}
480480
<div styleName={`${viewAsTable ? 'view-as-table' : ''}`}>
481+
{
482+
((numWinners > 0 || challenge.status === CHALLENGE_STATUS.COMPLETED)
483+
&& (isMM || isRDM) && isLoggedIn) && (
484+
<div styleName="block-download-all">
485+
<button
486+
disabled={downloadingAll}
487+
styleName="download MM"
488+
onClick={() => {
489+
// download submission
490+
this.setState({
491+
downloadingAll: true,
492+
});
493+
const submissionsService = getService(auth.m2mToken);
494+
const allFiles = [];
495+
let downloadedFile = 0;
496+
const checkToCompressFiles = () => {
497+
if (downloadedFile === sortedSubmissions.length) {
498+
if (downloadedFile > 0) {
499+
compressFiles(allFiles, 'all-submissions.zip', () => {
500+
this.setState({
501+
downloadingAll: false,
502+
});
503+
});
504+
} else {
505+
this.setState({
506+
downloadingAll: false,
507+
});
508+
}
509+
}
510+
};
511+
checkToCompressFiles();
512+
_.forEach(sortedSubmissions, (submission) => {
513+
const mmSubmissionId = submission.submissions
514+
? getSubmissionId(submission.submissions) : submission.id;
515+
submissionsService.downloadSubmission(mmSubmissionId)
516+
.then((blob) => {
517+
const file = new File([blob], `submission-${mmSubmissionId}.zip`);
518+
allFiles.push(file);
519+
downloadedFile += 1;
520+
checkToCompressFiles();
521+
}).catch(() => {
522+
downloadedFile += 1;
523+
checkToCompressFiles();
524+
});
525+
});
526+
}}
527+
type="button"
528+
>
529+
Download All
530+
</button>
531+
</div>
532+
)
533+
}
481534
{
482535
!isMM && (
483536
<div styleName="head">
@@ -603,58 +656,6 @@ class SubmissionsComponent extends React.Component {
603656
</div>
604657
)
605658
}
606-
{
607-
((numWinners > 0 || challenge.status === CHALLENGE_STATUS.COMPLETED)
608-
&& (isMM || isRDM) && isLoggedIn) && (
609-
<div styleName="block-download-all">
610-
<button
611-
disabled={downloadingAll}
612-
styleName="download MM"
613-
onClick={() => {
614-
// download submission
615-
this.setState({
616-
downloadingAll: true,
617-
});
618-
const submissionsService = getService(auth.m2mToken);
619-
const allFiles = [];
620-
let downloadedFile = 0;
621-
const checkToCompressFiles = () => {
622-
if (downloadedFile === sortedSubmissions.length) {
623-
if (downloadedFile > 0) {
624-
compressFiles(allFiles, 'all-winners-submissions.zip', () => {
625-
this.setState({
626-
downloadingAll: false,
627-
});
628-
});
629-
} else {
630-
this.setState({
631-
downloadingAll: false,
632-
});
633-
}
634-
}
635-
};
636-
checkToCompressFiles();
637-
_.forEach(sortedSubmissions, (submission) => {
638-
const mmSubmissionId = isMM && getSubmissionId(submission.submissions);
639-
submissionsService.downloadSubmission(mmSubmissionId)
640-
.then((blob) => {
641-
const file = new File([blob], `submission-${mmSubmissionId}.zip`);
642-
allFiles.push(file);
643-
downloadedFile += 1;
644-
checkToCompressFiles();
645-
}).catch(() => {
646-
downloadedFile += 1;
647-
checkToCompressFiles();
648-
});
649-
});
650-
}}
651-
type="button"
652-
>
653-
Download All
654-
</button>
655-
</div>
656-
)
657-
}
658659
{
659660
isMM && (
660661
<div styleName={`sub-head ${viewAsTable ? 'sub-head-table' : ''}`}>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function Winners({
5656
};
5757
checkToCompressFiles();
5858
_.forEach(winners, (winner) => {
59-
const mmSubmissionId = isMM && getMMSubmissionId(submissions, winner.handle);
59+
const mmSubmissionId = getMMSubmissionId(submissions, winner.handle);
6060
submissionsService.downloadSubmission(mmSubmissionId)
6161
.then((blob) => {
6262
const file = new File([blob], `submission-${mmSubmissionId}.zip`);

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

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import PT from 'prop-types';
88
import React from 'react';
9-
import Tooltip from 'components/Tooltip';
9+
import Tooltip from '../../../Tooltip';
1010
import Tip from './Tip';
1111
import './style.scss';
1212

@@ -35,11 +35,6 @@ export default function Prize({
3535
</div>
3636
);
3737

38-
function placeArrow(TooltipNode) {
39-
const arrow = TooltipNode.querySelector('.rc-tooltip-arrow');
40-
arrow.style.left = '33%';
41-
}
42-
4338
const component = (
4439
<div
4540
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
@@ -48,7 +43,13 @@ export default function Prize({
4843
>
4944
{((onlyShowTooltipForPrize && !withoutTooltip)
5045
? (
51-
<Tooltip content={tip} placeArrow={placeArrow}>
46+
<Tooltip
47+
content={tip}
48+
placeArrow={(TooltipNode) => {
49+
const arrow = TooltipNode.querySelector('.rc-tooltip-arrow');
50+
arrow.style.left = '33%';
51+
}}
52+
>
5253
{prizeUI}
5354
</Tooltip>
5455
)

src/shared/components/tc-communities/AccessDenied/index.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default function AccessDenied(props) {
2424
spaceName,
2525
environment,
2626
viewportId,
27+
children,
2728
} = props;
2829

2930
if (viewportId) {
@@ -67,7 +68,7 @@ export default function AccessDenied(props) {
6768
<div styleName="msg">
6869
You are not authorized to access this page.
6970
</div>
70-
{props.children}
71+
{children}
7172
</div>
7273
);
7374
case CAUSE.HAVE_NOT_SUBMITTED_TO_THE_CHALLENGE:

src/shared/components/tc-communities/communities/wipro/Home/index.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ const settings = {
123123
export default function Home(props) {
124124
const {
125125
userId,
126+
resetChallengeListing,
126127
} = props;
127128

128129
return (
@@ -199,7 +200,7 @@ export default function Home(props) {
199200
>
200201
<div styleName="ImageTextStyles.linkWrap style.linkWrap">
201202
<Link
202-
onClick={() => props.resetChallengeListing()}
203+
onClick={() => resetChallengeListing()}
203204
styleName="ImageTextStyles.link"
204205
to="challenges?communityId="
205206
>

src/shared/containers/ErrorIcons/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ function Tip({ errors, clear }) {
2525
&#10799;
2626
</a>
2727
{
28-
errors.map(({ title, message }, i) => (
29-
<div key={i.toString()} styleName="item">
28+
errors.map(({ title, message }) => (
29+
<div key={`${title}-${message}`} styleName="item">
3030
<div styleName="title" title={title}>
3131
{title}
3232
</div>

src/shared/utils/challenge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function isMM(challenge) {
2020
export function isRDM(challenge) {
2121
const tags = _.get(challenge, 'tags') || [];
2222
const isMMType = challenge ? challenge.type === 'Rapid Development Match' : false;
23-
return tags.includes('Rapid Development Match') || isMMType;
23+
return tags.includes('Rapid Development Match') || tags.includes('RDM') || isMMType;
2424
}
2525

2626
/**

0 commit comments

Comments
 (0)