diff --git a/.circleci/config.yml b/.circleci/config.yml index 0b655a0e..be67ba05 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -150,7 +150,7 @@ workflows: context : org-global filters: &filters-dev branches: - only: ['develop', 'feature/linking-challenge-milestone'] + only: ['develop', 'feature/forum-for-task'] # Production builds are exectuted only on tagged commits to the # master branch. diff --git a/config/constants/development.js b/config/constants/development.js index 83d80b43..597dbb57 100644 --- a/config/constants/development.js +++ b/config/constants/development.js @@ -35,7 +35,7 @@ module.exports = { QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115', CHALLENGE_TYPE_ID: '927abff4-7af9-4145-8ba1-577c16e64e2e', SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n', - CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c'], + CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c', 'ecd58c69-238f-43a4-a4bb-d172719b9f31'], FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY, FILE_PICKER_CONTAINER_NAME: 'tc-challenge-v5-dev', FILE_PICKER_REGION: 'us-east-1', diff --git a/config/constants/production.js b/config/constants/production.js index 52e795e1..5d87c493 100644 --- a/config/constants/production.js +++ b/config/constants/production.js @@ -35,7 +35,7 @@ module.exports = { QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115', CHALLENGE_TYPE_ID: '927abff4-7af9-4145-8ba1-577c16e64e2e', SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF', - CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c'], + CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c', 'ecd58c69-238f-43a4-a4bb-d172719b9f31'], FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY, FILE_PICKER_CONTAINER_NAME: 'tc-challenge-v5-prod', FILE_PICKER_REGION: 'us-east-1', diff --git a/src/components/ChallengeEditor/ChallengeViewTabs/index.js b/src/components/ChallengeEditor/ChallengeViewTabs/index.js index 3bac5a89..5d4229f4 100644 --- a/src/components/ChallengeEditor/ChallengeViewTabs/index.js +++ b/src/components/ChallengeEditor/ChallengeViewTabs/index.js @@ -10,6 +10,7 @@ import _ from 'lodash' import ChallengeViewComponent from '../ChallengeView' import { PrimaryButton } from '../../Buttons' import LegacyLinks from '../../LegacyLinks' +import ForumLink from '../../ForumLink' import Registrants from '../Registrants' import Submissions from '../Submissions' import { getResourceRoleByName } from '../../../util/tc' @@ -85,17 +86,19 @@ const ChallengeViewTabs = ({
{challenge.name}
- {!isTask && ( -
- -
- )} + +
+ { isTask ? () + : () + } +
+
{ + console.log('hasForummm ' + hasForum) + if (readOnly) { + return ( +
+
Forum Discussion :
+
+ { hasForum ? 'On' : 'Off' } +
+
+ ) + } + + return ( +
+
Forum Discussion :
+
+
+ + +
+
+ + +
+
+
+ ) +} + +DiscussionField.defaultProps = { + readOnly: false +} + +DiscussionField.propTypes = { + hasForum: PropTypes.bool, + toggleForum: PropTypes.func, + readOnly: PropTypes.bool +} + +export default DiscussionField diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index 308f0687..ae5d8cbd 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -57,6 +57,7 @@ import UseSchedulingAPIField from './UseSchedulingAPIField' import { getResourceRoleByName } from '../../util/tc' import { isBetaMode } from '../../util/cookie' import MilestoneField from './Milestone-Field' +import DiscussionField from './Discussion-Field' const theme = { container: styles.modalContainer @@ -78,6 +79,7 @@ class ChallengeEditor extends Component { isDeleteLaunch: false, isConfirm: false, isClose: false, + hasForum: false, isOpenAdvanceSettings: false, isLoading: false, isSaving: false, @@ -135,6 +137,7 @@ class ChallengeEditor extends Component { this.updateResource = this.updateResource.bind(this) this.onDeleteChallenge = this.onDeleteChallenge.bind(this) this.deleteModalLaunch = this.deleteModalLaunch.bind(this) + this.toggleForumOnCreate = this.toggleForumOnCreate.bind(this) } componentDidMount () { @@ -583,6 +586,11 @@ class ChallengeEditor extends Component { this.setState({ challenge: newChallenge }) } + toggleForumOnCreate () { + const { hasForum } = this.state + this.setState({ hasForum: !hasForum }) + } + toggleAdvanceSettings () { const { isOpenAdvanceSettings } = this.state this.setState({ isOpenAdvanceSettings: !isOpenAdvanceSettings }) @@ -817,7 +825,9 @@ class ChallengeEditor extends Component { 'terms', 'prizeSets', 'winners', - 'milestoneId' + 'milestoneId', + 'discussions', + 'task' ], this.state.challenge) const isTask = _.find(metadata.challengeTypes, { id: challenge.typeId, isTask: true }) challenge.legacy = _.assign(this.state.challenge.legacy, { @@ -913,9 +923,11 @@ class ChallengeEditor extends Component { if (projectDetail.groups) { newChallenge.groups.push(...projectDetail.groups) } - const discussions = this.getDiscussionsConfig(newChallenge) - if (discussions) { - newChallenge.discussions = discussions + if (!isTask || this.state.hasForum) { + const discussions = this.getDiscussionsConfig(newChallenge) + if (discussions) { + newChallenge.discussions = discussions + } } try { const action = await createChallenge(newChallenge, projectDetail.id) @@ -1197,6 +1209,7 @@ class ChallengeEditor extends Component { showDesignChallengeWarningModel, challenge, draftChallenge, + hasForum, isOpenAdvanceSettings, isSaving, isCloseTask @@ -1435,6 +1448,7 @@ class ChallengeEditor extends Component { ) } + const useTask = _.find(metadata.challengeTypes, { id: challenge.typeId, isTask: true }) const selectedType = _.find(metadata.challengeTypes, { id: challenge.typeId }) const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId }) const selectedMilestone = _.find(projectPhases, @@ -1454,6 +1468,7 @@ class ChallengeEditor extends Component { {projectDetail.version === 'v4' && } + { useTask && () }
{showDesignChallengeWarningModel && designChallengeModal} { errorContainer } diff --git a/src/components/ForumLink/ForumLink.module.scss b/src/components/ForumLink/ForumLink.module.scss new file mode 100644 index 00000000..95abcc77 --- /dev/null +++ b/src/components/ForumLink/ForumLink.module.scss @@ -0,0 +1,34 @@ +@import "../../styles/includes"; +.container { + display: flex; + align-items: center; + white-space: nowrap; + + > a { + margin: 0 5px; + } + + .row { + margin-bottom: 0; + + &.topRow { + flex-wrap: wrap; + } + } + + .col { + margin-right: 20px; + display: flex; + align-items: center; + + .fieldTitle { + @include roboto-bold(); + + font-size: 16px; + line-height: 19px; + font-weight: 500; + color: $tc-gray-80; + margin-right: 10px; + } + } +} diff --git a/src/components/ForumLink/index.js b/src/components/ForumLink/index.js new file mode 100644 index 00000000..7e05060c --- /dev/null +++ b/src/components/ForumLink/index.js @@ -0,0 +1,29 @@ +/** + * Component to render ForumLink of the app + */ +import React from 'react' +import PropTypes from 'prop-types' +import cn from 'classnames' +import styles from './ForumLink.module.scss' + +const ForumLink = ({ challenge }) => { + return ( +
+
+ { challenge.discussions && challenge.discussions.map(d => ( +
+
+ Forum +
+
+ ))} +
+
+ ) +} + +ForumLink.propTypes = { + challenge: PropTypes.object +} + +export default ForumLink