@@ -13,9 +13,7 @@ import Loader from '../../components/Loader'
1313import { loadChallengesByPage , partiallyUpdateChallengeDetails , deleteChallenge } from '../../actions/challenges'
1414import { loadProject } from '../../actions/projects'
1515import { loadProjects , setActiveProject , resetSidebarActiveParams } from '../../actions/sidebar'
16- import {
17- CHALLENGE_STATUS
18- } from '../../config/constants'
16+ import { CHALLENGE_STATUS } from '../../config/constants'
1917import styles from './Challenges.module.scss'
2018
2119class Challenges extends Component {
@@ -25,20 +23,20 @@ class Challenges extends Component {
2523 searchProjectName : '' ,
2624 onlyMyProjects : true
2725 }
28-
2926 this . updateProjectName = this . updateProjectName . bind ( this )
3027 this . toggleMyProjects = this . toggleMyProjects . bind ( this )
3128 }
3229
3330 componentDidMount ( ) {
34- const { activeProjectId, resetSidebarActiveParams, menu, projectId } = this . props
31+ console . debug ( 'here' )
32+ const { activeProjectId, resetSidebarActiveParams, menu, projectId, selfServe } = this . props
3533 if ( menu === 'NULL' && activeProjectId !== - 1 ) {
3634 resetSidebarActiveParams ( )
37- } else {
38- if ( projectId ) {
35+ } else if ( projectId || selfServe ) {
36+ if ( ! ! projectId ) {
3937 this . props . loadProject ( projectId )
40- this . reloadChallenges ( this . props )
4138 }
39+ this . reloadChallenges ( this . props )
4240 }
4341 }
4442
@@ -49,11 +47,11 @@ class Challenges extends Component {
4947 }
5048
5149 reloadChallenges ( props ) {
52- const { activeProjectId, projectDetail : reduxProjectInfo , projectId, challengeProjectId, loadProject } = props
53- if ( activeProjectId !== challengeProjectId ) {
54- this . props . loadChallengesByPage ( 1 , projectId ? parseInt ( projectId ) : - 1 , CHALLENGE_STATUS . ACTIVE , '' )
55- if (
56- ( ! reduxProjectInfo || `${ reduxProjectInfo . id } ` !== projectId )
50+ const { activeProjectId, projectDetail : reduxProjectInfo , projectId, challengeProjectId, loadProject, selfServe } = props
51+ if ( activeProjectId !== challengeProjectId || selfServe ) {
52+ this . props . loadChallengesByPage ( 1 , projectId ? parseInt ( projectId ) : - 1 , CHALLENGE_STATUS . ACTIVE , '' , selfServe )
53+ if ( ! selfServe
54+ && ( ! reduxProjectInfo || `${ reduxProjectInfo . id } ` !== projectId )
5755 ) {
5856 loadProject ( projectId )
5957 }
@@ -88,7 +86,8 @@ class Challenges extends Component {
8886 setActiveProject,
8987 partiallyUpdateChallengeDetails,
9088 deleteChallenge,
91- isBillingAccountExpired
89+ isBillingAccountExpired,
90+ selfServe
9291 } = this . props
9392 const { searchProjectName, onlyMyProjects } = this . state
9493 const projectInfo = _ . find ( projects , { id : activeProjectId } ) || { }
@@ -123,7 +122,7 @@ class Challenges extends Component {
123122 < label > My Projects</ label >
124123 </ div >
125124 {
126- activeProjectId === - 1 && < div > No project selected. Select one below</ div >
125+ activeProjectId === - 1 && ! selfServe && < div > No project selected. Select one below</ div >
127126 }
128127 {
129128 isLoading ? < Loader /> : (
@@ -133,7 +132,7 @@ class Challenges extends Component {
133132 )
134133 }
135134 </ div >
136- { activeProjectId !== - 1 && < ChallengesComponent
135+ { ( activeProjectId !== - 1 || selfServe ) && < ChallengesComponent
137136 activeProject = { ( {
138137 ...projectInfo ,
139138 ...( ( reduxProjectInfo && reduxProjectInfo . id === activeProjectId ) ? reduxProjectInfo : { } )
@@ -151,6 +150,7 @@ class Challenges extends Component {
151150 partiallyUpdateChallengeDetails = { partiallyUpdateChallengeDetails }
152151 deleteChallenge = { deleteChallenge }
153152 isBillingAccountExpired = { isBillingAccountExpired }
153+ selfServe = { selfServe }
154154 />
155155 }
156156 </ Fragment >
@@ -179,7 +179,8 @@ Challenges.propTypes = {
179179 setActiveProject : PropTypes . func . isRequired ,
180180 partiallyUpdateChallengeDetails : PropTypes . func . isRequired ,
181181 deleteChallenge : PropTypes . func . isRequired ,
182- isBillingAccountExpired : PropTypes . bool
182+ isBillingAccountExpired : PropTypes . bool ,
183+ selfServe : PropTypes . bool
183184}
184185
185186const mapStateToProps = ( { challenges, sidebar, projects } ) => ( {
0 commit comments