From e591a1701b96ff93f52e827b1d3963061142bd08 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Fri, 24 Jul 2020 16:57:41 +0530 Subject: [PATCH 01/11] feat: git#734-Set-Up Screen 1 Q&A Copy Updates --- src/components/ChallengeEditor/ChallengeName-Field/index.js | 6 +++--- src/components/ChallengeEditor/Track-Field/index.js | 4 ++-- src/components/ChallengeEditor/Type-Field/index.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/ChallengeEditor/ChallengeName-Field/index.js b/src/components/ChallengeEditor/ChallengeName-Field/index.js index 8b12d7d9..4b4feebb 100644 --- a/src/components/ChallengeEditor/ChallengeName-Field/index.js +++ b/src/components/ChallengeEditor/ChallengeName-Field/index.js @@ -8,16 +8,16 @@ const ChallengeNameField = ({ challenge, onUpdateInput }) => { <>
- +
- +
{ challenge.submitTriggered && !challenge.name &&
- Name is required field + Work Name is required field
} diff --git a/src/components/ChallengeEditor/Track-Field/index.js b/src/components/ChallengeEditor/Track-Field/index.js index 99327138..34c16d37 100644 --- a/src/components/ChallengeEditor/Track-Field/index.js +++ b/src/components/ChallengeEditor/Track-Field/index.js @@ -18,7 +18,7 @@ const TrackField = ({ challenge, onUpdateOthers, disabled }) => { <>
- +
{ @@ -29,7 +29,7 @@ const TrackField = ({ challenge, onUpdateOthers, disabled }) => { { challenge.submitTriggered && !challenge.track &&
- Track is required field + Work Type is required field
} diff --git a/src/components/ChallengeEditor/Type-Field/index.js b/src/components/ChallengeEditor/Type-Field/index.js index 5e982de0..87ca0653 100644 --- a/src/components/ChallengeEditor/Type-Field/index.js +++ b/src/components/ChallengeEditor/Type-Field/index.js @@ -10,14 +10,14 @@ const TypeField = ({ types, onUpdateSelect, challenge, disabled }) => { <>
- +
t.isActive && t.track === challenge.track)} + options={_.filter(types, t => t.isActive)} value={challenge.typeId} placeholder='Work Format' labelKey='name' diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index 0f387d84..e73593c1 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -508,8 +508,8 @@ class ChallengeEditor extends Component { isValidChallenge () { const { challenge } = this.state if (this.props.isNew) { - const { name, track, typeId } = challenge - return !!name && !!track && !!typeId + const { name, trackId, typeId } = challenge + return !!name && !!trackId && !!typeId } const reviewType = challenge.reviewType ? challenge.reviewType.toLowerCase() : 'community' @@ -523,7 +523,7 @@ class ChallengeEditor extends Component { } return !(Object.values(pick([ - 'track', + 'trackId', 'typeId', 'name', 'description', @@ -586,7 +586,7 @@ class ChallengeEditor extends Component { const challenge = pick([ 'phases', 'typeId', - 'track', + 'trackId', 'name', 'description', 'privateDescription', @@ -599,8 +599,7 @@ class ChallengeEditor extends Component { 'prizeSets' ], this.state.challenge) challenge.legacy = _.assign(this.state.challenge.legacy, { - reviewType: challenge.reviewType, - track: challenge.track + reviewType: challenge.reviewType }) challenge.timelineTemplateId = _.get(this.getCurrentTemplate(), 'id') challenge.projectId = this.props.projectId @@ -618,7 +617,6 @@ class ChallengeEditor extends Component { ], p)) if (challenge.terms && challenge.terms.length === 0) delete challenge.terms delete challenge.attachments - delete challenge.track delete challenge.reviewType return _.cloneDeep(challenge) } @@ -632,7 +630,7 @@ class ChallengeEditor extends Component { async createNewChallenge () { if (!this.props.isNew) return const { metadata } = this.props - const { name, track, typeId } = this.state.challenge + const { name, trackId, typeId } = this.state.challenge const { timelineTemplates } = metadata // fallback template @@ -646,9 +644,9 @@ class ChallengeEditor extends Component { projectId: this.props.projectId, name, typeId, + trackId, startDate: moment().add(1, 'days').format(), legacy: { - track, reviewType: 'community' }, descriptionFormat: 'markdown', @@ -1023,13 +1021,14 @@ class ChallengeEditor extends Component { } const selectedType = _.find(metadata.challengeTypes, { id: challenge.typeId }) + const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId }) const currentChallengeId = this.getCurrentChallengeId() const showTimeline = false // disables the timeline for time being https://github.com/topcoder-platform/challenge-engine-ui/issues/706 const challengeForm = isNew ? (
- +
@@ -1050,7 +1049,7 @@ class ChallengeEditor extends Component {
Track: - {}} /> + {}} />
Type: {selectedType ? selectedType.name : ''} diff --git a/src/components/ChallengesComponent/ChallengeCard/index.js b/src/components/ChallengesComponent/ChallengeCard/index.js index 0418d435..734d07e1 100644 --- a/src/components/ChallengesComponent/ChallengeCard/index.js +++ b/src/components/ChallengesComponent/ChallengeCard/index.js @@ -242,7 +242,7 @@ class ChallengeCard extends React.Component {
{challenge.name} - +
diff --git a/src/components/ChallengesComponent/ChallengeTag/ChallengeTag.module.scss b/src/components/ChallengesComponent/ChallengeTag/ChallengeTag.module.scss index 1aa8b574..cc661f85 100644 --- a/src/components/ChallengesComponent/ChallengeTag/ChallengeTag.module.scss +++ b/src/components/ChallengesComponent/ChallengeTag/ChallengeTag.module.scss @@ -38,8 +38,3 @@ color: $white; background-color: $light-blue; } - -.design { - color: $white; - background-color: $green; -} diff --git a/src/components/Tag/index.js b/src/components/Tag/index.js index d8350deb..482f12a5 100644 --- a/src/components/Tag/index.js +++ b/src/components/Tag/index.js @@ -28,6 +28,9 @@ const stylizedSubTrack = (t, challengeTypes) => { ) } +/** + * ***************** UNUSED ************************** + */ const Tag = ({ track, subTrack, value, challengeTypes, roleTag }) => { const className = cn(styles.tag, { [styles.dataScience]: track === CHALLENGE_TRACKS.DATA_SCIENCE, diff --git a/src/components/Track/index.js b/src/components/Track/index.js index 5fec766d..a1d5c262 100644 --- a/src/components/Track/index.js +++ b/src/components/Track/index.js @@ -2,34 +2,19 @@ import React from 'react' import PropTypes from 'prop-types' import cn from 'classnames' import ReactSVG from 'react-svg' -import { CHALLENGE_TRACKS } from '../../config/constants' import styles from './Track.module.scss' const assets = require.context('../../assets/images/tracks', false, /svg/) const Track = ({ type, isActive, onUpdateOthers, disabled }) => { - const icon = `./${type.toLowerCase()}.svg` - const getName = (type) => { - switch (type.toUpperCase()) { - case CHALLENGE_TRACKS.DEVELOP: - return 'Development' - case CHALLENGE_TRACKS.DESIGN: - return 'Design' - case CHALLENGE_TRACKS.DATA_SCIENCE: - return 'Data Science' - case CHALLENGE_TRACKS.QA: - return CHALLENGE_TRACKS.QA - default: - return '' - } - } + const icon = `./${type.abbreviation.toLowerCase()}.svg` return ( -
onUpdateOthers({ field: 'track', value: type })}> +
onUpdateOthers({ field: 'trackId', value: type.id })}>
{ assets && assets.keys().includes(icon) ? : '' }
- {getName(type)} + {type.name}
) } @@ -40,7 +25,7 @@ Track.defaultProps = { } Track.propTypes = { - type: PropTypes.string.isRequired, + type: PropTypes.object.isRequired, isActive: PropTypes.bool, disabled: PropTypes.bool, onUpdateOthers: PropTypes.func.isRequired diff --git a/src/config/constants.js b/src/config/constants.js index adb7084e..f7355165 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -9,7 +9,11 @@ export const { ONLINE_REVIEW_URL, DEFAULT_TERM_UUID, DEFAULT_NDA_UUID, - SUBMITTER_ROLE_UUID + SUBMITTER_ROLE_UUID, + DEV_TRACK_ID, + DES_TRACK_ID, + DS_TRACK_ID, + QA_TRACK_ID } = process.env // Actions @@ -58,10 +62,10 @@ export const RESET_SIDEBAR_ACTIVE_PARAMS = 'RESET_SIDEBAR_ACTIVE_PARAMS' // Name of challenge tracks export const CHALLENGE_TRACKS = { - DESIGN: 'DESIGN', - DEVELOP: 'DEVELOP', - DATA_SCIENCE: 'DATA_SCIENCE', - QA: 'QA' + DESIGN: DES_TRACK_ID, + DEVELOP: DEV_TRACK_ID, + DATA_SCIENCE: DS_TRACK_ID, + QA: QA_TRACK_ID } // List of challenge phase statuses diff --git a/src/containers/ChallengeEditor/index.js b/src/containers/ChallengeEditor/index.js index 6fe3f152..ccd131b1 100644 --- a/src/containers/ChallengeEditor/index.js +++ b/src/containers/ChallengeEditor/index.js @@ -10,6 +10,7 @@ import { loadTimelineTemplates, loadChallengePhases, loadChallengeTypes, + loadChallengeTracks, loadChallengeTimelines, loadChallengeTags, loadChallengeTerms, @@ -30,6 +31,7 @@ class ChallengeEditor extends Component { loadTimelineTemplates, loadChallengePhases, loadChallengeTypes, + loadChallengeTracks, loadChallengeTimelines, loadChallengeTags, loadChallengeTerms, @@ -41,6 +43,7 @@ class ChallengeEditor extends Component { loadTimelineTemplates() loadChallengePhases() loadChallengeTypes() + loadChallengeTracks() loadChallengeTimelines() loadChallengeTags() loadChallengeTerms() @@ -169,6 +172,7 @@ ChallengeEditor.propTypes = { loadTimelineTemplates: PropTypes.func, loadChallengePhases: PropTypes.func, loadChallengeTypes: PropTypes.func, + loadChallengeTracks: PropTypes.func, loadChallengeTimelines: PropTypes.func, loadChallengeTags: PropTypes.func, loadChallengeTerms: PropTypes.func, @@ -207,6 +211,7 @@ const mapDispatchToProps = { loadTimelineTemplates, loadChallengePhases, loadChallengeTypes, + loadChallengeTracks, loadChallengeTimelines, loadChallengeTags, loadGroups, diff --git a/src/services/challenges.js b/src/services/challenges.js index 0e29d600..2560ab08 100644 --- a/src/services/challenges.js +++ b/src/services/challenges.js @@ -6,6 +6,7 @@ import FormData from 'form-data' const { CHALLENGE_API_URL, CHALLENGE_TYPES_URL, + CHALLENGE_TRACKS_URL, CHALLENGE_TIMELINE_TEMPLATES_URL, CHALLENGE_PHASES_URL, CHALLENGE_TIMELINES_URL, @@ -26,6 +27,15 @@ export async function fetchChallengeTypes () { return _.get(response, 'data', []) } +/** + * Api request for fetching challenge tracks + * @returns {Promise<*>} + */ +export async function fetchChallengeTracks () { + const response = await axiosInstance.get(`${CHALLENGE_TRACKS_URL}`) + return _.get(response, 'data', []) +} + /** * Api request for fetching challenge tags * @returns {Promise<*>} diff --git a/src/util/tc.js b/src/util/tc.js index ffbd4b19..fb056b11 100644 --- a/src/util/tc.js +++ b/src/util/tc.js @@ -32,6 +32,8 @@ export function getRatingColor (rating) { } /** + * ********** UNUSED ************************ + * * Handle special subtrack DEVELOP_MARATHON_MATCH * @param {String} track * @param {String} subTrack From 2f08be40f58685b30d3d44dc35460a3fd105d3e9 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Wed, 12 Aug 2020 19:46:35 +0530 Subject: [PATCH 08/11] feat: git#674-Enable Chameleon in Production --- config/constants/development.js | 3 ++- config/constants/production.js | 3 ++- src/config/constants.js | 5 ++++- src/index.js | 11 +++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/config/constants/development.js b/config/constants/development.js index de9716ee..08aadc94 100644 --- a/config/constants/development.js +++ b/config/constants/development.js @@ -30,5 +30,6 @@ module.exports = { DEV_TRACK_ID: '9b6fc876-f4d9-4ccb-9dfd-419247628825', DES_TRACK_ID: '5fa04185-041f-49a6-bfd1-fe82533cd6c8', DS_TRACK_ID: 'c0f5d461-8219-4c14-878a-c3a3f356466d', - QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115' + QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115', + SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n' } diff --git a/config/constants/production.js b/config/constants/production.js index 3223c048..3456ff9e 100644 --- a/config/constants/production.js +++ b/config/constants/production.js @@ -30,5 +30,6 @@ module.exports = { DEV_TRACK_ID: '9b6fc876-f4d9-4ccb-9dfd-419247628825', DES_TRACK_ID: '5fa04185-041f-49a6-bfd1-fe82533cd6c8', DS_TRACK_ID: 'c0f5d461-8219-4c14-878a-c3a3f356466d', - QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115' + QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115', + SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF' } diff --git a/src/config/constants.js b/src/config/constants.js index f7355165..0f3e37c5 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -13,7 +13,8 @@ export const { DEV_TRACK_ID, DES_TRACK_ID, DS_TRACK_ID, - QA_TRACK_ID + QA_TRACK_ID, + SEGMENT_API_KEY } = process.env // Actions @@ -124,3 +125,5 @@ export const downloadAttachmentURL = (challengeId, attachmentId, token) => `${CHALLENGE_API_URL}/${challengeId}/attachments/${attachmentId}?token=${token}` export const PAGE_SIZE = 50 + +export const SEGMENT_API_KEY = SEGMENT_API_KEY diff --git a/src/index.js b/src/index.js index 397b1c90..e89124e1 100644 --- a/src/index.js +++ b/src/index.js @@ -6,5 +6,16 @@ import ReactDOM from 'react-dom' import './styles/main.scss' import 'react-redux-toastr/lib/css/react-redux-toastr.min.css' import App from './App' +import { SEGMENT_KEY } from './config/constants' ReactDOM.render(, document.getElementById('root')) + + +/* eslint-disable */ +if (!_.isEmpty(SEGMENT_KEY)) { + !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e Date: Wed, 12 Aug 2020 20:08:44 +0530 Subject: [PATCH 09/11] fix: lint --- src/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index e89124e1..4ee0f435 100644 --- a/src/index.js +++ b/src/index.js @@ -6,11 +6,10 @@ import ReactDOM from 'react-dom' import './styles/main.scss' import 'react-redux-toastr/lib/css/react-redux-toastr.min.css' import App from './App' -import { SEGMENT_KEY } from './config/constants' +import { SEGMENT_KEY } from './config/constants' ReactDOM.render(, document.getElementById('root')) - /* eslint-disable */ if (!_.isEmpty(SEGMENT_KEY)) { !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e Date: Wed, 12 Aug 2020 23:32:16 +0530 Subject: [PATCH 10/11] More lint fix --- src/config/constants.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/config/constants.js b/src/config/constants.js index 0f3e37c5..0e9a9919 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -125,5 +125,3 @@ export const downloadAttachmentURL = (challengeId, attachmentId, token) => `${CHALLENGE_API_URL}/${challengeId}/attachments/${attachmentId}?token=${token}` export const PAGE_SIZE = 50 - -export const SEGMENT_API_KEY = SEGMENT_API_KEY From a505002dcfe47028977e25899da9f06f7be38e70 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Thu, 13 Aug 2020 11:01:40 +0530 Subject: [PATCH 11/11] Fixed wrong import for SEGMENT_API_KEY --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 4ee0f435..def73426 100644 --- a/src/index.js +++ b/src/index.js @@ -6,14 +6,14 @@ import ReactDOM from 'react-dom' import './styles/main.scss' import 'react-redux-toastr/lib/css/react-redux-toastr.min.css' import App from './App' -import { SEGMENT_KEY } from './config/constants' +import { SEGMENT_API_KEY } from './config/constants' ReactDOM.render(, document.getElementById('root')) /* eslint-disable */ -if (!_.isEmpty(SEGMENT_KEY)) { +if (!_.isEmpty(SEGMENT_API_KEY)) { !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e