Skip to content

Commit 9e185ad

Browse files
Merge pull request #1293 from doctorhilarius/self-service-fixes
Fix Assign Copilot Issues; Unassign Copilot
2 parents ab19d57 + bcee707 commit 9e185ad

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const ChallengeView = ({
136136
<CopilotField challenge={{
137137
copilot,
138138
selfService: challenge.legacy.selfService
139-
}} copilots={metadata.members} assignYourselfCopilot={assignYourselfCopilot} showRejectChallengeModal={showRejectChallengeModal} readOnly />
139+
}} copilots={challengeResources} assignYourselfCopilot={assignYourselfCopilot} showRejectChallengeModal={showRejectChallengeModal} readOnly />
140140
<div className={cn(styles.row, styles.topRow)}>
141141
<div className={styles.col}>
142142
<span><span

src/components/ChallengeEditor/Copilot-Field/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import CopilotCard from '../../CopilotCard'
88

99
const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly, assignYourselfCopilot }) => {
1010
let errMessage = 'Please set a copilot'
11-
const selectedCopilot = _.find(copilots, { handle: challenge.copilot })
11+
const handleProperty = copilots.handle ? 'handle' : 'memberHandle'
12+
const selectedCopilot = _.find(copilots, { [handleProperty]: challenge.copilot })
13+
const selectedCopilotHandle = selectedCopilot ? selectedCopilot[handleProperty] : undefined
1214
const copilotFee = _.find(challenge.prizeSets, p => p.type === 'copilot', [])
1315
const selfService = challenge.selfService
1416

@@ -19,10 +21,10 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly, assignYou
1921
<label htmlFor='copilot'>Copilot:</label>
2022
</div>
2123
{(selectedCopilot || selfService) && (<div className={cn(styles.field, styles.col2)}>
22-
{(selectedCopilot && <CopilotCard copilot={selectedCopilot} selectedCopilot='' key={selectedCopilot.handle} />)}
24+
{(selectedCopilot && <CopilotCard copilot={selectedCopilot} selectedCopilot={challenge.copilot} key={selectedCopilotHandle} />)}
2325
{(selfService && !selectedCopilot && <PrimaryButton
24-
text={'Assign Yourself'}
25-
type={'info'}
26+
text='Assign Yourself'
27+
type='info'
2628
onClick={assignYourselfCopilot}
2729
/>)}
2830
</div>)}

src/components/ChallengeEditor/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,8 @@ class ChallengeEditor extends Component {
12341234
attachments,
12351235
projectPhases,
12361236
challengeId,
1237-
assignYourselfCopilot
1237+
assignYourselfCopilot,
1238+
challengeResources
12381239
} = this.props
12391240
if (_.isEmpty(challenge)) {
12401241
return <div>Error loading challenge</div>
@@ -1466,6 +1467,7 @@ class ChallengeEditor extends Component {
14661467
const activeProjectMilestones = projectPhases.filter(phase => phase.status === MILESTONE_STATUS.ACTIVE)
14671468
const currentChallengeId = this.getCurrentChallengeId()
14681469
const showTimeline = false // disables the timeline for time being https://github.com/topcoder-platform/challenge-engine-ui/issues/706
1470+
const copilotResources = metadata.members || challengeResources
14691471
const challengeForm = isNew
14701472
? (
14711473
<form name='challenge-new-form' noValidate autoComplete='off' onSubmit={this.createChallengeHandler}>
@@ -1515,7 +1517,7 @@ class ChallengeEditor extends Component {
15151517
/>
15161518
)}
15171519
{projectDetail.version === 'v4' && <MilestoneField milestones={activeProjectMilestones} onUpdateSelect={this.onUpdateSelect} projectId={projectDetail.id} selectedMilestoneId={selectedMilestoneId} />}
1518-
<CopilotField challenge={challenge} copilots={metadata.members} onUpdateOthers={this.onUpdateOthers} assignYourselfCopilot={assignYourselfCopilot} />
1520+
<CopilotField challenge={challenge} copilots={copilotResources} onUpdateOthers={this.onUpdateOthers} assignYourselfCopilot={assignYourselfCopilot} />
15191521
<ReviewTypeField
15201522
reviewers={metadata.members}
15211523
challenge={challenge}

src/components/CopilotCard/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ const assets = require.context('../../assets/images', false, /svg/)
88

99
const CopilotCard = ({ copilot, selectedCopilot, onUpdateOthers }) => {
1010
const icon = './user.svg'
11+
const copilotHandle = copilot.handle || copilot.memberHandle
1112
return (
12-
<div className={cn(styles.container, { [styles.active]: copilot.handle === selectedCopilot })} onClick={() => onUpdateOthers({ field: 'copilot', value: copilot.handle })}>
13+
<div className={cn(styles.container, { [styles.active]: copilotHandle === selectedCopilot })} onClick={() => onUpdateOthers({ field: 'copilot', value: copilotHandle })}>
1314
{copilot.photoURL && <img src={copilot.photoURL} alt='copilot' />}
1415
{!copilot.photoURL && <ReactSVG path={assets(`${icon}`)} />}
15-
<span className={cn(styles.handle, styles[copilot.color])}>{copilot.handle}</span>
16+
<span className={cn(styles.handle, styles[copilot.color])}>{copilotHandle}</span>
1617
</div>
1718
)
1819
}

src/containers/ChallengeEditor/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ class ChallengeEditor extends Component {
405405
loggedInUser,
406406
projectPhases,
407407
isProjectPhasesLoading,
408-
rejectChallenge,
409408
showRejectChallengeModal
410409
// members
411410
} = this.props
@@ -529,7 +528,7 @@ class ChallengeEditor extends Component {
529528
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
530529
projectPhases={projectPhases}
531530
assignYourselfCopilot={this.assignYourselfCopilot}
532-
rejectChallenge={rejectChallenge}
531+
rejectChallenge={this.rejectChallenge}
533532
showRejectChallengeModal={showRejectChallengeModal}
534533
loggedInUser={loggedInUser}
535534
/>
@@ -656,7 +655,6 @@ ChallengeEditor.propTypes = {
656655
loadProject: PropTypes.func,
657656
projectPhases: PropTypes.arrayOf(PropTypes.object),
658657
isProjectPhasesLoading: PropTypes.bool,
659-
rejectChallenge: PropTypes.func.isRequired,
660658
showRejectChallengeModal: PropTypes.func
661659
// members: PropTypes.arrayOf(PropTypes.shape())
662660
}

0 commit comments

Comments
 (0)