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: 4 additions & 1 deletion src/actions/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import { removeChallengeFromPhaseProduct, saveChallengeAsPhaseProduct } from '..
/**
* Loads active challenges of project by page
*/
export function loadChallengesByPage (page, projectId, status, filterChallengeName = null, selfService = false) {
export function loadChallengesByPage (page, projectId, status, filterChallengeName = null, selfService = false, userHandle = null) {
return (dispatch, getState) => {
dispatch({
type: LOAD_CHALLENGES_PENDING,
Expand Down Expand Up @@ -87,6 +87,9 @@ export function loadChallengesByPage (page, projectId, status, filterChallengeNa
}
if (selfService) {
filters.selfService = true
if (userHandle) {
filters.selfServiceCopilot = userHandle
}
}

return fetchChallenges(filters, {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function loadProjects (filterProjectName = '', myProjects = true) {
}

/**
* Unlads projects of the authenticated user
* Unloads projects of the authenticated user
*/
export function unloadProjects () {
return (dispatch) => {
Expand Down
31 changes: 17 additions & 14 deletions src/components/ChallengeEditor/ChallengeView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const ChallengeView = ({
enableEdit,
onLaunchChallenge,
onCloseTask,
projectPhases
projectPhases,
assignYourselfCopilit
}) => {
const selectedType = _.find(metadata.challengeTypes, { id: challenge.typeId })
const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId })
Expand Down Expand Up @@ -103,18 +104,18 @@ const ChallengeView = ({
</span>
</div>
{selectedMilestone &&
<div className={styles.col}>
<span><span className={styles.fieldTitle}>Milestone:</span> {selectedMilestone ? (
<a href={`${CONNECT_APP_URL}/projects/${projectDetail.id}`} target='_blank'
rel='noopener noreferrer'>
{selectedMilestone.name}
</a>
) : ''}</span>
</div>
<div className={styles.col}>
<span><span className={styles.fieldTitle}>Milestone:</span> {selectedMilestone ? (
<a href={`${CONNECT_APP_URL}/projects/${projectDetail.id}`} target='_blank'
rel='noopener noreferrer'>
{selectedMilestone.name}
</a>
) : ''}</span>
</div>
}
<div className={styles.col}>
<span className={styles.fieldTitle}>Track:</span>
<Track disabled type={challengeTrack} isActive key={challenge.trackId} onUpdateOthers={() => {}} />
<Track disabled type={challengeTrack} isActive key={challenge.trackId} onUpdateOthers={() => { }} />
</div>
<div className={styles.col}>
<span><span className={styles.fieldTitle}>Type:</span> {selectedType ? selectedType.name : ''}</span>
Expand All @@ -130,10 +131,11 @@ const ChallengeView = ({
</div>
</div>
{isTask &&
<AssignedMemberField challenge={challenge} assignedMemberDetails={assignedMemberDetails} readOnly />}
<AssignedMemberField challenge={challenge} assignedMemberDetails={assignedMemberDetails} readOnly />}
<CopilotField challenge={{
copilot
}} copilots={metadata.members} readOnly />
copilot,
selfService: challenge.legacy.selfService
}} copilots={metadata.members} assignYourselfCopilit={assignYourselfCopilit} readOnly />
<div className={cn(styles.row, styles.topRow)}>
<div className={styles.col}>
<span><span
Expand Down Expand Up @@ -259,7 +261,8 @@ ChallengeView.propTypes = {
enableEdit: PropTypes.bool,
onLaunchChallenge: PropTypes.func,
onCloseTask: PropTypes.func,
projectPhases: PropTypes.arrayOf(PropTypes.object)
projectPhases: PropTypes.arrayOf(PropTypes.object),
assignYourselfCopilit: PropTypes.func.isRequired
}

export default withRouter(ChallengeView)
30 changes: 23 additions & 7 deletions src/components/ChallengeEditor/ChallengeViewTabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ForumLink from '../../ForumLink'
import Registrants from '../Registrants'
import Submissions from '../Submissions'
import { getResourceRoleByName } from '../../../util/tc'
import { MESSAGE } from '../../../config/constants'
import { CHALLENGE_STATUS, MESSAGE } from '../../../config/constants'
import Tooltip from '../../Tooltip'
import CancelDropDown from '../Cancel-Dropdown'
import 'react-tabs/style/react-tabs.css'
Expand Down Expand Up @@ -43,7 +43,8 @@ const ChallengeViewTabs = ({
onLaunchChallenge,
cancelChallenge,
onCloseTask,
projectPhases
projectPhases,
assignYourselfCopilit
}) => {
const [selectedTab, setSelectedTab] = useState(0)

Expand Down Expand Up @@ -80,6 +81,10 @@ const ChallengeViewTabs = ({

const isTask = _.get(challenge, 'task.isTask', false)

const isSelfService = challenge.legacy.selfService
const isDraft = challenge.status.toUpperCase() === CHALLENGE_STATUS.DRAFT
const launchText = `${isSelfService && isDraft ? 'Approve and ' : ''}Launch`

return (
<div className={styles.list}>
<Helmet title='View Details' />
Expand All @@ -94,7 +99,7 @@ const ChallengeViewTabs = ({
styles.actionButtonsLeft
)}
>
{ isTask ? (<ForumLink challenge={challenge} />)
{isTask ? (<ForumLink challenge={challenge} />)
: (<LegacyLinks challenge={challenge} challengeView />)
}
</div>
Expand All @@ -107,12 +112,13 @@ const ChallengeViewTabs = ({
styles.actionButtonsRight
)}
>
{(challenge.status === 'Draft' || challenge.status === 'New') && <div className={styles['cancel-button']}><CancelDropDown challenge={challenge} onSelectMenu={cancelChallenge} /></div>}
{(challenge.status === 'Draft' || challenge.status === 'New') && !isSelfService &&
(<div className={styles['cancel-button']}><CancelDropDown challenge={challenge} onSelectMenu={cancelChallenge} /></div>)}
{challenge.status === 'Draft' && (
<div className={styles.button}>
{challenge.legacyId || isTask ? (
<PrimaryButton
text={'Launch'}
text={launchText}
type={'info'}
onClick={onLaunchChallenge}
/>
Expand All @@ -138,9 +144,17 @@ const ChallengeViewTabs = ({
)}
</div>
)}
{enableEdit && (
{enableEdit && !isSelfService && (
<PrimaryButton text={'Edit'} type={'info'} submit link={`./edit`} />
)}
{isSelfService && isDraft &&
(
<PrimaryButton
text={'Reject challenge'}
type={'danger'}
onClick={onLaunchChallenge} // TODO
/>
)}
<PrimaryButton text={'Back'} type={'info'} submit link={`..`} />
</div>
</div>
Expand Down Expand Up @@ -208,6 +222,7 @@ const ChallengeViewTabs = ({
onLaunchChallenge={onLaunchChallenge}
onCloseTask={onCloseTask}
projectPhases={projectPhases}
assignYourselfCopilit={assignYourselfCopilit}
/>
)}
{selectedTab === 1 && (
Expand Down Expand Up @@ -244,7 +259,8 @@ ChallengeViewTabs.propTypes = {
onLaunchChallenge: PropTypes.func,
cancelChallenge: PropTypes.func.isRequired,
onCloseTask: PropTypes.func,
projectPhases: PropTypes.arrayOf(PropTypes.object)
projectPhases: PropTypes.arrayOf(PropTypes.object),
assignYourselfCopilit: PropTypes.func.isRequired
}

export default ChallengeViewTabs
24 changes: 16 additions & 8 deletions src/components/ChallengeEditor/Copilot-Field/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import React from 'react'
import PropTypes from 'prop-types'
import { PrimaryButton } from '../../Buttons'
import styles from './Copilot-Field.module.scss'
import cn from 'classnames'
import _ from 'lodash'
import CopilotCard from '../../CopilotCard'

const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => {
const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly, assignYourselfCopilit }) => {
let errMessage = 'Please set a copilot'
const selectedCopilot = _.find(copilots, { handle: challenge.copilot })
const copilotFee = _.find(challenge.prizeSets, p => p.type === 'copilot', [])
console.log(copilotFee)
const selfService = challenge.selfService

if (readOnly) {
return (
<div className={styles.row}>
<div className={cn(styles.field, styles.col1)}>
<label htmlFor='copilot'>Copilot :</label>
<label htmlFor='copilot'>Copilot:</label>
</div>
{selectedCopilot && (<div className={cn(styles.field, styles.col2)}>
<CopilotCard copilot={selectedCopilot} selectedCopilot='' key={selectedCopilot.handle} />
{(selectedCopilot || selfService) && (<div className={cn(styles.field, styles.col2)}>
{(selectedCopilot && <CopilotCard copilot={selectedCopilot} selectedCopilot='' key={selectedCopilot.handle} />)}
{(selfService && <PrimaryButton
text={'Assign Yourself'}
type={'info'}
onClick={assignYourselfCopilit}
/>)}
</div>)}
</div>
)
Expand All @@ -26,7 +33,7 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => {
<>
<div className={styles.row}>
<div className={cn(styles.field, styles.col1)}>
<label htmlFor='copilot'>Copilot :</label>
<label htmlFor='copilot'>Copilot:</label>
</div>
<div className={cn(styles.field, styles.col2)}>
{
Expand All @@ -49,15 +56,16 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => {

CopilotField.defaultProps = {
copilots: [],
onUpdateOthers: () => {},
onUpdateOthers: () => { },
readOnly: false
}

CopilotField.propTypes = {
copilots: PropTypes.arrayOf(PropTypes.shape()).isRequired,
challenge: PropTypes.shape().isRequired,
onUpdateOthers: PropTypes.func,
readOnly: PropTypes.bool
readOnly: PropTypes.bool,
assignYourselfCopilit: PropTypes.func.isRequired
}

export default CopilotField
Loading