@@ -34,6 +34,11 @@ import { connect } from 'react-redux'
34
34
import { SUBMITTER_ROLE_UUID } from '../../config/constants'
35
35
36
36
class ChallengeEditor extends Component {
37
+ constructor ( props ) {
38
+ super ( props )
39
+ const mountedWithCreatePage = props . match . path . endsWith ( '/new' )
40
+ this . state = { mountedWithCreatePage }
41
+ }
37
42
componentDidMount ( ) {
38
43
const {
39
44
match,
@@ -144,6 +149,7 @@ class ChallengeEditor extends Component {
144
149
replaceResourceInRole
145
150
// members
146
151
} = this . props
152
+ const { mountedWithCreatePage } = this . state
147
153
if ( isProjectLoading || isLoading ) return < Loader />
148
154
const challengeId = _ . get ( match . params , 'challengeId' , null )
149
155
if ( challengeId && ( ! challengeDetails || ! challengeDetails . id ) ) {
@@ -157,7 +163,8 @@ class ChallengeEditor extends Component {
157
163
handle : submitters [ 0 ] . memberHandle
158
164
}
159
165
}
160
- const enableEdit = true // this.isEditable()
166
+ const enableEdit = this . isEditable ( )
167
+ const isCreatePage = this . props . match . path . endsWith ( '/new' )
161
168
return < div >
162
169
< Route
163
170
exact
@@ -185,8 +192,8 @@ class ChallengeEditor extends Component {
185
192
/>
186
193
) )
187
194
} />
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
190
197
exact
191
198
path = { `${ this . props . match . path } /edit` }
192
199
render = { ( { match } ) => ( (
0 commit comments