Skip to content

Commit 5520b9a

Browse files
author
vikasrohit
authored
Merge pull request #868 from topcoder-platform/feature/git-558-explict-access-check
fix: git#558-fixed error in challenge creation after the new access check
2 parents 23902d1 + 86c05c6 commit 5520b9a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/components/ChallengeEditor/LastSaved-Display/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ const LastSavedDisplay = ({ timeLastSaved }) =>
1010
</div>
1111

1212
LastSavedDisplay.propTypes = {
13-
timeLastSaved: PropTypes.string.isRequired
13+
timeLastSaved: PropTypes.string
1414
}
1515
export default LastSavedDisplay

src/components/Track/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Track.defaultProps = {
2525
}
2626

2727
Track.propTypes = {
28-
type: PropTypes.object.isRequired,
28+
type: PropTypes.object,
2929
isActive: PropTypes.bool,
3030
disabled: PropTypes.bool,
3131
onUpdateOthers: PropTypes.func.isRequired

src/containers/ChallengeEditor/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ import { connect } from 'react-redux'
3434
import { SUBMITTER_ROLE_UUID } from '../../config/constants'
3535

3636
class 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

Comments
 (0)