@@ -34,6 +34,11 @@ import { connect } from 'react-redux'
3434import { SUBMITTER_ROLE_UUID } from '../../config/constants'
3535
3636class ChallengeEditor extends Component {
37+ constructor ( props ) {
38+ super ( props )
39+ const mountedWithCreatePage = props . match . path . endsWith ( '/new' )
40+ this . state = { mountedWithCreatePage }
41+ }
3742 componentDidMount ( ) {
3843 const {
3944 match,
@@ -144,6 +149,7 @@ class ChallengeEditor extends Component {
144149 replaceResourceInRole
145150 // members
146151 } = this . props
152+ const { mountedWithCreatePage } = this . state
147153 if ( isProjectLoading || isLoading ) return < Loader />
148154 const challengeId = _ . get ( match . params , 'challengeId' , null )
149155 if ( challengeId && ( ! challengeDetails || ! challengeDetails . id ) ) {
@@ -157,7 +163,8 @@ class ChallengeEditor extends Component {
157163 handle : submitters [ 0 ] . memberHandle
158164 }
159165 }
160- const enableEdit = true // this.isEditable()
166+ const enableEdit = this . isEditable ( )
167+ const isCreatePage = this . props . match . path . endsWith ( '/new' )
161168 return < div >
162169 < Route
163170 exact
@@ -185,8 +192,8 @@ class ChallengeEditor extends Component {
185192 />
186193 ) )
187194 } />
188- { ! enableEdit && < div className = { styles . errorContainer } > You don't have access to edit the challenge</ div > }
189- { enableEdit && < Route
195+ { ! isCreatePage && ! mountedWithCreatePage && ! enableEdit && < div className = { styles . errorContainer } > You don't have access to edit the challenge</ div > }
196+ { ( mountedWithCreatePage || enableEdit ) && < Route
190197 exact
191198 path = { `${ this . props . match . path } /edit` }
192199 render = { ( { match } ) => ( (
0 commit comments