Skip to content

Commit 211f09d

Browse files
authored
Merge pull request #4060 from topcoder-platform/feature-m2m-with-stats
PR for private stats feature
2 parents a53ad36 + f1e54e6 commit 211f09d

File tree

43 files changed

+520
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+520
-52
lines changed

.circleci/config.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ workflows:
174174
filters:
175175
branches:
176176
only:
177-
- develop
178-
- feature-m2m-token
177+
- feature-m2m-with-stats
179178
# This is alternate dev env for parallel testing
180179
- "build-test":
181180
context : org-global
@@ -191,8 +190,7 @@ workflows:
191190
filters:
192191
branches:
193192
only:
194-
- develop
195-
- feature-contentful
193+
- develop
196194
# Production builds are exectuted only on tagged commits to the
197195
# master branch.
198196
- "build-prod":

__tests__/shared/components/ProfilePage/__snapshots__/index.jsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ exports[`renders a full Profile correctly 1`] = `
199199
className=""
200200
handle="testHandle"
201201
inModal={false}
202+
meta={null}
202203
stats={
203204
Object {
204205
"COPILOT": Object {
@@ -699,6 +700,7 @@ exports[`renders an empty Profile correctly 1`] = `
699700
className=""
700701
handle="testHandle"
701702
inModal={false}
703+
meta={null}
702704
stats={
703705
Object {
704706
"COPILOT": null,

src/shared/components/ProfilePage/Skill/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const Skill = ({
3737
Skill.propTypes = {
3838
tagId: PT.string.isRequired,
3939
tagName: PT.string.isRequired,
40-
isVerified: PT.string.isRequired,
40+
isVerified: PT.bool.isRequired,
4141
};
4242

4343
export default Skill;

src/shared/components/ProfilePage/Stats/index.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import _ from 'lodash';
66
import React from 'react';
77
import PT from 'prop-types';
8-
import { Link } from 'react-router-dom';
98
import ReactSVG from 'react-svg';
10-
import { isomorphy } from 'topcoder-react-utils';
9+
import { Link, isomorphy } from 'topcoder-react-utils';
1110
import { getRatingColor } from 'utils/tc';
1211
import Th from 'assets/images/th.svg';
1312
import LeftArrow from 'assets/images/arrow-prev.svg';
@@ -50,7 +49,6 @@ class ProfileStats extends React.Component {
5049

5150
render() {
5251
const {
53-
stats,
5452
statsDistribution,
5553
statsHistory,
5654
track,
@@ -60,6 +58,11 @@ class ProfileStats extends React.Component {
6058
handleParam,
6159
activeChallengesCount,
6260
} = this.props;
61+
let { stats } = this.props;
62+
if (_.isArray(stats)) {
63+
// eslint-disable-next-line prefer-destructuring
64+
stats = stats[0];
65+
}
6366

6467
const { activeGraph, showModal } = this.state;
6568

@@ -300,7 +303,7 @@ ProfileStats.defaultProps = {
300303
};
301304

302305
ProfileStats.propTypes = {
303-
stats: PT.shape().isRequired,
306+
stats: PT.arrayOf(PT.shape()).isRequired,
304307
handleParam: PT.string.isRequired,
305308
track: PT.string.isRequired,
306309
subTrack: PT.string.isRequired,

src/shared/components/ProfilePage/StatsCategory/index.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ const isActiveSubtrack = (subtrack) => {
4343

4444
class StatsCategory extends React.Component {
4545
getActiveTracks() {
46-
const { stats } = this.props;
46+
let { stats } = this.props;
47+
if (_.isArray(stats)) {
48+
// eslint-disable-next-line prefer-destructuring
49+
stats = stats[0];
50+
}
4751
const activeTracks = [];
4852

4953
if (stats.COPILOT && stats.COPILOT.fulfillment) {
@@ -89,6 +93,7 @@ class StatsCategory extends React.Component {
8993
handle,
9094
className,
9195
inModal,
96+
meta,
9297
} = this.props;
9398

9499
const activeTracks = this.getActiveTracks();
@@ -113,7 +118,7 @@ class StatsCategory extends React.Component {
113118
<Link
114119
to={`/members/${handle}/details/?track=${track.name}&subTrack=${subtrack.name.replace(' ', '_')}`}
115120
key={subtrack.name}
116-
styleName={`subtrack ${index === 0 ? 'first' : ''}`}
121+
styleName={`subtrack ${index === 0 ? 'first' : ''} ${meta ? 'disablelink' : ''}`}
117122
>
118123
<div
119124
styleName="name"
@@ -179,13 +184,15 @@ class StatsCategory extends React.Component {
179184
StatsCategory.defaultProps = {
180185
className: '',
181186
inModal: false,
187+
meta: null,
182188
};
183189

184190
StatsCategory.propTypes = {
185191
handle: PT.string.isRequired,
186-
stats: PT.shape().isRequired,
192+
stats: PT.arrayOf(PT.shape()).isRequired,
187193
inModal: PT.bool,
188194
className: PT.string,
195+
meta: PT.shape(),
189196
};
190197

191198
export default StatsCategory;

src/shared/components/ProfilePage/StatsCategory/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@
147147
}
148148
}
149149

150+
.disablelink {
151+
pointer-events: none;
152+
}
153+
150154
.icon {
151155
width: 80px;
152156
height: 80px;

src/shared/components/ProfilePage/index.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ class ProfilePage extends React.Component {
6363
}
6464

6565
getActiveTracks() {
66-
const { copilot, stats } = this.props;
66+
const { copilot } = this.props;
67+
let { stats } = this.props;
68+
if (_.isArray(stats)) {
69+
// eslint-disable-next-line prefer-destructuring
70+
stats = stats[0];
71+
}
6772
const activeTracks = [];
6873

6974
if (copilot && stats && stats.COPILOT && stats.COPILOT.fulfillment) {
@@ -118,6 +123,7 @@ class ProfilePage extends React.Component {
118123
skills: propSkills,
119124
stats,
120125
lookupData,
126+
meta,
121127
} = this.props;
122128

123129
const {
@@ -257,7 +263,7 @@ class ProfilePage extends React.Component {
257263
{
258264
stats && (
259265
<div id="profile-activity">
260-
<StatsCategory handle={info.handle} stats={stats} />
266+
<StatsCategory handle={info.handle} stats={stats} meta={meta} />
261267
</div>
262268
)
263269
}
@@ -297,6 +303,7 @@ ProfilePage.defaultProps = {
297303
achievements: [],
298304
skills: null,
299305
stats: null,
306+
meta: null,
300307
};
301308

302309
ProfilePage.propTypes = {
@@ -306,8 +313,9 @@ ProfilePage.propTypes = {
306313
externalLinks: PT.arrayOf(PT.shape()),
307314
info: PT.shape().isRequired,
308315
skills: PT.shape(),
309-
stats: PT.shape(),
316+
stats: PT.arrayOf(PT.shape()),
310317
lookupData: PT.shape().isRequired,
318+
meta: PT.shape(),
311319
};
312320

313321
export default ProfilePage;

src/shared/containers/Profile.jsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* Connects the Redux store to the Profile display components.
33
*/
4+
import _ from 'lodash';
45
import React from 'react';
56
import PT from 'prop-types';
67
import { connect } from 'react-redux';
@@ -15,20 +16,22 @@ class ProfileContainer extends React.Component {
1516
const {
1617
handleParam,
1718
loadProfile,
19+
meta,
1820
} = this.props;
1921

20-
loadProfile(handleParam);
22+
loadProfile(handleParam, _.join(_.get(meta, 'groupIds', [])));
2123
}
2224

2325
componentWillReceiveProps(nextProps) {
2426
const {
2527
handleParam,
2628
profileForHandle,
2729
loadProfile,
30+
meta,
2831
} = nextProps;
2932

3033
if (handleParam !== profileForHandle) {
31-
loadProfile(handleParam);
34+
loadProfile(handleParam, _.join(_.get(meta, 'groupIds', [])));
3235
}
3336
}
3437

@@ -75,6 +78,7 @@ ProfileContainer.defaultProps = {
7578
profileForHandle: '',
7679
skills: null,
7780
stats: null,
81+
meta: null,
7882
};
7983

8084
ProfileContainer.propTypes = {
@@ -89,8 +93,9 @@ ProfileContainer.propTypes = {
8993
loadProfile: PT.func.isRequired,
9094
profileForHandle: PT.string,
9195
skills: PT.shape(),
92-
stats: PT.shape(),
96+
stats: PT.arrayOf(PT.shape()),
9397
lookupData: PT.shape().isRequired,
98+
meta: PT.shape(),
9499
};
95100

96101
const mapStateToProps = (state, ownProps) => ({
@@ -100,6 +105,7 @@ const mapStateToProps = (state, ownProps) => ({
100105
externalAccounts: state.profile.externalAccounts,
101106
externalLinks: state.profile.externalLinks,
102107
handleParam: ownProps.match.params.handle,
108+
meta: ownProps.meta,
103109
info: state.profile.info,
104110
loadingError: state.profile.loadingError,
105111
profileForHandle: state.profile.profileForHandle,
@@ -112,7 +118,7 @@ function mapDispatchToProps(dispatch) {
112118
const a = actions.profile;
113119
const lookupActions = actions.lookup;
114120
return {
115-
loadProfile: (handle) => {
121+
loadProfile: (handle, groupIds) => {
116122
dispatch(a.clearProfile());
117123
dispatch(a.loadProfile(handle));
118124
dispatch(a.getAchievementsInit());
@@ -127,7 +133,7 @@ function mapDispatchToProps(dispatch) {
127133
dispatch(a.getExternalLinksDone(handle));
128134
dispatch(a.getInfoDone(handle));
129135
dispatch(a.getSkillsDone(handle));
130-
dispatch(a.getStatsDone(handle));
136+
dispatch(a.getStatsDone(handle, groupIds));
131137
dispatch(lookupActions.getCountriesDone());
132138
},
133139
};

src/shared/containers/ProfileStats.jsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ class ProfileStatsContainer extends React.Component {
2323
location,
2424
loadStats,
2525
loadStatsHistoryAndDistribution,
26+
meta,
2627
} = this.props;
28+
2729
const trackAndSubTrack = getQueryParamsQuery(location);
28-
loadStats(handleParam);
30+
loadStats(handleParam, _.join(_.get(meta, 'groupIds', [])));
2931
if (shouldShowGraph(trackAndSubTrack)) {
3032
loadStatsHistoryAndDistribution(
3133
handleParam,
34+
_.join(_.get(meta, 'groupIds', [])),
3235
trackAndSubTrack.track,
3336
trackAndSubTrack.subTrack,
3437
);
@@ -41,6 +44,7 @@ class ProfileStatsContainer extends React.Component {
4144
location: nextLocation,
4245
loadStats,
4346
loadStatsHistoryAndDistribution,
47+
meta,
4448
} = nextProps;
4549
const {
4650
handleParam,
@@ -51,7 +55,7 @@ class ProfileStatsContainer extends React.Component {
5155
const trackAndSubTrack = getQueryParamsQuery(location);
5256

5357
if (nextHandleParam !== handleParam) {
54-
loadStats(nextHandleParam);
58+
loadStats(nextHandleParam, _.join(_.get(meta, 'groupIds', [])));
5559
if (
5660
nextQueryParams.track !== trackAndSubTrack.track
5761
|| nextQueryParams.subTrack !== trackAndSubTrack.subTrack
@@ -60,6 +64,7 @@ class ProfileStatsContainer extends React.Component {
6064
&& !nextQueryParams.tab) {
6165
loadStatsHistoryAndDistribution(
6266
nextHandleParam,
67+
_.join(_.get(meta, 'groupIds', [])),
6368
nextQueryParams.track,
6469
nextQueryParams.subTrack,
6570
);
@@ -73,6 +78,7 @@ class ProfileStatsContainer extends React.Component {
7378
loadingError,
7479
location,
7580
isLoading,
81+
meta,
7682
} = this.props;
7783

7884
const { track, subTrack, tab } = getQueryParamsQuery(location);
@@ -88,6 +94,7 @@ class ProfileStatsContainer extends React.Component {
8894
track={track}
8995
subTrack={subTrack}
9096
tab={tab}
97+
meta={meta}
9198
/>
9299
);
93100
}
@@ -100,6 +107,7 @@ ProfileStatsContainer.defaultProps = {
100107
stats: null,
101108
info: null,
102109
achievements: null,
110+
meta: null,
103111
};
104112

105113
ProfileStatsContainer.propTypes = {
@@ -110,10 +118,11 @@ ProfileStatsContainer.propTypes = {
110118
handleParam: PT.string.isRequired,
111119
statsHistory: PT.shape(),
112120
statsDistribution: PT.shape(),
113-
stats: PT.shape(),
121+
stats: PT.arrayOf(PT.shape()),
114122
info: PT.shape(),
115123
achievements: PT.arrayOf(PT.shape()),
116124
isLoading: PT.bool.isRequired,
125+
meta: PT.shape(),
117126
};
118127

119128
const mapStateToProps = (state, ownProps) => {
@@ -131,6 +140,7 @@ const mapStateToProps = (state, ownProps) => {
131140
statsDistribution: _.get(obj, 'statsDistribution.data'),
132141
activeChallengesCount: _.get(obj, 'activeChallengesCount'),
133142
info: state.profile.info,
143+
meta: ownProps.meta,
134144
achievements: state.profile.achievements,
135145
});
136146
};
@@ -140,17 +150,17 @@ function mapDispatchToProps(dispatch) {
140150
const pa = actions.profile;
141151

142152
return {
143-
loadStats: (handle) => {
153+
loadStats: (handle, groupIds) => {
144154
dispatch(a.getStatsInit(handle));
145-
dispatch(a.getStatsDone(handle));
155+
dispatch(a.getStatsDone(handle, groupIds));
146156
dispatch(pa.getInfoInit(handle));
147157
dispatch(pa.getInfoDone(handle));
148158
dispatch(a.getActiveChallengesInit(handle));
149159
dispatch(a.getActiveChallengesDone(handle));
150160
},
151-
loadStatsHistoryAndDistribution: (handle, track, subTrack) => {
152-
dispatch(a.getStatsHistoryInit(handle));
153-
dispatch(a.getStatsHistoryDone(handle));
161+
loadStatsHistoryAndDistribution: (handle, groupIds, track, subTrack) => {
162+
dispatch(a.getStatsHistoryInit(handle, groupIds));
163+
dispatch(a.getStatsHistoryDone(handle, groupIds));
154164
dispatch(a.getStatsDistributionInit(handle));
155165
dispatch(a.getStatsDistributionDone(handle, track, subTrack));
156166
},

0 commit comments

Comments
 (0)