Skip to content

Commit 621956e

Browse files
add assign yourself copilit button
1 parent 5defce4 commit 621956e

File tree

4 files changed

+49
-27
lines changed

4 files changed

+49
-27
lines changed

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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -94,7 +95,7 @@ const ChallengeViewTabs = ({
9495
styles.actionButtonsLeft
9596
)}
9697
>
97-
{ isTask ? (<ForumLink challenge={challenge} />)
98+
{isTask ? (<ForumLink challenge={challenge} />)
9899
: (<LegacyLinks challenge={challenge} challengeView />)
99100
}
100101
</div>
@@ -208,6 +209,7 @@ const ChallengeViewTabs = ({
208209
onLaunchChallenge={onLaunchChallenge}
209210
onCloseTask={onCloseTask}
210211
projectPhases={projectPhases}
212+
assignYourselfCopilit={assignYourselfCopilit}
211213
/>
212214
)}
213215
{selectedTab === 1 && (
@@ -244,7 +246,8 @@ ChallengeViewTabs.propTypes = {
244246
onLaunchChallenge: PropTypes.func,
245247
cancelChallenge: PropTypes.func.isRequired,
246248
onCloseTask: PropTypes.func,
247-
projectPhases: PropTypes.arrayOf(PropTypes.object)
249+
projectPhases: PropTypes.arrayOf(PropTypes.object),
250+
assignYourselfCopilit: PropTypes.func.isRequired
248251
}
249252

250253
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

src/containers/ChallengeEditor/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ class ChallengeEditor extends Component {
306306
}
307307
}
308308

309+
assignYourselfCopilit () {
310+
console.debug('assign copilit')
311+
}
312+
309313
render () {
310314
const {
311315
match,
@@ -330,7 +334,8 @@ class ChallengeEditor extends Component {
330334
deleteChallenge,
331335
loggedInUser,
332336
projectPhases,
333-
isProjectPhasesLoading
337+
isProjectPhasesLoading,
338+
assignYourselfCopilit
334339
// members
335340
} = this.props
336341
const {
@@ -424,6 +429,7 @@ class ChallengeEditor extends Component {
424429
replaceResourceInRole={replaceResourceInRole}
425430
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
426431
projectPhases={projectPhases}
432+
assignYourselfCopilit={assignYourselfCopilit}
427433
/>
428434
)}
429435
/>
@@ -487,6 +493,7 @@ class ChallengeEditor extends Component {
487493
enableEdit={enableEdit}
488494
onLaunchChallenge={this.onLaunchChallenge}
489495
onCloseTask={this.onCloseTask}
496+
assignYourselfCopilit={this.assignYourselfCopilit}
490497
/>
491498
)}
492499
/>
@@ -541,7 +548,8 @@ ChallengeEditor.propTypes = {
541548
replaceResourceInRole: PropTypes.func,
542549
loadProject: PropTypes.func,
543550
projectPhases: PropTypes.arrayOf(PropTypes.object),
544-
isProjectPhasesLoading: PropTypes.bool
551+
isProjectPhasesLoading: PropTypes.bool,
552+
assignYourselfCopilit: PropTypes.func.isRequired
545553
// members: PropTypes.arrayOf(PropTypes.shape())
546554
}
547555

0 commit comments

Comments
 (0)