Skip to content
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
5 changes: 3 additions & 2 deletions src/actions/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ import {
DELETE_CHALLENGE_PENDING,
DELETE_CHALLENGE_SUCCESS,
DELETE_CHALLENGE_FAILURE,
LOAD_CHALLENGE_RESOURCES
LOAD_CHALLENGE_RESOURCES,
CHALLENGE_STATUS
} from '../config/constants'
import { loadProject } from './projects'
import { removeChallengeFromPhaseProduct, saveChallengeAsPhaseProduct } from '../services/projects'
Expand Down Expand Up @@ -87,7 +88,7 @@ export function loadChallengesByPage (page, projectId, status, filterChallengeNa
}
if (selfService) {
filters.selfService = true
if (userHandle) {
if (userHandle && filters.status.toUpperCase() !== CHALLENGE_STATUS.DRAFT) {
filters.selfServiceCopilot = userHandle
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/components/ChallengeEditor/ChallengeView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const ChallengeView = ({
onLaunchChallenge,
onCloseTask,
projectPhases,
assignYourselfCopilit
assignYourselfCopilot,
showRejectChallengeModal
}) => {
const selectedType = _.find(metadata.challengeTypes, { id: challenge.typeId })
const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId })
Expand Down Expand Up @@ -75,7 +76,7 @@ const ChallengeView = ({
const reviewerFromResources = reviewerResource ? reviewerResource.memberHandle : ''
let copilot, reviewer
if (challenge) {
copilot = challenge.copilot
copilot = challenge.copilot || (challenge.legacy && challenge.legacy.selfServiceCopilot)
reviewer = challenge.reviewer
}
copilot = copilot || copilotFromResources
Expand Down Expand Up @@ -135,7 +136,7 @@ const ChallengeView = ({
<CopilotField challenge={{
copilot,
selfService: challenge.legacy.selfService
}} copilots={metadata.members} assignYourselfCopilit={assignYourselfCopilit} readOnly />
}} copilots={metadata.members} assignYourselfCopilot={assignYourselfCopilot} showRejectChallengeModal={showRejectChallengeModal} readOnly />
<div className={cn(styles.row, styles.topRow)}>
<div className={styles.col}>
<span><span
Expand Down Expand Up @@ -262,7 +263,8 @@ ChallengeView.propTypes = {
onLaunchChallenge: PropTypes.func,
onCloseTask: PropTypes.func,
projectPhases: PropTypes.arrayOf(PropTypes.object),
assignYourselfCopilit: PropTypes.func.isRequired
assignYourselfCopilot: PropTypes.func.isRequired,
showRejectChallengeModal: PropTypes.func.isRequired
}

export default withRouter(ChallengeView)
25 changes: 16 additions & 9 deletions src/components/ChallengeEditor/ChallengeViewTabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ const ChallengeViewTabs = ({
cancelChallenge,
onCloseTask,
projectPhases,
assignYourselfCopilit
assignYourselfCopilot,
showRejectChallengeModal,
loggedInUser
}) => {
const [selectedTab, setSelectedTab] = useState(0)

Expand Down Expand Up @@ -84,6 +86,7 @@ const ChallengeViewTabs = ({
const isSelfService = challenge.legacy.selfService
const isDraft = challenge.status.toUpperCase() === CHALLENGE_STATUS.DRAFT
const launchText = `${isSelfService && isDraft ? 'Approve and ' : ''}Launch`
const isCopilot = challenge.legacy.selfServiceCopilot === loggedInUser.handle

return (
<div className={styles.list}>
Expand Down Expand Up @@ -112,9 +115,9 @@ const ChallengeViewTabs = ({
styles.actionButtonsRight
)}
>
{(challenge.status === 'Draft' || challenge.status === 'New') && !isSelfService &&
{(isDraft || challenge.status === 'New') && !isSelfService &&
(<div className={styles['cancel-button']}><CancelDropDown challenge={challenge} onSelectMenu={cancelChallenge} /></div>)}
{challenge.status === 'Draft' && (
{isDraft && (!isSelfService || isCopilot) && (
<div className={styles.button}>
{challenge.legacyId || isTask ? (
<PrimaryButton
Expand Down Expand Up @@ -147,14 +150,15 @@ const ChallengeViewTabs = ({
{enableEdit && !isSelfService && (
<PrimaryButton text={'Edit'} type={'info'} submit link={`./edit`} />
)}
{isSelfService && isDraft &&
(
{isSelfService && isDraft && isCopilot && (
<div className={styles.button}>
<PrimaryButton
text={'Reject challenge'}
type={'danger'}
onClick={onLaunchChallenge} // TODO
onClick={showRejectChallengeModal}
/>
)}
</div>
)}
<PrimaryButton text={'Back'} type={'info'} submit link={`..`} />
</div>
</div>
Expand Down Expand Up @@ -222,7 +226,8 @@ const ChallengeViewTabs = ({
onLaunchChallenge={onLaunchChallenge}
onCloseTask={onCloseTask}
projectPhases={projectPhases}
assignYourselfCopilit={assignYourselfCopilit}
assignYourselfCopilot={assignYourselfCopilot}
showRejectChallengeModal={showRejectChallengeModal}
/>
)}
{selectedTab === 1 && (
Expand Down Expand Up @@ -260,7 +265,9 @@ ChallengeViewTabs.propTypes = {
cancelChallenge: PropTypes.func.isRequired,
onCloseTask: PropTypes.func,
projectPhases: PropTypes.arrayOf(PropTypes.object),
assignYourselfCopilit: PropTypes.func.isRequired
assignYourselfCopilot: PropTypes.func.isRequired,
showRejectChallengeModal: PropTypes.func.isRequired,
loggedInUser: PropTypes.object.isRequired
}

export default ChallengeViewTabs
8 changes: 4 additions & 4 deletions src/components/ChallengeEditor/Copilot-Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cn from 'classnames'
import _ from 'lodash'
import CopilotCard from '../../CopilotCard'

const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly, assignYourselfCopilit }) => {
const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly, assignYourselfCopilot }) => {
let errMessage = 'Please set a copilot'
const selectedCopilot = _.find(copilots, { handle: challenge.copilot })
const copilotFee = _.find(challenge.prizeSets, p => p.type === 'copilot', [])
Expand All @@ -20,10 +20,10 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly, assignYou
</div>
{(selectedCopilot || selfService) && (<div className={cn(styles.field, styles.col2)}>
{(selectedCopilot && <CopilotCard copilot={selectedCopilot} selectedCopilot='' key={selectedCopilot.handle} />)}
{(selfService && <PrimaryButton
{(selfService && !selectedCopilot && <PrimaryButton
text={'Assign Yourself'}
type={'info'}
onClick={assignYourselfCopilit}
onClick={assignYourselfCopilot}
/>)}
</div>)}
</div>
Expand Down Expand Up @@ -65,7 +65,7 @@ CopilotField.propTypes = {
challenge: PropTypes.shape().isRequired,
onUpdateOthers: PropTypes.func,
readOnly: PropTypes.bool,
assignYourselfCopilit: PropTypes.func.isRequired
assignYourselfCopilot: PropTypes.func.isRequired
}

export default CopilotField
8 changes: 5 additions & 3 deletions src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,8 @@ class ChallengeEditor extends Component {
projectDetail,
attachments,
projectPhases,
challengeId
challengeId,
assignYourselfCopilot
} = this.props
if (_.isEmpty(challenge)) {
return <div>Error loading challenge</div>
Expand Down Expand Up @@ -1514,7 +1515,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} />
<CopilotField challenge={challenge} copilots={metadata.members} onUpdateOthers={this.onUpdateOthers} assignYourselfCopilot={assignYourselfCopilot} />
<ReviewTypeField
reviewers={metadata.members}
challenge={challenge}
Expand Down Expand Up @@ -1694,7 +1695,8 @@ ChallengeEditor.propTypes = {
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
deleteChallenge: PropTypes.func.isRequired,
loggedInUser: PropTypes.shape().isRequired,
projectPhases: PropTypes.arrayOf(PropTypes.object).isRequired
projectPhases: PropTypes.arrayOf(PropTypes.object).isRequired,
assignYourselfCopilot: PropTypes.func.isRequired
}

export default withRouter(ChallengeEditor)
Loading