Skip to content

Sync bug-bash with develop #5178

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

Merged
merged 19 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ workflows:
branches:
only:
- develop
- auth0-hotfix-v3
# This is alternate dev env for parallel testing
- "build-test":
context : org-global
Expand Down Expand Up @@ -261,6 +260,7 @@ workflows:
branches:
only:
- develop
- bug-bash-develop-sync
# Production builds are exectuted
# when PR is merged to the master
# Don't change anything in this configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ exports[`renders marathon 1`] = `
</p>
</div>
</div>
<p
className="src-shared-components-ChallengeTile-___style__roles___1V-WA"
/>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Submission from 'components/SubmissionManagement/Submission';
import TU from 'react-dom/test-utils';

const mockOnDelete = jest.fn();
const mockOnDownload = jest.fn();
const mockOnShowDetails = jest.fn();

const rnd = new Rnd();
Expand All @@ -12,6 +13,7 @@ test('Snapshot match', () => {
rnd.render((
<Submission
onDelete={mockOnDelete}
onDownload={mockOnDownload}
onShowDetails={mockOnShowDetails}
showScreeningDetails
type="develop"
Expand All @@ -21,6 +23,7 @@ test('Snapshot match', () => {
rnd.render((
<Submission
onDelete={mockOnDelete}
onDownload={mockOnDownload}
onShowDetails={mockOnShowDetails}
submissionObject={{
id: '12345',
Expand Down Expand Up @@ -49,6 +52,7 @@ class Wrapper extends React.Component {
const page = TU.renderIntoDocument((
<Wrapper
onDelete={mockOnDelete}
onDownload={mockOnDownload}
onShowDetails={mockOnShowDetails}
submissionObject={{
id: '12345',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ exports[`Snapshot match 1`] = `
className="src-shared-components-SubmissionManagement-Submission-___styles__action-col___2M1RY"
>
<div>
<a>
<button
onClick={[Function]}
type="button"
>
<DownloadIcon
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
</a>
</button>
<button
className="src-shared-components-SubmissionManagement-Submission-___styles__delete-icon___2M67z"
disabled={true}
Expand Down Expand Up @@ -81,14 +84,17 @@ exports[`Snapshot match 2`] = `
className="src-shared-components-SubmissionManagement-Submission-___styles__action-col___2M1RY"
>
<div>
<a>
<button
onClick={[Function]}
type="button"
>
<DownloadIcon
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
</a>
</button>
<button
className="src-shared-components-SubmissionManagement-Submission-___styles__delete-icon___2M67z"
disabled={true}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/actions/page/challenge-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function setSpecsTabState(state) {
* @param {Boolean} open
* @return {Object}
*/
function toggleCheckpointFeedback(id, open) {
function toggleCheckpointFeedback(id, open = false) {
return { id, open };
}

Expand Down
13 changes: 9 additions & 4 deletions src/shared/components/ChallengeTile/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Challenge tile.
*/
/* eslint-env browser */
import _ from 'lodash';
import React from 'react';
import PT from 'prop-types';
import { Link } from 'react-router-dom';
Expand Down Expand Up @@ -74,6 +75,7 @@ class ChallengeTile extends React.Component {
} = this.props;

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

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

<p styleName="roles">
{ track !== COMPETITION_TRACKS.DS
{ !_.isEmpty(roles)
&& (
<p styleName="roles">
{ track !== COMPETITION_TRACKS.DS
&& (
<span>
<span>
Role: &nbsp;
</span>
<span>
{ listRoles(challenge.userDetails.roles) }
{ listRoles(roles) }
</span>
</span>
) }
</p>
</p>
) }
</div>
</div>
</div>
Expand Down
15 changes: 7 additions & 8 deletions src/shared/components/SubmissionManagement/Submission/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import _ from 'lodash';
import moment from 'moment';
import React from 'react';
import { config } from 'topcoder-react-utils';
import { COMPETITION_TRACKS, CHALLENGE_STATUS } from 'utils/tc';

import PT from 'prop-types';
Expand All @@ -31,12 +30,14 @@ export default function Submission(props) {
submissionObject,
showScreeningDetails,
track,
onDownload,
onDelete,
onShowDetails,
status,
allowDelete,
} = props;
const formatDate = date => moment(+new Date(date)).format('MMM DD, YYYY hh:mm A');
const onDownloadSubmission = onDownload.bind(1, submissionObject.id);

return (
<tr styleName="submission-row">
Expand Down Expand Up @@ -66,15 +67,12 @@ export default function Submission(props) {
}
<td styleName="action-col">
<div>
<a
href={
track === COMPETITION_TRACKS.DES
? `${config.URL.ONLINE_REVIEW}/review/actions/DownloadContestSubmission?uid=${submissionObject.id}`
: submissionObject.download
}
<button
onClick={() => onDownloadSubmission(submissionObject.id)}
type="button"
>
<DownloadIcon />
</a>
</button>
{ /*
TODO: At the moment we just fetch downloads from the legacy
Topcoder Studio API, and we don't need any JS code to this.
Expand Down Expand Up @@ -132,6 +130,7 @@ Submission.propTypes = {
}),
showScreeningDetails: PT.bool,
track: PT.string.isRequired,
onDownload: PT.func.isRequired,
onDelete: PT.func.isRequired,
onShowDetails: PT.func,
status: PT.string.isRequired,
Expand Down
6 changes: 3 additions & 3 deletions src/shared/components/challenge-detail/Checkpoints/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function Checkpoints(props) {
document
.getElementsByClassName(style['challenge-checkpoint-winners'])[index]
.scrollIntoView(true);
toggleCheckpointFeedback(index, true);
toggleCheckpointFeedback(item.submissionId, true);
}}
type="button"
>
Expand All @@ -47,12 +47,12 @@ function Checkpoints(props) {
}}
/>
{
checkpointResults && checkpointResults.map((item, index) => (
checkpointResults && checkpointResults.map(item => (
<div key={item.submissionId} styleName="challenge-checkpoint-winners">
<button
onClick={(e) => {
e.preventDefault();
toggleCheckpointFeedback(index);
toggleCheckpointFeedback(item.submissionId, !item.expanded);
}}
styleName="challenge-checkpoint-submission"
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
/* eslint-disable jsx-a11y/label-has-for */

import _ from 'lodash';
import { challenge as challengeUtils } from 'topcoder-react-lib';
import React from 'react';
import PT from 'prop-types';
import Select from 'components/Select';
Expand All @@ -38,7 +37,6 @@ import DateRangePicker from '../DateRangePicker';
import style from './style.scss';
import UiSimpleRemove from '../../Icons/ui-simple-remove.svg';

const Filter = challengeUtils.filter;

export default function FiltersPanel({
communityFilters,
Expand Down Expand Up @@ -328,9 +326,10 @@ export default function FiltersPanel({
autoBlur
clearable={false}
id="review-type-select"
onChange={
value => setFilterState(Filter.setReviewOpportunityType(filterState, value))
}
onChange={(value) => {
const reviewOpportunityType = value === 0 ? undefined : value;
setFilterState({ ..._.clone(filterState), reviewOpportunityType });
}}
options={[
{ label: 'All', value: 0 }, // 0 value deactivates above filter
...Object.entries(REVIEW_OPPORTUNITY_TYPES)
Expand Down Expand Up @@ -434,6 +433,7 @@ export default function FiltersPanel({
endDateStart: null,
startDateEnd: null,
status: 'All',
reviewOpportunityType: undefined,
});
selectCommunity(defaultCommunityId);
setSearchText('');
Expand Down
19 changes: 16 additions & 3 deletions src/shared/containers/SubmissionManagement/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import PT from 'prop-types';
import { connect } from 'react-redux';
import { Modal } from 'topcoder-react-ui-kit';
import { config } from 'topcoder-react-utils';
import { actions } from 'topcoder-react-lib';
import { actions, services } from 'topcoder-react-lib';

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

const { getService } = services.submissions;

// The container component
class SubmissionManagementPageContainer extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -54,7 +56,6 @@ class SubmissionManagementPageContainer extends React.Component {
isLoadingChallenge,
mySubmissions,
onCancelSubmissionDelete,
onDownloadSubmission,
onShowDetails,
onSubmissionDelete,
onSubmissionDeleteConfirmed,
Expand All @@ -68,7 +69,19 @@ class SubmissionManagementPageContainer extends React.Component {
const smConfig = {
onShowDetails,
onDelete: onSubmissionDelete,
onDownload: () => onDownloadSubmission(0, authTokens),
onDownload: (challengeType, submissionId) => {
const submissionsService = getService(authTokens.tokenV3);
submissionsService.downloadSubmission(submissionId)
.then((blob) => {
const url = window.URL.createObjectURL(new Blob([blob]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', `submission-${challengeType}-${submissionId}.zip`);
document.body.appendChild(link);
link.click();
link.parentNode.removeChild(link);
});
},
onlineReviewUrl: `${config.URL.ONLINE_REVIEW}/review/actions/ViewProjectDetails?pid=${challengeId}`,
challengeUrl: `${challengesUrl}/${challengeId}`,
addSumissionUrl: `${config.URL.BASE}/challenges/${challengeId}/submit`,
Expand Down
12 changes: 10 additions & 2 deletions src/shared/containers/challenge-detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,14 @@ function mapStateToProps(state, props) {
mySubmissions = _.filter(challenge.submissions, s => (`${s.memberId}` === `${auth.user.userId}`));
}
}
const { page: { challengeDetails: { feedbackOpen } } } = state;
const checkpoints = state.challenge.checkpoints || {};
if (feedbackOpen.id && checkpoints.checkpointResults) {
checkpoints.checkpointResults = checkpoints.checkpointResults.map(result => ({
...result,
expanded: result.submissionId === feedbackOpen.id ? feedbackOpen.open : result.expanded,
}));
}
return {
auth: state.auth,
challenge,
Expand All @@ -773,9 +781,9 @@ function mapStateToProps(state, props) {
challengeId: String(props.match.params.challengeId),
challengesUrl: props.challengesUrl,
challengeTypesMap: state.challengeListing.challengeTypesMap,
checkpointResults: (state.challenge.checkpoints || {}).checkpointResults,
checkpointResults: checkpoints.checkpointResults,
checkpointResultsUi: state.page.challengeDetails.checkpoints,
checkpoints: state.challenge.checkpoints || {},
checkpoints,
communityId: props.communityId,
communitiesList: state.tcCommunities.list,
domain: state.domain,
Expand Down
17 changes: 3 additions & 14 deletions src/shared/reducers/page/challenge-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,8 @@ import { updateQuery } from 'utils/url';
* @param {Object} state Previous state.
* @param {Object} action Action.
*/
function onToggleCheckpointFeedback(state, action) {
const { payload: { id, open } } = action;
const newCheckpointResults = _.clone(state.checkpoints.checkpointResults);
newCheckpointResults[id].expanded = _.isUndefined(open)
? !newCheckpointResults[id].expanded : open;
const newCheckpoints = {
...state.checkpoints,
checkpointResults: newCheckpointResults,
};
return {
...state,
checkpoints: newCheckpoints,
};
function onToggleCheckpointFeedback(state, { payload }) {
return { ...state, feedbackOpen: payload };
}

/**
Expand Down Expand Up @@ -92,7 +81,7 @@ function create(state = {}) {
[a.submissions.toggleSubmissionTestcase]: toggleSubmissionTestcase,
[a.submissions.clearSubmissionTestcaseOpen]: clearSubmissionTestcaseOpen,
}, _.defaults(state, {
checkpoints: {},
feedbackOpen: {},
specsTabState: SPECS_TAB_STATES.VIEW,
submissionHistoryOpen: {},
submissionTestcaseOpen: {},
Expand Down