Skip to content

Commit 6d0f941

Browse files
Merge branch 'develop' into tcx-202011
2 parents 8e6fbd9 + e3d9f3d commit 6d0f941

File tree

12 files changed

+68
-49
lines changed

12 files changed

+68
-49
lines changed

.circleci/config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ workflows:
231231
branches:
232232
only:
233233
- develop
234-
- auth0-hotfix-v3
235234
# This is alternate dev env for parallel testing
236235
- "build-test":
237236
context : org-global
@@ -261,7 +260,6 @@ workflows:
261260
branches:
262261
only:
263262
- develop
264-
- tcx-202011
265263
# Production builds are exectuted
266264
# when PR is merged to the master
267265
# Don't change anything in this configuration

__tests__/shared/components/ChallengeTile/__snapshots__/index.jsx.snap

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,6 @@ exports[`renders marathon 1`] = `
241241
</p>
242242
</div>
243243
</div>
244-
<p
245-
className="src-shared-components-ChallengeTile-___style__roles___1V-WA"
246-
/>
247244
</div>
248245
</div>
249246
</div>

__tests__/shared/components/SubmissionManagement/Submission.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Submission from 'components/SubmissionManagement/Submission';
44
import TU from 'react-dom/test-utils';
55

66
const mockOnDelete = jest.fn();
7+
const mockOnDownload = jest.fn();
78
const mockOnShowDetails = jest.fn();
89

910
const rnd = new Rnd();
@@ -12,6 +13,7 @@ test('Snapshot match', () => {
1213
rnd.render((
1314
<Submission
1415
onDelete={mockOnDelete}
16+
onDownload={mockOnDownload}
1517
onShowDetails={mockOnShowDetails}
1618
showScreeningDetails
1719
type="develop"
@@ -21,6 +23,7 @@ test('Snapshot match', () => {
2123
rnd.render((
2224
<Submission
2325
onDelete={mockOnDelete}
26+
onDownload={mockOnDownload}
2427
onShowDetails={mockOnShowDetails}
2528
submissionObject={{
2629
id: '12345',
@@ -49,6 +52,7 @@ class Wrapper extends React.Component {
4952
const page = TU.renderIntoDocument((
5053
<Wrapper
5154
onDelete={mockOnDelete}
55+
onDownload={mockOnDownload}
5256
onShowDetails={mockOnShowDetails}
5357
submissionObject={{
5458
id: '12345',

__tests__/shared/components/SubmissionManagement/__snapshots__/Submission.jsx.snap

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ exports[`Snapshot match 1`] = `
2121
className="src-shared-components-SubmissionManagement-Submission-___styles__action-col___2M1RY"
2222
>
2323
<div>
24-
<a>
24+
<button
25+
onClick={[Function]}
26+
type="button"
27+
>
2528
<DownloadIcon
2629
height="16"
2730
viewBox="0 0 16 16"
2831
width="16"
2932
xmlns="http://www.w3.org/2000/svg"
3033
/>
31-
</a>
34+
</button>
3235
<button
3336
className="src-shared-components-SubmissionManagement-Submission-___styles__delete-icon___2M67z"
3437
disabled={true}
@@ -81,14 +84,17 @@ exports[`Snapshot match 2`] = `
8184
className="src-shared-components-SubmissionManagement-Submission-___styles__action-col___2M1RY"
8285
>
8386
<div>
84-
<a>
87+
<button
88+
onClick={[Function]}
89+
type="button"
90+
>
8591
<DownloadIcon
8692
height="16"
8793
viewBox="0 0 16 16"
8894
width="16"
8995
xmlns="http://www.w3.org/2000/svg"
9096
/>
91-
</a>
97+
</button>
9298
<button
9399
className="src-shared-components-SubmissionManagement-Submission-___styles__delete-icon___2M67z"
94100
disabled={true}

src/shared/actions/page/challenge-details.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function setSpecsTabState(state) {
5959
* @param {Boolean} open
6060
* @return {Object}
6161
*/
62-
function toggleCheckpointFeedback(id, open) {
62+
function toggleCheckpointFeedback(id, open = false) {
6363
return { id, open };
6464
}
6565

src/shared/components/ChallengeTile/index.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Challenge tile.
33
*/
44
/* eslint-env browser */
5+
import _ from 'lodash';
56
import React from 'react';
67
import PT from 'prop-types';
78
import { Link } from 'react-router-dom';
@@ -74,6 +75,7 @@ class ChallengeTile extends React.Component {
7475
} = this.props;
7576

7677
const { track, type } = challenge;
78+
const roles = _.get(challenge, 'userDetails.roles');
7779

7880
const outStyleName = `challenge tile-view ${track.replace(' ', '-').toLowerCase()}`;
7981
const extraStyle = {
@@ -307,19 +309,22 @@ class ChallengeTile extends React.Component {
307309
) }
308310
</div>
309311

310-
<p styleName="roles">
311-
{ track !== COMPETITION_TRACKS.DS
312+
{ !_.isEmpty(roles)
313+
&& (
314+
<p styleName="roles">
315+
{ track !== COMPETITION_TRACKS.DS
312316
&& (
313317
<span>
314318
<span>
315319
Role: &nbsp;
316320
</span>
317321
<span>
318-
{ listRoles(challenge.userDetails.roles) }
322+
{ listRoles(roles) }
319323
</span>
320324
</span>
321325
) }
322-
</p>
326+
</p>
327+
) }
323328
</div>
324329
</div>
325330
</div>

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import _ from 'lodash';
1515
import moment from 'moment';
1616
import React from 'react';
17-
import { config } from 'topcoder-react-utils';
1817
import { COMPETITION_TRACKS, CHALLENGE_STATUS } from 'utils/tc';
1918

2019
import PT from 'prop-types';
@@ -31,12 +30,14 @@ export default function Submission(props) {
3130
submissionObject,
3231
showScreeningDetails,
3332
track,
33+
onDownload,
3434
onDelete,
3535
onShowDetails,
3636
status,
3737
allowDelete,
3838
} = props;
3939
const formatDate = date => moment(+new Date(date)).format('MMM DD, YYYY hh:mm A');
40+
const onDownloadSubmission = onDownload.bind(1, submissionObject.id);
4041

4142
return (
4243
<tr styleName="submission-row">
@@ -66,15 +67,12 @@ export default function Submission(props) {
6667
}
6768
<td styleName="action-col">
6869
<div>
69-
<a
70-
href={
71-
track === COMPETITION_TRACKS.DES
72-
? `${config.URL.ONLINE_REVIEW}/review/actions/DownloadContestSubmission?uid=${submissionObject.id}`
73-
: submissionObject.download
74-
}
70+
<button
71+
onClick={() => onDownloadSubmission(submissionObject.id)}
72+
type="button"
7573
>
7674
<DownloadIcon />
77-
</a>
75+
</button>
7876
{ /*
7977
TODO: At the moment we just fetch downloads from the legacy
8078
Topcoder Studio API, and we don't need any JS code to this.
@@ -132,6 +130,7 @@ Submission.propTypes = {
132130
}),
133131
showScreeningDetails: PT.bool,
134132
track: PT.string.isRequired,
133+
onDownload: PT.func.isRequired,
135134
onDelete: PT.func.isRequired,
136135
onShowDetails: PT.func,
137136
status: PT.string.isRequired,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function Checkpoints(props) {
2727
document
2828
.getElementsByClassName(style['challenge-checkpoint-winners'])[index]
2929
.scrollIntoView(true);
30-
toggleCheckpointFeedback(index, true);
30+
toggleCheckpointFeedback(item.submissionId, true);
3131
}}
3232
type="button"
3333
>
@@ -47,12 +47,12 @@ function Checkpoints(props) {
4747
}}
4848
/>
4949
{
50-
checkpointResults && checkpointResults.map((item, index) => (
50+
checkpointResults && checkpointResults.map(item => (
5151
<div key={item.submissionId} styleName="challenge-checkpoint-winners">
5252
<button
5353
onClick={(e) => {
5454
e.preventDefault();
55-
toggleCheckpointFeedback(index);
55+
toggleCheckpointFeedback(item.submissionId, !item.expanded);
5656
}}
5757
styleName="challenge-checkpoint-submission"
5858
type="button"

src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
/* eslint-disable jsx-a11y/label-has-for */
2323

2424
import _ from 'lodash';
25-
import { challenge as challengeUtils } from 'topcoder-react-lib';
2625
import React from 'react';
2726
import PT from 'prop-types';
2827
import Select from 'components/Select';
@@ -38,7 +37,6 @@ import DateRangePicker from '../DateRangePicker';
3837
import style from './style.scss';
3938
import UiSimpleRemove from '../../Icons/ui-simple-remove.svg';
4039

41-
const Filter = challengeUtils.filter;
4240

4341
export default function FiltersPanel({
4442
communityFilters,
@@ -328,9 +326,10 @@ export default function FiltersPanel({
328326
autoBlur
329327
clearable={false}
330328
id="review-type-select"
331-
onChange={
332-
value => setFilterState(Filter.setReviewOpportunityType(filterState, value))
333-
}
329+
onChange={(value) => {
330+
const reviewOpportunityType = value === 0 ? undefined : value;
331+
setFilterState({ ..._.clone(filterState), reviewOpportunityType });
332+
}}
334333
options={[
335334
{ label: 'All', value: 0 }, // 0 value deactivates above filter
336335
...Object.entries(REVIEW_OPPORTUNITY_TYPES)
@@ -434,6 +433,7 @@ export default function FiltersPanel({
434433
endDateStart: null,
435434
startDateEnd: null,
436435
status: 'All',
436+
reviewOpportunityType: undefined,
437437
});
438438
selectCommunity(defaultCommunityId);
439439
setSearchText('');

src/shared/containers/SubmissionManagement/index.jsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ import PT from 'prop-types';
1515
import { connect } from 'react-redux';
1616
import { Modal } from 'topcoder-react-ui-kit';
1717
import { config } from 'topcoder-react-utils';
18-
import { actions } from 'topcoder-react-lib';
18+
import { actions, services } from 'topcoder-react-lib';
1919

2020
import './styles.scss';
2121
import smpActions from '../../actions/page/submission_management';
2222

23+
const { getService } = services.submissions;
24+
2325
// The container component
2426
class SubmissionManagementPageContainer extends React.Component {
2527
componentDidMount() {
@@ -54,7 +56,6 @@ class SubmissionManagementPageContainer extends React.Component {
5456
isLoadingChallenge,
5557
mySubmissions,
5658
onCancelSubmissionDelete,
57-
onDownloadSubmission,
5859
onShowDetails,
5960
onSubmissionDelete,
6061
onSubmissionDeleteConfirmed,
@@ -68,7 +69,19 @@ class SubmissionManagementPageContainer extends React.Component {
6869
const smConfig = {
6970
onShowDetails,
7071
onDelete: onSubmissionDelete,
71-
onDownload: () => onDownloadSubmission(0, authTokens),
72+
onDownload: (challengeType, submissionId) => {
73+
const submissionsService = getService(authTokens.tokenV3);
74+
submissionsService.downloadSubmission(submissionId)
75+
.then((blob) => {
76+
const url = window.URL.createObjectURL(new Blob([blob]));
77+
const link = document.createElement('a');
78+
link.href = url;
79+
link.setAttribute('download', `submission-${challengeType}-${submissionId}.zip`);
80+
document.body.appendChild(link);
81+
link.click();
82+
link.parentNode.removeChild(link);
83+
});
84+
},
7285
onlineReviewUrl: `${config.URL.ONLINE_REVIEW}/review/actions/ViewProjectDetails?pid=${challengeId}`,
7386
challengeUrl: `${challengesUrl}/${challengeId}`,
7487
addSumissionUrl: `${config.URL.BASE}/challenges/${challengeId}/submit`,

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,14 @@ function mapStateToProps(state, props) {
763763
mySubmissions = _.filter(challenge.submissions, s => (`${s.memberId}` === `${auth.user.userId}`));
764764
}
765765
}
766+
const { page: { challengeDetails: { feedbackOpen } } } = state;
767+
const checkpoints = state.challenge.checkpoints || {};
768+
if (feedbackOpen.id && checkpoints.checkpointResults) {
769+
checkpoints.checkpointResults = checkpoints.checkpointResults.map(result => ({
770+
...result,
771+
expanded: result.submissionId === feedbackOpen.id ? feedbackOpen.open : result.expanded,
772+
}));
773+
}
766774
return {
767775
auth: state.auth,
768776
challenge,
@@ -773,9 +781,9 @@ function mapStateToProps(state, props) {
773781
challengeId: String(props.match.params.challengeId),
774782
challengesUrl: props.challengesUrl,
775783
challengeTypesMap: state.challengeListing.challengeTypesMap,
776-
checkpointResults: (state.challenge.checkpoints || {}).checkpointResults,
784+
checkpointResults: checkpoints.checkpointResults,
777785
checkpointResultsUi: state.page.challengeDetails.checkpoints,
778-
checkpoints: state.challenge.checkpoints || {},
786+
checkpoints,
779787
communityId: props.communityId,
780788
communitiesList: state.tcCommunities.list,
781789
domain: state.domain,

src/shared/reducers/page/challenge-details.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,8 @@ import { updateQuery } from 'utils/url';
88
* @param {Object} state Previous state.
99
* @param {Object} action Action.
1010
*/
11-
function onToggleCheckpointFeedback(state, action) {
12-
const { payload: { id, open } } = action;
13-
const newCheckpointResults = _.clone(state.checkpoints.checkpointResults);
14-
newCheckpointResults[id].expanded = _.isUndefined(open)
15-
? !newCheckpointResults[id].expanded : open;
16-
const newCheckpoints = {
17-
...state.checkpoints,
18-
checkpointResults: newCheckpointResults,
19-
};
20-
return {
21-
...state,
22-
checkpoints: newCheckpoints,
23-
};
11+
function onToggleCheckpointFeedback(state, { payload }) {
12+
return { ...state, feedbackOpen: payload };
2413
}
2514

2615
/**
@@ -92,7 +81,7 @@ function create(state = {}) {
9281
[a.submissions.toggleSubmissionTestcase]: toggleSubmissionTestcase,
9382
[a.submissions.clearSubmissionTestcaseOpen]: clearSubmissionTestcaseOpen,
9483
}, _.defaults(state, {
95-
checkpoints: {},
84+
feedbackOpen: {},
9685
specsTabState: SPECS_TAB_STATES.VIEW,
9786
submissionHistoryOpen: {},
9887
submissionTestcaseOpen: {},

0 commit comments

Comments
 (0)