Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ChallengeEditor/LastSaved-Display/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ const LastSavedDisplay = ({ timeLastSaved }) =>
</div>

LastSavedDisplay.propTypes = {
timeLastSaved: PropTypes.string.isRequired
timeLastSaved: PropTypes.string
}
export default LastSavedDisplay
2 changes: 1 addition & 1 deletion src/components/Track/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Track.defaultProps = {
}

Track.propTypes = {
type: PropTypes.object.isRequired,
type: PropTypes.object,
isActive: PropTypes.bool,
disabled: PropTypes.bool,
onUpdateOthers: PropTypes.func.isRequired
Expand Down
13 changes: 10 additions & 3 deletions src/containers/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ import { connect } from 'react-redux'
import { SUBMITTER_ROLE_UUID } from '../../config/constants'

class ChallengeEditor extends Component {
constructor (props) {
super(props)
const mountedWithCreatePage = props.match.path.endsWith('/new')
this.state = { mountedWithCreatePage }
}
componentDidMount () {
const {
match,
Expand Down Expand Up @@ -144,6 +149,7 @@ class ChallengeEditor extends Component {
replaceResourceInRole
// members
} = this.props
const { mountedWithCreatePage } = this.state
if (isProjectLoading || isLoading) return <Loader />
const challengeId = _.get(match.params, 'challengeId', null)
if (challengeId && (!challengeDetails || !challengeDetails.id)) {
Expand All @@ -157,7 +163,8 @@ class ChallengeEditor extends Component {
handle: submitters[0].memberHandle
}
}
const enableEdit = true // this.isEditable()
const enableEdit = this.isEditable()
const isCreatePage = this.props.match.path.endsWith('/new')
return <div>
<Route
exact
Expand Down Expand Up @@ -185,8 +192,8 @@ class ChallengeEditor extends Component {
/>
))
} />
{ !enableEdit && <div className={styles.errorContainer}>You don't have access to edit the challenge</div>}
{ enableEdit && <Route
{ !isCreatePage && !mountedWithCreatePage && !enableEdit && <div className={styles.errorContainer}>You don't have access to edit the challenge</div>}
{ (mountedWithCreatePage || enableEdit) && <Route
exact
path={`${this.props.match.path}/edit`}
render={({ match }) => ((
Expand Down