Skip to content

Commit 6ca2894

Browse files
authored
Merge pull request #1059 from CDharmateja/default-terms-and-nda
fix project terms load and default terms in beta
2 parents de55c10 + 58ef9be commit 6ca2894

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/components/ChallengeEditor/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,8 @@ class ChallengeEditor extends Component {
810810

811811
async createNewChallenge () {
812812
if (!this.props.isNew) return
813-
const { metadata, createChallenge, projectDetail } = this.props
813+
const { metadata, createChallenge, projectDetail, location } = this.props
814+
const params = new URLSearchParams(location.search)
814815
const { name, trackId, typeId } = this.state.challenge
815816
const { timelineTemplates } = metadata
816817
const isDesignChallenge = trackId === DES_TRACK_ID
@@ -839,7 +840,7 @@ class ChallengeEditor extends Component {
839840
terms: [{ id: DEFAULT_TERM_UUID, roleId: SUBMITTER_ROLE_UUID }]
840841
// prizeSets: this.getDefaultPrizeSets()
841842
}
842-
if (projectDetail.terms) {
843+
if (params.get('beta') === 'true' && projectDetail.terms) {
843844
const currTerms = new Set(newChallenge.terms.map(term => term.id))
844845
newChallenge.terms.push(
845846
...projectDetail.terms

src/containers/ChallengeEditor/index.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import {
3030
replaceResourceInRole
3131
} from '../../actions/challenges'
3232

33+
import { loadProject } from '../../actions/projects'
34+
3335
import { connect } from 'react-redux'
3436
import { SUBMITTER_ROLE_UUID, MESSAGE } from '../../config/constants'
3537
import { patchChallenge } from '../../services/challenges'
@@ -59,6 +61,7 @@ class ChallengeEditor extends Component {
5961
this.closeSuccessModal = this.closeSuccessModal.bind(this)
6062
this.onCloseTask = this.onCloseTask.bind(this)
6163
this.closeTask = this.closeTask.bind(this)
64+
this.fetchProjectDetails = this.fetchProjectDetails.bind(this)
6265
}
6366

6467
componentDidMount () {
@@ -86,7 +89,6 @@ class ChallengeEditor extends Component {
8689
loadGroups()
8790
loadResourceRoles()
8891
this.fetchChallengeDetails(match, loadChallengeDetails, loadResources)
89-
9092
// this.unlisten = this.props.history.listen(() => {
9193
// const { isLoading } = this.props
9294
// if (!isLoading) {
@@ -112,12 +114,23 @@ class ChallengeEditor extends Component {
112114
}
113115
}
114116

117+
async fetchProjectDetails (newMatch) {
118+
let projectId = _.get(newMatch.params, 'projectId', null)
119+
projectId = projectId ? parseInt(projectId) : null
120+
if (projectId) {
121+
await this.props.loadProject(projectId)
122+
}
123+
}
124+
115125
async fetchChallengeDetails (newMatch, loadChallengeDetails, loadResources) {
116126
let projectId = _.get(newMatch.params, 'projectId', null)
117127
projectId = projectId ? parseInt(projectId) : null
118128
const challengeId = _.get(newMatch.params, 'challengeId', null)
119129
await loadResources(challengeId)
120130
loadChallengeDetails(projectId, challengeId)
131+
if (!challengeId) {
132+
this.fetchProjectDetails(newMatch)
133+
}
121134
}
122135

123136
isEditable () {
@@ -413,7 +426,8 @@ ChallengeEditor.propTypes = {
413426
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
414427
createChallenge: PropTypes.func.isRequired,
415428
deleteChallenge: PropTypes.func.isRequired,
416-
replaceResourceInRole: PropTypes.func
429+
replaceResourceInRole: PropTypes.func,
430+
loadProject: PropTypes.func
417431
// members: PropTypes.arrayOf(PropTypes.shape())
418432
}
419433

@@ -450,7 +464,8 @@ const mapDispatchToProps = {
450464
partiallyUpdateChallengeDetails,
451465
deleteChallenge,
452466
createChallenge,
453-
replaceResourceInRole
467+
replaceResourceInRole,
468+
loadProject
454469
}
455470

456471
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(ChallengeEditor))

0 commit comments

Comments
 (0)