From c6a7ba463857929a50d87ca7765e642336de3b6f Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Wed, 5 Aug 2020 02:18:59 -0300 Subject: [PATCH 1/4] Removed getChallengeSubTrack and added getChallengeTypeAbbr --- .../TrackIcon/__snapshots__/index.jsx.snap | 6 +- .../components/TrackIcon/Abbreviation.jsx | 79 ------------------- src/shared/components/TrackIcon/index.jsx | 8 +- .../challenge-detail/Header/index.jsx | 8 +- .../ChallengesCard/index.jsx | 8 +- .../challenge-listing/ChallengeCard/index.jsx | 9 ++- .../containers/challenge-detail/index.jsx | 9 +-- src/shared/utils/challenge-detail/helper.jsx | 8 +- 8 files changed, 24 insertions(+), 111 deletions(-) delete mode 100644 src/shared/components/TrackIcon/Abbreviation.jsx diff --git a/__tests__/shared/components/TrackIcon/__snapshots__/index.jsx.snap b/__tests__/shared/components/TrackIcon/__snapshots__/index.jsx.snap index 3b2750a7be..9ea76c5bbd 100644 --- a/__tests__/shared/components/TrackIcon/__snapshots__/index.jsx.snap +++ b/__tests__/shared/components/TrackIcon/__snapshots__/index.jsx.snap @@ -7,7 +7,7 @@ exports[`Matches shallow shapshot 1`] = `
- Cd + CH
- Cd + CH - Cd + CH - {Abbreviation[track.toUpperCase()][subTrack]} + {type} ) : (
- {Abbreviation[track.toUpperCase()][subTrack]} + {type}
)} @@ -48,6 +48,7 @@ TrackIcon.defaultProps = { challengesUrl: '', track: 'DEVELOP', subTrack: 'DEVELOPMENT', + type: 'CH', }; TrackIcon.propTypes = { @@ -55,6 +56,7 @@ TrackIcon.propTypes = { tcoEligible: PT.string, track: PT.string, subTrack: PT.string, + type: PT.string, MAIN_URL: PT.string, challengesUrl: PT.string, }; diff --git a/src/shared/components/challenge-detail/Header/index.jsx b/src/shared/components/challenge-detail/Header/index.jsx index 834dff4f5e..cc8713b283 100644 --- a/src/shared/components/challenge-detail/Header/index.jsx +++ b/src/shared/components/challenge-detail/Header/index.jsx @@ -9,7 +9,6 @@ import _ from 'lodash'; import moment from 'moment'; import 'moment-duration-format'; import { isMM } from 'utils/challenge'; -import { getChallengeSubTrack } from 'utils/challenge-detail/helper'; import PT from 'prop-types'; import React from 'react'; @@ -37,7 +36,6 @@ export default function ChallengeHeader(props) { isLoggedIn, challenge, challengesUrl, - challengeTypes, checkpoints, hasRegistered, numWinners, @@ -74,9 +72,8 @@ export default function ChallengeHeader(props) { status, } = challenge; - const { track } = legacy; + const { track, subTrack } = legacy; const tags = challenge.tags || []; - const subTrack = getChallengeSubTrack(challenge.type, challengeTypes); const allPhases = challenge.phases || []; const { prizes } = prizeSets && prizeSets.length ? prizeSets[0] : []; @@ -472,7 +469,6 @@ ChallengeHeader.defaultProps = { isMenuOpened: false, hasThriveArticles: false, hasRecommendedChallenges: false, - challengeTypes: [], }; ChallengeHeader.propTypes = { @@ -492,6 +488,7 @@ ChallengeHeader.propTypes = { prizes: PT.any, legacy: PT.shape({ track: PT.any, + subTrack: PT.string, }), reliabilityBonus: PT.any, userDetails: PT.any, @@ -505,7 +502,6 @@ ChallengeHeader.propTypes = { prizeSets: PT.any, }).isRequired, challengesUrl: PT.string.isRequired, - challengeTypes: PT.arrayOf(PT.shape()), hasRegistered: PT.bool.isRequired, hasThriveArticles: PT.bool, hasRecommendedChallenges: PT.bool, diff --git a/src/shared/components/challenge-detail/RecommendedActiveChallenges/ChallengesCard/index.jsx b/src/shared/components/challenge-detail/RecommendedActiveChallenges/ChallengesCard/index.jsx index 51805e70b0..0541118825 100644 --- a/src/shared/components/challenge-detail/RecommendedActiveChallenges/ChallengesCard/index.jsx +++ b/src/shared/components/challenge-detail/RecommendedActiveChallenges/ChallengesCard/index.jsx @@ -9,7 +9,6 @@ import { PRIZE_MODE, getPrizePurseUI, getTimeLeft, - getChallengeSubTrack, } from 'utils/challenge-detail/helper'; import TrackIcon from 'components/TrackIcon'; @@ -21,7 +20,6 @@ import styles from './style.scss'; export default function ChallengesCard({ challenge, - challengeTypes, className, challengesUrl, selectChallengeDetailsTab, @@ -38,7 +36,7 @@ export default function ChallengesCard({ } = challenge; let { track } = legacy; - const subTrack = getChallengeSubTrack(challenge.type, challengeTypes); + const { subTrack } = legacy; if (subTrack === 'DEVELOP_MARATHON_MATCH') { track = 'DATA_SCIENCE'; } @@ -87,7 +85,7 @@ export default function ChallengesCard({
{challenge.status === 'Active' ? 'Ends ' : 'Ended '} - {getEndDate(challenge, challengeTypes)} + {getEndDate(challenge)}
{getPrizePurseUI(challenge, prizeMode, true, 'Prize Purse')} @@ -121,12 +119,10 @@ ChallengesCard.defaultProps = { userHandle: '', expandedTags: [], expandTag: null, - challengeTypes: [], }; ChallengesCard.propTypes = { challenge: PT.shape().isRequired, - challengeTypes: PT.arrayOf(PT.shape()), className: PT.string, challengesUrl: PT.string.isRequired, selectChallengeDetailsTab: PT.func.isRequired, diff --git a/src/shared/components/challenge-listing/ChallengeCard/index.jsx b/src/shared/components/challenge-listing/ChallengeCard/index.jsx index fd31079915..e597e03bef 100644 --- a/src/shared/components/challenge-listing/ChallengeCard/index.jsx +++ b/src/shared/components/challenge-listing/ChallengeCard/index.jsx @@ -8,7 +8,7 @@ import { isDevelopMM } from 'utils/challenge'; import { getEndDate, getPrizePointsUI, - getChallengeSubTrack, + getChallengeTypeAbbr, } from 'utils/challenge-detail/helper'; import Tags from '../Tags'; @@ -44,6 +44,7 @@ function ChallengeCard({ } = challenge; let { track } = legacy; + const { subTrack } = legacy; challenge.isDataScience = false; if ((challenge.tags && challenge.tags.includes('Data Science')) || isDevelopMM(challenge)) { challenge.isDataScience = true; @@ -51,8 +52,7 @@ function ChallengeCard({ challenge.prize = challenge.prizes || []; const challengeDetailLink = `${challengesUrl}/${id}`; - - const subTrack = getChallengeSubTrack(challenge.type, challengeTypes); + const type = getChallengeTypeAbbr(challenge.type, challengeTypes); if (subTrack === 'DEVELOP_MARATHON_MATCH') { track = 'DATA_SCIENCE'; } @@ -72,6 +72,7 @@ function ChallengeCard({ 0 ? challenge.events[0].eventName : ''} isDataScience={challenge.isDataScience} /> @@ -90,7 +91,7 @@ function ChallengeCard({
{challenge.status === 'Active' ? 'Ends ' : 'Ended '} - {getEndDate(challenge, challengeTypes)} + {getEndDate(challenge)} { challenge.tags.length > 0 && ( diff --git a/src/shared/containers/challenge-detail/index.jsx b/src/shared/containers/challenge-detail/index.jsx index 15d15dc5dc..a05521eb3a 100644 --- a/src/shared/containers/challenge-detail/index.jsx +++ b/src/shared/containers/challenge-detail/index.jsx @@ -38,7 +38,6 @@ import { actions } from 'topcoder-react-lib'; import { getService } from 'services/contentful'; import { getDisplayRecommendedChallenges, - getChallengeSubTrack, getRecommendedTags, } from 'utils/challenge-detail/helper'; @@ -79,9 +78,9 @@ const DAY = 24 * 60 * MIN; * @param {Object} challenge * @return {String} */ -function getOgImage(challenge, challengeTypes) { +function getOgImage(challenge) { const { legacy } = challenge; - const { track } = legacy; + const { track, subTrack } = legacy; if (challenge.name.startsWith('LUX -')) return ogLuxChallenge; if (challenge.name.startsWith('RUX -')) return ogRuxChallenge; if (challenge.prizes) { @@ -89,8 +88,6 @@ function getOgImage(challenge, challengeTypes) { if (totalPrize > 2500) return ogBigPrizesChallenge; } - const subTrack = getChallengeSubTrack(challenge.type, challengeTypes); - switch (subTrack) { case SUBTRACKS.FIRST_2_FINISH: return ogFirst2Finish; case SUBTRACKS.UI_PROTOTYPE_COMPETITION: { @@ -430,7 +427,7 @@ class ChallengeDetailPageContainer extends React.Component { && ( p.phaseType === 'Iterative Review' && p.phaseStatus === 'Closed'); From 68de6f26c11899db12872e617f49037a6f84656c Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Wed, 5 Aug 2020 05:46:35 -0300 Subject: [PATCH 2/4] Added QA to challenge listing filter --- .../__snapshots__/ChallengeFilters.jsx.snap | 21 +++++++++++++++++++ src/shared/components/TrackIcon/style.scss | 7 +++++-- .../challenge-listing/ChallengeCard/index.jsx | 4 ++++ .../Filters/ChallengeFilters.jsx | 9 ++++++++ .../Filters/ChallengeSearchBar/style.scss | 2 +- .../Filters/EditTrackPanel/index.jsx | 15 +++++++++++++ .../TrackAbbreviationTooltip/index.jsx | 1 + .../TrackAbbreviationTooltip/style.scss | 4 ++++ 8 files changed, 60 insertions(+), 3 deletions(-) diff --git a/__tests__/shared/components/challenge-listing/Filters/__snapshots__/ChallengeFilters.jsx.snap b/__tests__/shared/components/challenge-listing/Filters/__snapshots__/ChallengeFilters.jsx.snap index 5a29b8846c..9ea194e1b3 100644 --- a/__tests__/shared/components/challenge-listing/Filters/__snapshots__/ChallengeFilters.jsx.snap +++ b/__tests__/shared/components/challenge-listing/Filters/__snapshots__/ChallengeFilters.jsx.snap @@ -85,9 +85,11 @@ exports[`Matches shallow shapshot shapshot 1`] = ` devEnabled={true} onClose={[Function]} opened={true} + qaEnabled={true} switchDataScience={[Function]} switchDesign={[Function]} switchDev={[Function]} + switchQA={[Function]} />
`; @@ -159,6 +161,23 @@ exports[`Matches shallow shapshot shapshot 2`] = ` themePriority="adhoc-context-default" /> + + +
`; diff --git a/src/shared/components/TrackIcon/style.scss b/src/shared/components/TrackIcon/style.scss index e901c04e35..4ab4f3cf38 100644 --- a/src/shared/components/TrackIcon/style.scss +++ b/src/shared/components/TrackIcon/style.scss @@ -34,11 +34,14 @@ $track-radius-4: $corner-radius * 2; background: $tc-light-blue-110; } - &.develop, - &.qa { + &.develop { background: $tc-green-110; } + &.qa { + background: $tc-purple-110; + } + &.data_science, &.data-science, &.data { diff --git a/src/shared/components/challenge-listing/ChallengeCard/index.jsx b/src/shared/components/challenge-listing/ChallengeCard/index.jsx index e597e03bef..02372fd87c 100644 --- a/src/shared/components/challenge-listing/ChallengeCard/index.jsx +++ b/src/shared/components/challenge-listing/ChallengeCard/index.jsx @@ -48,6 +48,10 @@ function ChallengeCard({ challenge.isDataScience = false; if ((challenge.tags && challenge.tags.includes('Data Science')) || isDevelopMM(challenge)) { challenge.isDataScience = true; + track = 'DATA_SCIENCE'; + } + if (challenge.tags && challenge.tags.includes('QA')) { + track = 'QA'; } challenge.prize = challenge.prizes || []; diff --git a/src/shared/components/challenge-listing/Filters/ChallengeFilters.jsx b/src/shared/components/challenge-listing/Filters/ChallengeFilters.jsx index accee1d144..555989af4d 100644 --- a/src/shared/components/challenge-listing/Filters/ChallengeFilters.jsx +++ b/src/shared/components/challenge-listing/Filters/ChallengeFilters.jsx @@ -100,6 +100,13 @@ export default function ChallengeFilters({ onSwitch={on => switchTrack(TRACKS.DATA_SCIENCE, on)} /> + + switchTrack(TRACKS.QA, on)} + /> + ) : '' } @@ -178,6 +185,8 @@ export default function ChallengeFilters({ switchDev={on => switchTrack(TRACKS.DEVELOP, on)} dataScienceEnabled={isTrackOn(TRACKS.DATA_SCIENCE)} switchDataScience={on => switchTrack(TRACKS.DATA_SCIENCE, on)} + qaEnabled={isTrackOn(TRACKS.QA)} + switchQA={on => switchTrack(TRACKS.QA, on)} />
); diff --git a/src/shared/components/challenge-listing/Filters/ChallengeSearchBar/style.scss b/src/shared/components/challenge-listing/Filters/ChallengeSearchBar/style.scss index 08cfe39428..bcf05d0753 100644 --- a/src/shared/components/challenge-listing/Filters/ChallengeSearchBar/style.scss +++ b/src/shared/components/challenge-listing/Filters/ChallengeSearchBar/style.scss @@ -10,7 +10,7 @@ $challenge-radius-4: $corner-radius * 2; /* -100px is necessary to compensate for the temporarly added `Alpha preview` * banner. Should be modified / removed together with banner. */ -$search-bar-width: '100% - 475px'; +$search-bar-width: '100% - 536px'; $search-input-width: '100% - 56px'; .ChallengeSearchBar { diff --git a/src/shared/components/challenge-listing/Filters/EditTrackPanel/index.jsx b/src/shared/components/challenge-listing/Filters/EditTrackPanel/index.jsx index ed9bac85d1..12ee5f8ba5 100644 --- a/src/shared/components/challenge-listing/Filters/EditTrackPanel/index.jsx +++ b/src/shared/components/challenge-listing/Filters/EditTrackPanel/index.jsx @@ -16,6 +16,8 @@ * switchDev={enable => this.setTracks(DEVELOP_TRACK, enable)} * dataScienceEnabled={this.state.filter.tracks.has(DATA_SCIENCE_TRACK)} * switchDataScience={enable => this.setTracks(DATA_SCIENCE_TRACK, enable)} + * qaEnabled={this.state.filter.tracks.has(QA_TRACK)} + * switchQA={enable => this.setTracks(QA_TRACK, enable)} * /> */ import React from 'react'; @@ -28,11 +30,13 @@ function EditTrackPanel({ dataScienceEnabled, designEnabled, devEnabled, + qaEnabled, onClose, opened, switchDataScience, switchDesign, switchDev, + switchQA, }) { return (
@@ -75,6 +79,15 @@ function EditTrackPanel({ onSwitch={switchDataScience} />
+
+ + QA + + +
); } @@ -92,6 +105,8 @@ EditTrackPanel.propTypes = { switchDev: PT.func.isRequired, dataScienceEnabled: PT.bool.isRequired, switchDataScience: PT.func.isRequired, + qaEnabled: PT.bool.isRequired, + switchQA: PT.func.isRequired, }; export default EditTrackPanel; diff --git a/src/shared/components/challenge-listing/Tooltips/TrackAbbreviationTooltip/index.jsx b/src/shared/components/challenge-listing/Tooltips/TrackAbbreviationTooltip/index.jsx index 224117ded4..026209837e 100644 --- a/src/shared/components/challenge-listing/Tooltips/TrackAbbreviationTooltip/index.jsx +++ b/src/shared/components/challenge-listing/Tooltips/TrackAbbreviationTooltip/index.jsx @@ -92,6 +92,7 @@ const TRACK_COLOR_CLASS = { DESIGN: 'blue', DEVELOP: 'green', DATA_SCIENCE: 'orange', + QA: 'purple', }; /** diff --git a/src/shared/components/challenge-listing/Tooltips/TrackAbbreviationTooltip/style.scss b/src/shared/components/challenge-listing/Tooltips/TrackAbbreviationTooltip/style.scss index 739b189366..aab74eb239 100644 --- a/src/shared/components/challenge-listing/Tooltips/TrackAbbreviationTooltip/style.scss +++ b/src/shared/components/challenge-listing/Tooltips/TrackAbbreviationTooltip/style.scss @@ -25,6 +25,10 @@ $track-radius-4: $corner-radius * 2; &.orange { border-left: $track-radius-4 solid $tc-orange; } + + &.purple { + border-left: $track-radius-4 solid $tc-purple; + } } .body { From 7e37f2ca8d485ed917a63f9d88390fb6c930f13e Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Wed, 5 Aug 2020 20:32:23 -0300 Subject: [PATCH 3/4] Updated challengeSubtracks to challengeTypes in filter --- .../Filters/ChallengeFilters.jsx | 6 +-- .../Filters/FiltersPanel.jsx | 4 +- .../__snapshots__/ChallengeFilters.jsx.snap | 10 ++--- .../__snapshots__/FiltersPanel.jsx.snap | 16 ++++---- .../challenge-listing/FilterPanel.jsx | 10 ++--- .../containers/challenge-listing/Listing.jsx | 4 +- src/shared/actions/challenge-listing/index.js | 2 +- .../Contentful/ChallengesBlock/Card/index.jsx | 6 ++- .../Challenges/ChallengeCard/index.jsx | 40 +++++++------------ .../CurrentActivity/Challenges/index.jsx | 6 +-- .../Dashboard/CurrentActivity/index.jsx | 6 +-- src/shared/components/Dashboard/index.jsx | 6 +-- .../challenge-detail/Header/ChallengeTags.jsx | 32 +++++++-------- .../challenge-detail/Header/index.jsx | 8 ++-- .../Filters/ChallengeFilters.jsx | 8 ++-- .../Filters/FiltersPanel/index.jsx | 22 +++++----- .../challenge-listing/Listing/index.jsx | 2 +- src/shared/containers/Dashboard/index.jsx | 12 +++--- .../containers/challenge-detail/index.jsx | 14 +++---- .../challenge-listing/FilterPanel.jsx | 10 ++--- .../challenge-listing/Listing/index.jsx | 8 +--- .../containers/challenge-listing/Sidebar.jsx | 2 +- .../tc-communities/cognitive/home.jsx | 2 +- .../reducers/challenge-listing/index.js | 8 ++-- src/shared/utils/challenge.js | 8 ++-- 25 files changed, 119 insertions(+), 133 deletions(-) diff --git a/__tests__/shared/components/challenge-listing/Filters/ChallengeFilters.jsx b/__tests__/shared/components/challenge-listing/Filters/ChallengeFilters.jsx index f1d3b99750..2c42662b37 100644 --- a/__tests__/shared/components/challenge-listing/Filters/ChallengeFilters.jsx +++ b/__tests__/shared/components/challenge-listing/Filters/ChallengeFilters.jsx @@ -39,14 +39,14 @@ const mockDatas = [{ showTrackModal, trackModalShown: true, validKeywords: [''], - validSubtracks: [''], + validTypes: [''], }, { challengeGroupId: '1', communityFilters: [{ filter: {} }], communityName: 'name', expanded: false, filterState: { - tags: ['abc'], subtracks: ['CODE'], endDate: moment('2019-12-31T23:00:00.000Z'), startDate: moment('2019-12-31T23:00:00.000Z'), tracks: ['tracks'], + tags: ['abc'], types: ['927abff4-7af9-4145-8ba1-577c16e64e2e'], endDate: moment('2019-12-31T23:00:00.000Z'), startDate: moment('2019-12-31T23:00:00.000Z'), tracks: ['tracks'], }, isCardTypeSet: 'Challenges', saveFilter, @@ -59,7 +59,7 @@ const mockDatas = [{ showTrackModal, trackModalShown: true, validKeywords: [''], - validSubtracks: [''], + validTypes: [''], }]; describe('Matches shallow shapshot', () => { diff --git a/__tests__/shared/components/challenge-listing/Filters/FiltersPanel.jsx b/__tests__/shared/components/challenge-listing/Filters/FiltersPanel.jsx index 82fd4e8cc8..126bf4a6b0 100644 --- a/__tests__/shared/components/challenge-listing/Filters/FiltersPanel.jsx +++ b/__tests__/shared/components/challenge-listing/Filters/FiltersPanel.jsx @@ -25,7 +25,7 @@ const mockDatas = [{ setFilterState, setSearchText, validKeywords: ['key', 'word'], - validSubtracks: [{ name: 'sub', subTrack: 'sub' }, { name: 'track', subTrack: 'track' }], + validTypes: [{ name: 'sub', subTrack: 'sub' }, { name: 'track', subTrack: 'track' }], onClose, }, { communityFilters: [ @@ -42,7 +42,7 @@ const mockDatas = [{ setFilterState, setSearchText, validKeywords: [], - validSubtracks: [], + validTypes: [], onClose, }]; diff --git a/__tests__/shared/components/challenge-listing/Filters/__snapshots__/ChallengeFilters.jsx.snap b/__tests__/shared/components/challenge-listing/Filters/__snapshots__/ChallengeFilters.jsx.snap index 9ea194e1b3..4fe80207f5 100644 --- a/__tests__/shared/components/challenge-listing/Filters/__snapshots__/ChallengeFilters.jsx.snap +++ b/__tests__/shared/components/challenge-listing/Filters/__snapshots__/ChallengeFilters.jsx.snap @@ -73,7 +73,7 @@ exports[`Matches shallow shapshot shapshot 1`] = ` "", ] } - validSubtracks={ + validTypes={ Array [ "", ] @@ -235,15 +235,15 @@ exports[`Matches shallow shapshot shapshot 2`] = ` Object { "endDate": "2019-12-31T23:00:00.000Z", "startDate": "2019-12-31T23:00:00.000Z", - "subtracks": Array [ - "CODE", - ], "tags": Array [ "abc", ], "tracks": Array [ "tracks", ], + "types": Array [ + "927abff4-7af9-4145-8ba1-577c16e64e2e", + ], } } hidden={true} @@ -261,7 +261,7 @@ exports[`Matches shallow shapshot shapshot 2`] = ` "", ] } - validSubtracks={ + validTypes={ Array [ "", ] diff --git a/__tests__/shared/components/challenge-listing/Filters/__snapshots__/FiltersPanel.jsx.snap b/__tests__/shared/components/challenge-listing/Filters/__snapshots__/FiltersPanel.jsx.snap index eaf347c8fe..0a5978ac93 100644 --- a/__tests__/shared/components/challenge-listing/Filters/__snapshots__/FiltersPanel.jsx.snap +++ b/__tests__/shared/components/challenge-listing/Filters/__snapshots__/FiltersPanel.jsx.snap @@ -109,15 +109,15 @@ exports[`Matches shallow shapshot 1`] = ` >