Skip to content

Commit fc2c8cb

Browse files
committed
feat: create forums during challenge creation
ref issue topcoder-platform#845
1 parent ff06e42 commit fc2c8cb

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

config/constants/development.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ module.exports = {
3131
DES_TRACK_ID: '5fa04185-041f-49a6-bfd1-fe82533cd6c8',
3232
DS_TRACK_ID: 'c0f5d461-8219-4c14-878a-c3a3f356466d',
3333
QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115',
34-
SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n'
34+
SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n',
35+
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c']
3536
}

config/constants/production.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ module.exports = {
3131
DES_TRACK_ID: '5fa04185-041f-49a6-bfd1-fe82533cd6c8',
3232
DS_TRACK_ID: 'c0f5d461-8219-4c14-878a-c3a3f356466d',
3333
QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115',
34-
SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF'
34+
SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF',
35+
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c']
3536
}

src/components/ChallengeEditor/index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
PRIZE_SETS_TYPE,
1616
DEFAULT_TERM_UUID,
1717
DEFAULT_NDA_UUID,
18-
SUBMITTER_ROLE_UUID
18+
SUBMITTER_ROLE_UUID,
19+
CREATE_FORUM_TYPE_IDS
1920
} from '../../config/constants'
2021
import { PrimaryButton, OutlineButton } from '../Buttons'
2122
import TrackField from './Track-Field'
@@ -767,6 +768,10 @@ class ChallengeEditor extends Component {
767768
phases: this.getTemplatePhases(defaultTemplate)
768769
// prizeSets: this.getDefaultPrizeSets()
769770
}
771+
const discussions = this.getDiscussionsConfig(newChallenge)
772+
if (discussions) {
773+
newChallenge.discussions = discussions
774+
}
770775
try {
771776
const action = await createChallenge(newChallenge)
772777
const draftChallenge = {
@@ -779,6 +784,18 @@ class ChallengeEditor extends Component {
779784
}
780785
}
781786

787+
getDiscussionsConfig (challenge) {
788+
if (_.includes(CREATE_FORUM_TYPE_IDS, challenge.typeId)) {
789+
return ([
790+
{
791+
name: `${challenge.name} Discussion`,
792+
type: 'challenge',
793+
provider: 'vanilla'
794+
}
795+
])
796+
}
797+
}
798+
782799
getTemplatePhases (template) {
783800
const timelinePhaseIds = template.phases.map(timelinePhase => timelinePhase.phaseId || timelinePhase)
784801
const validPhases = _.cloneDeep(this.props.metadata.challengePhases).filter(challengePhase => {

src/config/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const {
1616
QA_TRACK_ID,
1717
SEGMENT_API_KEY
1818
} = process.env
19+
export const CREATE_FORUM_TYPE_IDS = typeof process.env.CREATE_FORUM_TYPE_IDS === 'string' ? process.env.CREATE_FORUM_TYPE_IDS.split(',') : process.env.CREATE_FORUM_TYPE_IDS
1920

2021
// Actions
2122
export const LOAD_PROJECTS_SUCCESS = 'LOAD_PROJECTS_SUCCESS'

0 commit comments

Comments
 (0)