@@ -6,7 +6,7 @@ import moment from 'moment'
66import ChallengeEditorComponent from '../../components/ChallengeEditor'
77import ChallengeViewTabs from '../../components/ChallengeEditor/ChallengeViewTabs'
88import Loader from '../../components/Loader'
9- import { checkAdmin } from '../../util/tc'
9+ import { checkAdmin , getResourceRoleByName } from '../../util/tc'
1010import styles from './ChallengeEditor.module.scss'
1111
1212import {
@@ -27,7 +27,8 @@ import {
2727 partiallyUpdateChallengeDetails ,
2828 deleteChallenge ,
2929 createChallenge ,
30- replaceResourceInRole
30+ replaceResourceInRole ,
31+ createResource
3132} from '../../actions/challenges'
3233
3334import { loadSubmissions } from '../../actions/challengeSubmissions'
@@ -65,6 +66,7 @@ class ChallengeEditor extends Component {
6566 this . onCloseTask = this . onCloseTask . bind ( this )
6667 this . closeTask = this . closeTask . bind ( this )
6768 this . fetchProjectDetails = this . fetchProjectDetails . bind ( this )
69+ this . assignYourselfCopilot = this . assignYourselfCopilot . bind ( this )
6870 }
6971
7072 componentDidMount ( ) {
@@ -306,8 +308,10 @@ class ChallengeEditor extends Component {
306308 }
307309 }
308310
309- assignYourselfCopilot ( ) {
310- console . debug ( 'assign copilot' )
311+ async assignYourselfCopilot ( ) {
312+ const { challengeDetails, loggedInUser, metadata } = this . props
313+ const copilotRole = getResourceRoleByName ( metadata . resourceRoles , 'Copilot' )
314+ await createResource ( challengeDetails . id , copilotRole . id , loggedInUser . handle )
311315 }
312316
313317 rejectChallenge ( ) {
@@ -475,6 +479,7 @@ class ChallengeEditor extends Component {
475479 deleteChallenge = { deleteChallenge }
476480 loggedInUser = { loggedInUser }
477481 projectPhases = { projectPhases }
482+ assignYourselfCopilot = { assignYourselfCopilot }
478483 />
479484 ) }
480485 />
@@ -617,7 +622,8 @@ const mapDispatchToProps = {
617622 deleteChallenge,
618623 createChallenge,
619624 replaceResourceInRole,
620- loadProject
625+ loadProject,
626+ createResource
621627}
622628
623629export default withRouter (
0 commit comments