Skip to content

Fix Assign Copilot Issues; Unassign Copilot #1293

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 3 commits into from
Jan 30, 2022
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 src/components/ChallengeEditor/ChallengeView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const ChallengeView = ({
<CopilotField challenge={{
copilot,
selfService: challenge.legacy.selfService
}} copilots={metadata.members} assignYourselfCopilot={assignYourselfCopilot} showRejectChallengeModal={showRejectChallengeModal} readOnly />
}} copilots={challengeResources} assignYourselfCopilot={assignYourselfCopilot} showRejectChallengeModal={showRejectChallengeModal} readOnly />
<div className={cn(styles.row, styles.topRow)}>
<div className={styles.col}>
<span><span
Expand Down
10 changes: 6 additions & 4 deletions src/components/ChallengeEditor/Copilot-Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import CopilotCard from '../../CopilotCard'

const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly, assignYourselfCopilot }) => {
let errMessage = 'Please set a copilot'
const selectedCopilot = _.find(copilots, { handle: challenge.copilot })
const handleProperty = copilots.handle ? 'handle' : 'memberHandle'
const selectedCopilot = _.find(copilots, { [handleProperty]: challenge.copilot })
const selectedCopilotHandle = selectedCopilot ? selectedCopilot[handleProperty] : undefined
const copilotFee = _.find(challenge.prizeSets, p => p.type === 'copilot', [])
const selfService = challenge.selfService

Expand All @@ -19,10 +21,10 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly, assignYou
<label htmlFor='copilot'>Copilot:</label>
</div>
{(selectedCopilot || selfService) && (<div className={cn(styles.field, styles.col2)}>
{(selectedCopilot && <CopilotCard copilot={selectedCopilot} selectedCopilot='' key={selectedCopilot.handle} />)}
{(selectedCopilot && <CopilotCard copilot={selectedCopilot} selectedCopilot={challenge.copilot} key={selectedCopilotHandle} />)}
{(selfService && !selectedCopilot && <PrimaryButton
text={'Assign Yourself'}
type={'info'}
text='Assign Yourself'
type='info'
onClick={assignYourselfCopilot}
/>)}
</div>)}
Expand Down
6 changes: 4 additions & 2 deletions src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,8 @@ class ChallengeEditor extends Component {
attachments,
projectPhases,
challengeId,
assignYourselfCopilot
assignYourselfCopilot,
challengeResources
} = this.props
if (_.isEmpty(challenge)) {
return <div>Error loading challenge</div>
Expand Down Expand Up @@ -1466,6 +1467,7 @@ class ChallengeEditor extends Component {
const activeProjectMilestones = projectPhases.filter(phase => phase.status === MILESTONE_STATUS.ACTIVE)
const currentChallengeId = this.getCurrentChallengeId()
const showTimeline = false // disables the timeline for time being https://github.com/topcoder-platform/challenge-engine-ui/issues/706
const copilotResources = metadata.members || challengeResources
const challengeForm = isNew
? (
<form name='challenge-new-form' noValidate autoComplete='off' onSubmit={this.createChallengeHandler}>
Expand Down Expand Up @@ -1515,7 +1517,7 @@ class ChallengeEditor extends Component {
/>
)}
{projectDetail.version === 'v4' && <MilestoneField milestones={activeProjectMilestones} onUpdateSelect={this.onUpdateSelect} projectId={projectDetail.id} selectedMilestoneId={selectedMilestoneId} />}
<CopilotField challenge={challenge} copilots={metadata.members} onUpdateOthers={this.onUpdateOthers} assignYourselfCopilot={assignYourselfCopilot} />
<CopilotField challenge={challenge} copilots={copilotResources} onUpdateOthers={this.onUpdateOthers} assignYourselfCopilot={assignYourselfCopilot} />
<ReviewTypeField
reviewers={metadata.members}
challenge={challenge}
Expand Down
5 changes: 3 additions & 2 deletions src/components/CopilotCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ const assets = require.context('../../assets/images', false, /svg/)

const CopilotCard = ({ copilot, selectedCopilot, onUpdateOthers }) => {
const icon = './user.svg'
const copilotHandle = copilot.handle || copilot.memberHandle
return (
<div className={cn(styles.container, { [styles.active]: copilot.handle === selectedCopilot })} onClick={() => onUpdateOthers({ field: 'copilot', value: copilot.handle })}>
<div className={cn(styles.container, { [styles.active]: copilotHandle === selectedCopilot })} onClick={() => onUpdateOthers({ field: 'copilot', value: copilotHandle })}>
{copilot.photoURL && <img src={copilot.photoURL} alt='copilot' />}
{!copilot.photoURL && <ReactSVG path={assets(`${icon}`)} />}
<span className={cn(styles.handle, styles[copilot.color])}>{copilot.handle}</span>
<span className={cn(styles.handle, styles[copilot.color])}>{copilotHandle}</span>
</div>
)
}
Expand Down
4 changes: 1 addition & 3 deletions src/containers/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ class ChallengeEditor extends Component {
loggedInUser,
projectPhases,
isProjectPhasesLoading,
rejectChallenge,
showRejectChallengeModal
// members
} = this.props
Expand Down Expand Up @@ -529,7 +528,7 @@ class ChallengeEditor extends Component {
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
projectPhases={projectPhases}
assignYourselfCopilot={this.assignYourselfCopilot}
rejectChallenge={rejectChallenge}
rejectChallenge={this.rejectChallenge}
showRejectChallengeModal={showRejectChallengeModal}
loggedInUser={loggedInUser}
/>
Expand Down Expand Up @@ -656,7 +655,6 @@ ChallengeEditor.propTypes = {
loadProject: PropTypes.func,
projectPhases: PropTypes.arrayOf(PropTypes.object),
isProjectPhasesLoading: PropTypes.bool,
rejectChallenge: PropTypes.func.isRequired,
showRejectChallengeModal: PropTypes.func
// members: PropTypes.arrayOf(PropTypes.shape())
}
Expand Down