From b23b11614e604ee54b9de6003edd6d6741c5764c Mon Sep 17 00:00:00 2001 From: Dedy Wahyudi Date: Tue, 21 Sep 2021 12:53:18 +0700 Subject: [PATCH 1/4] Add Forum option for Task type --- config/constants/development.js | 2 +- config/constants/production.js | 2 +- .../ChallengeViewTabs/index.js | 22 +-- .../Discussion-Field.module.scss | 178 ++++++++++++++++++ .../ChallengeEditor/Discussion-Field/index.js | 62 ++++++ .../Forum-Field/Forum-Field.module.scss | 55 ++++++ .../ChallengeEditor/Forum-Field/index.js | 48 +++++ src/components/ChallengeEditor/index.js | 36 +++- 8 files changed, 388 insertions(+), 17 deletions(-) create mode 100644 src/components/ChallengeEditor/Discussion-Field/Discussion-Field.module.scss create mode 100644 src/components/ChallengeEditor/Discussion-Field/index.js create mode 100644 src/components/ChallengeEditor/Forum-Field/Forum-Field.module.scss create mode 100644 src/components/ChallengeEditor/Forum-Field/index.js 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..12870888 100644 --- a/src/components/ChallengeEditor/ChallengeViewTabs/index.js +++ b/src/components/ChallengeEditor/ChallengeViewTabs/index.js @@ -85,17 +85,17 @@ const ChallengeViewTabs = ({
{challenge.name}
- {!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/Forum-Field/Forum-Field.module.scss b/src/components/ChallengeEditor/Forum-Field/Forum-Field.module.scss new file mode 100644 index 00000000..f6707a0c --- /dev/null +++ b/src/components/ChallengeEditor/Forum-Field/Forum-Field.module.scss @@ -0,0 +1,55 @@ +@import "../../../styles/includes"; + +.row { + box-sizing: border-box; + display: flex; + flex-direction: row; + margin: 30px 30px 0 30px; + align-content: space-between; + justify-content: flex-start; + + .field { + @include upto-sm { + display: block; + padding-bottom: 10px; + } + + label { + @include roboto-bold(); + + font-size: 16px; + line-height: 19px; + font-weight: 500; + color: $tc-gray-80; + } + + &.col1 { + max-width: 185px; + min-width: 185px; + margin-right: 14px; + white-space: nowrap; + display: flex; + align-items: center; + flex-grow: 1; + + span { + color: $tc-red; + } + } + + &.col2.error { + color: $tc-red; + margin-top: -25px; + } + &.col2 { + align-self: flex-end; + width: 80%; + margin-bottom: auto; + margin-top: auto; + display: flex; + flex-direction: row; + max-width: 600px; + min-width: 600px; + } + } +} diff --git a/src/components/ChallengeEditor/Forum-Field/index.js b/src/components/ChallengeEditor/Forum-Field/index.js new file mode 100644 index 00000000..86ef91cd --- /dev/null +++ b/src/components/ChallengeEditor/Forum-Field/index.js @@ -0,0 +1,48 @@ +import React from 'react' +import PropTypes from 'prop-types' +import Select from '../../Select' +import cn from 'classnames' +import styles from './Forum-Field.module.scss' + +const ForumField = ({ types, onSelectForum, challenge, hasForum, disabled }) => { + disabled = true + if (challenge.name && challenge.typeId) { + disabled = false + } + return ( + <> +
+
+ +
+
+ ({ label: type.name, value: type.id }))} - isClearable={false} - onChange={(e) => onSelectForum(e.value)} - isDisabled={disabled} - value={hasForum ? { label: 'On', value: true } : { label: 'Off', value: false }} - /> -
-
- - ) -} - -ForumField.defaultProps = { - types: [{ name: 'On', id: true }, { name: 'Off', id: false }], - hasForum: false, - disabled: false -} - -ForumField.propTypes = { - // currentType: PropTypes.string.isRequired, - types: PropTypes.arrayOf(PropTypes.shape()), - challenge: PropTypes.shape().isRequired, - onSelectForum: PropTypes.func.isRequired, - hasForum: PropTypes.bool, - disabled: PropTypes.bool -} - -export default ForumField diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index e8052a6d..f7d05650 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -138,8 +138,6 @@ class ChallengeEditor extends Component { this.onDeleteChallenge = this.onDeleteChallenge.bind(this) this.deleteModalLaunch = this.deleteModalLaunch.bind(this) this.toggleForumOnCreate = this.toggleForumOnCreate.bind(this) - this.onSelectForum = this.onSelectForum.bind(this) - this.toggleForumOnCreate = this.toggleForumOnCreate.bind(this) } componentDidMount () { @@ -593,10 +591,6 @@ class ChallengeEditor extends Component { this.setState({ hasForum: !hasForum }) } - onSelectForum (hasForum) { - this.setState({ hasForum }) - } - toggleAdvanceSettings () { const { isOpenAdvanceSettings } = this.state this.setState({ isOpenAdvanceSettings: !isOpenAdvanceSettings }) @@ -929,14 +923,7 @@ class ChallengeEditor extends Component { if (projectDetail.groups) { newChallenge.groups.push(...projectDetail.groups) } - if (isTask) { - if (this.state.hasForum) { - const discussions = this.getDiscussionsConfig(newChallenge) - if (discussions) { - newChallenge.discussions = discussions - } - } - } else { + if (!isTask || this.state.hasForum) { const discussions = this.getDiscussionsConfig(newChallenge) if (discussions) { newChallenge.discussions = discussions @@ -1461,7 +1448,7 @@ class ChallengeEditor extends Component { ) } - const useTask = _.find(metadata.challengeTypes, { id: challenge.typeId, isTask: true }) + // 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, @@ -1481,7 +1468,7 @@ class ChallengeEditor extends Component { {projectDetail.version === 'v4' && } - { useTask && () } + { isTask && () }
{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 From da5aa3b2004e6fba60de53f734ad20bde729fc86 Mon Sep 17 00:00:00 2001 From: vikasrohit Date: Fri, 24 Sep 2021 08:47:50 +0530 Subject: [PATCH 3/4] Deployable feature branch --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 7a1609dc2e18d20f6cf418d710dda698625583b1 Mon Sep 17 00:00:00 2001 From: Dedy Wahyudi Date: Fri, 24 Sep 2021 11:07:50 +0700 Subject: [PATCH 4/4] change to useTasks --- src/components/ChallengeEditor/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index f7d05650..ae5d8cbd 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -1448,7 +1448,7 @@ class ChallengeEditor extends Component { ) } - // const useTask = _.find(metadata.challengeTypes, { id: challenge.typeId, isTask: true }) + 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, @@ -1468,7 +1468,7 @@ class ChallengeEditor extends Component { {projectDetail.version === 'v4' && } - { isTask && () } + { useTask && () }
{showDesignChallengeWarningModel && designChallengeModal} { errorContainer }