Skip to content

Commit 3091e5e

Browse files
Merge pull request #1279 from doctorhilarius/self-service-opps
WIP - Self service opps pt 2
2 parents df72422 + 05f0029 commit 3091e5e

File tree

14 files changed

+154
-82
lines changed

14 files changed

+154
-82
lines changed

src/actions/challenges.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import { removeChallengeFromPhaseProduct, saveChallengeAsPhaseProduct } from '..
5858
/**
5959
* Loads active challenges of project by page
6060
*/
61-
export function loadChallengesByPage (page, projectId, status, filterChallengeName = null, selfService = false) {
61+
export function loadChallengesByPage (page, projectId, status, filterChallengeName = null, selfService = false, userHandle = null) {
6262
return (dispatch, getState) => {
6363
dispatch({
6464
type: LOAD_CHALLENGES_PENDING,
@@ -87,6 +87,9 @@ export function loadChallengesByPage (page, projectId, status, filterChallengeNa
8787
}
8888
if (selfService) {
8989
filters.selfService = true
90+
if (userHandle) {
91+
filters.selfServiceCopilot = userHandle
92+
}
9093
}
9194

9295
return fetchChallenges(filters, {

src/actions/sidebar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function loadProjects (filterProjectName = '', myProjects = true) {
5353
}
5454

5555
/**
56-
* Unlads projects of the authenticated user
56+
* Unloads projects of the authenticated user
5757
*/
5858
export function unloadProjects () {
5959
return (dispatch) => {

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const ChallengeView = ({
3737
enableEdit,
3838
onLaunchChallenge,
3939
onCloseTask,
40-
projectPhases
40+
projectPhases,
41+
assignYourselfCopilit
4142
}) => {
4243
const selectedType = _.find(metadata.challengeTypes, { id: challenge.typeId })
4344
const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId })
@@ -103,18 +104,18 @@ const ChallengeView = ({
103104
</span>
104105
</div>
105106
{selectedMilestone &&
106-
<div className={styles.col}>
107-
<span><span className={styles.fieldTitle}>Milestone:</span> {selectedMilestone ? (
108-
<a href={`${CONNECT_APP_URL}/projects/${projectDetail.id}`} target='_blank'
109-
rel='noopener noreferrer'>
110-
{selectedMilestone.name}
111-
</a>
112-
) : ''}</span>
113-
</div>
107+
<div className={styles.col}>
108+
<span><span className={styles.fieldTitle}>Milestone:</span> {selectedMilestone ? (
109+
<a href={`${CONNECT_APP_URL}/projects/${projectDetail.id}`} target='_blank'
110+
rel='noopener noreferrer'>
111+
{selectedMilestone.name}
112+
</a>
113+
) : ''}</span>
114+
</div>
114115
}
115116
<div className={styles.col}>
116117
<span className={styles.fieldTitle}>Track:</span>
117-
<Track disabled type={challengeTrack} isActive key={challenge.trackId} onUpdateOthers={() => {}} />
118+
<Track disabled type={challengeTrack} isActive key={challenge.trackId} onUpdateOthers={() => { }} />
118119
</div>
119120
<div className={styles.col}>
120121
<span><span className={styles.fieldTitle}>Type:</span> {selectedType ? selectedType.name : ''}</span>
@@ -130,10 +131,11 @@ const ChallengeView = ({
130131
</div>
131132
</div>
132133
{isTask &&
133-
<AssignedMemberField challenge={challenge} assignedMemberDetails={assignedMemberDetails} readOnly />}
134+
<AssignedMemberField challenge={challenge} assignedMemberDetails={assignedMemberDetails} readOnly />}
134135
<CopilotField challenge={{
135-
copilot
136-
}} copilots={metadata.members} readOnly />
136+
copilot,
137+
selfService: challenge.legacy.selfService
138+
}} copilots={metadata.members} assignYourselfCopilit={assignYourselfCopilit} readOnly />
137139
<div className={cn(styles.row, styles.topRow)}>
138140
<div className={styles.col}>
139141
<span><span
@@ -259,7 +261,8 @@ ChallengeView.propTypes = {
259261
enableEdit: PropTypes.bool,
260262
onLaunchChallenge: PropTypes.func,
261263
onCloseTask: PropTypes.func,
262-
projectPhases: PropTypes.arrayOf(PropTypes.object)
264+
projectPhases: PropTypes.arrayOf(PropTypes.object),
265+
assignYourselfCopilit: PropTypes.func.isRequired
263266
}
264267

265268
export default withRouter(ChallengeView)

src/components/ChallengeEditor/ChallengeViewTabs/index.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import ForumLink from '../../ForumLink'
1414
import Registrants from '../Registrants'
1515
import Submissions from '../Submissions'
1616
import { getResourceRoleByName } from '../../../util/tc'
17-
import { MESSAGE } from '../../../config/constants'
17+
import { CHALLENGE_STATUS, MESSAGE } from '../../../config/constants'
1818
import Tooltip from '../../Tooltip'
1919
import CancelDropDown from '../Cancel-Dropdown'
2020
import 'react-tabs/style/react-tabs.css'
@@ -43,7 +43,8 @@ const ChallengeViewTabs = ({
4343
onLaunchChallenge,
4444
cancelChallenge,
4545
onCloseTask,
46-
projectPhases
46+
projectPhases,
47+
assignYourselfCopilit
4748
}) => {
4849
const [selectedTab, setSelectedTab] = useState(0)
4950

@@ -80,6 +81,10 @@ const ChallengeViewTabs = ({
8081

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

84+
const isSelfService = challenge.legacy.selfService
85+
const isDraft = challenge.status.toUpperCase() === CHALLENGE_STATUS.DRAFT
86+
const launchText = `${isSelfService && isDraft ? 'Approve and ' : ''}Launch`
87+
8388
return (
8489
<div className={styles.list}>
8590
<Helmet title='View Details' />
@@ -94,7 +99,7 @@ const ChallengeViewTabs = ({
9499
styles.actionButtonsLeft
95100
)}
96101
>
97-
{ isTask ? (<ForumLink challenge={challenge} />)
102+
{isTask ? (<ForumLink challenge={challenge} />)
98103
: (<LegacyLinks challenge={challenge} challengeView />)
99104
}
100105
</div>
@@ -107,12 +112,13 @@ const ChallengeViewTabs = ({
107112
styles.actionButtonsRight
108113
)}
109114
>
110-
{(challenge.status === 'Draft' || challenge.status === 'New') && <div className={styles['cancel-button']}><CancelDropDown challenge={challenge} onSelectMenu={cancelChallenge} /></div>}
115+
{(challenge.status === 'Draft' || challenge.status === 'New') && !isSelfService &&
116+
(<div className={styles['cancel-button']}><CancelDropDown challenge={challenge} onSelectMenu={cancelChallenge} /></div>)}
111117
{challenge.status === 'Draft' && (
112118
<div className={styles.button}>
113119
{challenge.legacyId || isTask ? (
114120
<PrimaryButton
115-
text={'Launch'}
121+
text={launchText}
116122
type={'info'}
117123
onClick={onLaunchChallenge}
118124
/>
@@ -138,9 +144,17 @@ const ChallengeViewTabs = ({
138144
)}
139145
</div>
140146
)}
141-
{enableEdit && (
147+
{enableEdit && !isSelfService && (
142148
<PrimaryButton text={'Edit'} type={'info'} submit link={`./edit`} />
143149
)}
150+
{isSelfService && isDraft &&
151+
(
152+
<PrimaryButton
153+
text={'Reject challenge'}
154+
type={'danger'}
155+
onClick={onLaunchChallenge} // TODO
156+
/>
157+
)}
144158
<PrimaryButton text={'Back'} type={'info'} submit link={`..`} />
145159
</div>
146160
</div>
@@ -208,6 +222,7 @@ const ChallengeViewTabs = ({
208222
onLaunchChallenge={onLaunchChallenge}
209223
onCloseTask={onCloseTask}
210224
projectPhases={projectPhases}
225+
assignYourselfCopilit={assignYourselfCopilit}
211226
/>
212227
)}
213228
{selectedTab === 1 && (
@@ -244,7 +259,8 @@ ChallengeViewTabs.propTypes = {
244259
onLaunchChallenge: PropTypes.func,
245260
cancelChallenge: PropTypes.func.isRequired,
246261
onCloseTask: PropTypes.func,
247-
projectPhases: PropTypes.arrayOf(PropTypes.object)
262+
projectPhases: PropTypes.arrayOf(PropTypes.object),
263+
assignYourselfCopilit: PropTypes.func.isRequired
248264
}
249265

250266
export default ChallengeViewTabs

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3+
import { PrimaryButton } from '../../Buttons'
34
import styles from './Copilot-Field.module.scss'
45
import cn from 'classnames'
56
import _ from 'lodash'
67
import CopilotCard from '../../CopilotCard'
78

8-
const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => {
9+
const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly, assignYourselfCopilit }) => {
910
let errMessage = 'Please set a copilot'
1011
const selectedCopilot = _.find(copilots, { handle: challenge.copilot })
1112
const copilotFee = _.find(challenge.prizeSets, p => p.type === 'copilot', [])
12-
console.log(copilotFee)
13+
const selfService = challenge.selfService
14+
1315
if (readOnly) {
1416
return (
1517
<div className={styles.row}>
1618
<div className={cn(styles.field, styles.col1)}>
17-
<label htmlFor='copilot'>Copilot :</label>
19+
<label htmlFor='copilot'>Copilot:</label>
1820
</div>
19-
{selectedCopilot && (<div className={cn(styles.field, styles.col2)}>
20-
<CopilotCard copilot={selectedCopilot} selectedCopilot='' key={selectedCopilot.handle} />
21+
{(selectedCopilot || selfService) && (<div className={cn(styles.field, styles.col2)}>
22+
{(selectedCopilot && <CopilotCard copilot={selectedCopilot} selectedCopilot='' key={selectedCopilot.handle} />)}
23+
{(selfService && <PrimaryButton
24+
text={'Assign Yourself'}
25+
type={'info'}
26+
onClick={assignYourselfCopilit}
27+
/>)}
2128
</div>)}
2229
</div>
2330
)
@@ -26,7 +33,7 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => {
2633
<>
2734
<div className={styles.row}>
2835
<div className={cn(styles.field, styles.col1)}>
29-
<label htmlFor='copilot'>Copilot :</label>
36+
<label htmlFor='copilot'>Copilot:</label>
3037
</div>
3138
<div className={cn(styles.field, styles.col2)}>
3239
{
@@ -49,15 +56,16 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => {
4956

5057
CopilotField.defaultProps = {
5158
copilots: [],
52-
onUpdateOthers: () => {},
59+
onUpdateOthers: () => { },
5360
readOnly: false
5461
}
5562

5663
CopilotField.propTypes = {
5764
copilots: PropTypes.arrayOf(PropTypes.shape()).isRequired,
5865
challenge: PropTypes.shape().isRequired,
5966
onUpdateOthers: PropTypes.func,
60-
readOnly: PropTypes.bool
67+
readOnly: PropTypes.bool,
68+
assignYourselfCopilit: PropTypes.func.isRequired
6169
}
6270

6371
export default CopilotField

0 commit comments

Comments
 (0)