Skip to content

Commit 7508d8e

Browse files
committed
Update in challenge listing: optionally open challenges in new tab
Fixes #136 Also contains misc clean-up of minor issues noted on the way
1 parent eb1e235 commit 7508d8e

File tree

18 files changed

+156
-56
lines changed

18 files changed

+156
-56
lines changed

__tests__/shared/components/__snapshots__/LeaderboardAvatar.jsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports[`Matches shallow shapshot 1`] = `
44
<a
55
className="src-shared-components-LeaderboardAvatar-___style__leaderboard-avatar___3GHTf src-shared-components-LeaderboardAvatar-___style__light-gray___2hXZL"
66
href="url"
7+
target={undefined}
78
>
89
han
910
<span

__tests__/shared/components/challenge-listing/ChallengeCard/__snapshots__/Status.jsx.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ exports[`Matches shallow shapshot shapshot 1 1`] = `
120120
className="src-shared-components-challenge-listing-ChallengeCard-Status-___style__register-button___3BoMk"
121121
href=""
122122
onClick={[Function]}
123+
target={undefined}
123124
>
124125
<span>
125126
897d 19:18h
@@ -249,6 +250,7 @@ exports[`Matches shallow shapshot shapshot 1 3`] = `
249250
"position": undefined,
250251
}
251252
}
253+
openNewTab={false}
252254
url=""
253255
/>
254256
</UserAvatarTooltip>
@@ -277,6 +279,7 @@ exports[`Matches shallow shapshot shapshot 1 3`] = `
277279
"position": undefined,
278280
}
279281
}
282+
openNewTab={false}
280283
url=""
281284
/>
282285
</UserAvatarTooltip>
@@ -305,6 +308,7 @@ exports[`Matches shallow shapshot shapshot 1 3`] = `
305308
"position": undefined,
306309
}
307310
}
311+
openNewTab={false}
308312
url=""
309313
/>
310314
</UserAvatarTooltip>
@@ -317,6 +321,7 @@ exports[`Matches shallow shapshot shapshot 1 3`] = `
317321
"isLastItem": true,
318322
}
319323
}
324+
openNewTab={false}
320325
url="#winner"
321326
/>
322327
<span

__tests__/shared/components/challenge-listing/ChallengeCard/__snapshots__/index.jsx.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ exports[`Matches shallow shapshot shapshot 1 1`] = `
3131
<a
3232
className="src-shared-components-challenge-listing-ChallengeCard-___style__challenge-title___vir_2"
3333
href="https://www.topcoder-dev.com/challenge-details/undefined/?type=develop"
34+
target={undefined}
3435
/>
3536
<div
3637
className="src-shared-components-challenge-listing-ChallengeCard-___style__details-footer___3zNR-"
@@ -123,6 +124,7 @@ exports[`Matches shallow shapshot shapshot 1 1`] = `
123124
}
124125
}
125126
detailLink="https://www.topcoder-dev.com/challenge-details/undefined/?type=develop"
127+
openChallengesInNewTabs={false}
126128
sampleWinnerProfile={undefined}
127129
/>
128130
</div>
@@ -160,6 +162,7 @@ exports[`Matches shallow shapshot shapshot 2 1`] = `
160162
<a
161163
className="src-shared-components-challenge-listing-ChallengeCard-___style__challenge-title___vir_2"
162164
href="https://community.topcoder-dev.com/tc?module=MatchDetails&rd=1"
165+
target={undefined}
163166
/>
164167
<div
165168
className="src-shared-components-challenge-listing-ChallengeCard-___style__details-footer___3zNR-"
@@ -244,6 +247,7 @@ exports[`Matches shallow shapshot shapshot 2 1`] = `
244247
}
245248
}
246249
detailLink="https://community.topcoder-dev.com/tc?module=MatchDetails&rd=1"
250+
openChallengesInNewTabs={false}
247251
sampleWinnerProfile={undefined}
248252
/>
249253
</div>
@@ -281,6 +285,7 @@ exports[`Matches shallow shapshot shapshot 3 1`] = `
281285
<a
282286
className="src-shared-components-challenge-listing-ChallengeCard-___style__challenge-title___vir_2"
283287
href="https://www.topcoder-dev.com/challenge-details/long id/?type=develop"
288+
target={undefined}
284289
/>
285290
<div
286291
className="src-shared-components-challenge-listing-ChallengeCard-___style__details-footer___3zNR-"
@@ -365,6 +370,7 @@ exports[`Matches shallow shapshot shapshot 3 1`] = `
365370
}
366371
}
367372
detailLink="https://www.topcoder-dev.com/challenge-details/long id/?type=develop"
373+
openChallengesInNewTabs={false}
368374
sampleWinnerProfile={undefined}
369375
/>
370376
</div>

__tests__/shared/components/challenge-listing/Listing/__snapshots__/Bucket.jsx.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ exports[`Matches shallow shapshot 1`] = `
4949
}
5050
}
5151
onTechTagClicked={[Function]}
52+
openChallengesInNewTabs={false}
5253
sampleWinnerProfile={undefined}
5354
/>
5455
<Waypoint
@@ -93,6 +94,7 @@ exports[`Matches shallow shapshot 2`] = `
9394
}
9495
}
9596
onTechTagClicked={[Function]}
97+
openChallengesInNewTabs={false}
9698
sampleWinnerProfile={undefined}
9799
/>
98100
<ChallengeCard
@@ -103,6 +105,7 @@ exports[`Matches shallow shapshot 2`] = `
103105
}
104106
}
105107
onTechTagClicked={[Function]}
108+
openChallengesInNewTabs={false}
106109
sampleWinnerProfile={undefined}
107110
/>
108111
<ChallengeCard
@@ -113,6 +116,7 @@ exports[`Matches shallow shapshot 2`] = `
113116
}
114117
}
115118
onTechTagClicked={[Function]}
119+
openChallengesInNewTabs={false}
116120
sampleWinnerProfile={undefined}
117121
/>
118122
<ChallengeCard
@@ -123,6 +127,7 @@ exports[`Matches shallow shapshot 2`] = `
123127
}
124128
}
125129
onTechTagClicked={[Function]}
130+
openChallengesInNewTabs={false}
126131
sampleWinnerProfile={undefined}
127132
/>
128133
<ChallengeCard
@@ -133,6 +138,7 @@ exports[`Matches shallow shapshot 2`] = `
133138
}
134139
}
135140
onTechTagClicked={[Function]}
141+
openChallengesInNewTabs={false}
136142
sampleWinnerProfile={undefined}
137143
/>
138144
<ChallengeCard
@@ -143,6 +149,7 @@ exports[`Matches shallow shapshot 2`] = `
143149
}
144150
}
145151
onTechTagClicked={[Function]}
152+
openChallengesInNewTabs={false}
146153
sampleWinnerProfile={undefined}
147154
/>
148155
<ChallengeCard
@@ -153,6 +160,7 @@ exports[`Matches shallow shapshot 2`] = `
153160
}
154161
}
155162
onTechTagClicked={[Function]}
163+
openChallengesInNewTabs={false}
156164
sampleWinnerProfile={undefined}
157165
/>
158166
<ChallengeCard
@@ -163,6 +171,7 @@ exports[`Matches shallow shapshot 2`] = `
163171
}
164172
}
165173
onTechTagClicked={[Function]}
174+
openChallengesInNewTabs={false}
166175
sampleWinnerProfile={undefined}
167176
/>
168177
<ChallengeCard
@@ -173,6 +182,7 @@ exports[`Matches shallow shapshot 2`] = `
173182
}
174183
}
175184
onTechTagClicked={[Function]}
185+
openChallengesInNewTabs={false}
176186
sampleWinnerProfile={undefined}
177187
/>
178188
<ChallengeCard
@@ -183,6 +193,7 @@ exports[`Matches shallow shapshot 2`] = `
183193
}
184194
}
185195
onTechTagClicked={[Function]}
196+
openChallengesInNewTabs={false}
186197
sampleWinnerProfile={undefined}
187198
/>
188199
<ChallengeCardPlaceholder

__tests__/shared/components/challenge-listing/Listing/__snapshots__/index.jsx.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports[`Matches shallow shapshot 1`] = `
1111
expanded={false}
1212
loadMore={null}
1313
loading={false}
14+
openChallengesInNewTabs={false}
1415
setFilterState={[Function]}
1516
setSort={[Function]}
1617
sort={null}
@@ -22,6 +23,7 @@ exports[`Matches shallow shapshot 1`] = `
2223
expanded={false}
2324
loadMore={null}
2425
loading={false}
26+
openChallengesInNewTabs={false}
2527
setFilterState={[Function]}
2628
setSort={[Function]}
2729
sort={null}
@@ -33,6 +35,7 @@ exports[`Matches shallow shapshot 1`] = `
3335
expanded={false}
3436
loadMore={null}
3537
loading={false}
38+
openChallengesInNewTabs={false}
3639
setFilterState={[Function]}
3740
setSort={[Function]}
3841
sort={null}
@@ -44,6 +47,7 @@ exports[`Matches shallow shapshot 1`] = `
4447
expanded={false}
4548
loadMore={[Function]}
4649
loading={false}
50+
openChallengesInNewTabs={false}
4751
setFilterState={[Function]}
4852
setSort={[Function]}
4953
sort={null}
@@ -62,6 +66,7 @@ exports[`Matches shallow shapshot 2`] = `
6266
expanded={true}
6367
loadMore={[Function]}
6468
loading={false}
69+
openChallengesInNewTabs={false}
6570
setFilterState={[Function]}
6671
setSort={[Function]}
6772
sort={null}
@@ -80,6 +85,7 @@ exports[`Matches shallow shapshot 3`] = `
8085
expanded={true}
8186
loadMore={[Function]}
8287
loading={false}
88+
openChallengesInNewTabs={false}
8389
setFilterState={[Function]}
8490
setSort={[Function]}
8591
sort={null}
@@ -98,6 +104,7 @@ exports[`Matches shallow shapshot 4`] = `
98104
expanded={false}
99105
loadMore={null}
100106
loading={false}
107+
openChallengesInNewTabs={false}
101108
setFilterState={[Function]}
102109
setSort={[Function]}
103110
sort={null}
@@ -109,6 +116,7 @@ exports[`Matches shallow shapshot 4`] = `
109116
expanded={false}
110117
loadMore={null}
111118
loading={false}
119+
openChallengesInNewTabs={false}
112120
setFilterState={[Function]}
113121
setSort={[Function]}
114122
sort={null}
@@ -120,6 +128,7 @@ exports[`Matches shallow shapshot 4`] = `
120128
expanded={false}
121129
loadMore={[Function]}
122130
loading={false}
131+
openChallengesInNewTabs={false}
123132
setFilterState={[Function]}
124133
setSort={[Function]}
125134
sort={null}
@@ -138,6 +147,7 @@ exports[`Matches shallow shapshot 5`] = `
138147
expanded={true}
139148
loadMore={null}
140149
loading={false}
150+
openChallengesInNewTabs={false}
141151
setFilterState={[Function]}
142152
setSort={[Function]}
143153
sort={null}

__tests__/shared/components/challenge-listing/__snapshots__/index.jsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = `
7878
loadingPastChallenges={false}
7979
onExpandFilterResult={[Function]}
8080
onTechTagClicked={[Function]}
81+
openChallengesInNewTabs={false}
8182
selectBucket={[Function]}
8283
setFilterState={[Function]}
8384
setSort={[Function]}

docs/how-to-add-a-new-topcoder-community.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ To add a new community with the name **demo**, we should follow the following pr
1313
"challengeFilter": {
1414
"groupIds": ["12345"]
1515
},
16+
"challengeListing": {},
1617
"communityId": "demo",
1718
"communitySelector": [{
1819
"label": "Demo Community",
@@ -77,6 +78,8 @@ To add a new community with the name **demo**, we should follow the following pr
7778
"tags": ["JavaScript"]
7879
}
7980
```
81+
- `challengeListing` - *Object* - Optional. When provided, it holds configuration for the challenge listing shown inside the community. This config object may have the following fields:
82+
- `openChallengesInNewTabs` - *Boolean* - Optional. When set, challenge listing opens challenge details pages in new tabs. Defaults to `true`.
8083
- `communityId` - *String* - Unique ID of this community.
8184
- `communitySelector` - *Object Array* - Specifies data for the community selection dropdown inside the community header. Each object MUST HAVE `label` and `value` string fields, and MAY HAVE `redirect` field. If `redirect` field is specified, a click on that option in the dropdown will redirect user to the specified URL.
8285
- `groupId` - *String* - This value of group ID is now used to fetch community statistics. Probably, it makes sense to use this value everywhere where `authorizedGroupIds` array is used, however, at the moment, these two are independent.

src/server/tc-communities/wipro/metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"challengeFilter": {
66
"groupIds": ["20000000"]
77
},
8+
"challengeListing": {
9+
"openChallengesInNewTabs": true
10+
},
811
"communityId": "wipro",
912
"communityName": "TopGear Community",
1013
"communitySelector": [{

src/shared/components/LeaderboardAvatar/index.jsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import './style.scss';
88
const VISIBLE_CHARACTERS = 3;
99
const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_generic.jpg';
1010

11+
/* TODO: Should be functional component! */
1112
class LeaderboardAvatar extends Component {
1213
constructor(props) {
1314
super(props);
@@ -24,11 +25,15 @@ class LeaderboardAvatar extends Component {
2425
}
2526

2627
render() {
27-
const { domain, url } = this.props;
28+
const { domain, openNewTab, url } = this.props;
2829
const { member } = this.state;
2930
const targetURL = url || `//${domain}/members/${member.handle}`;
3031
return (
31-
<a href={targetURL} styleName={`leaderboard-avatar ${member.position || member.isSmr ? 'dark-gray' : 'light-gray'}`}>
32+
<a
33+
href={targetURL}
34+
styleName={`leaderboard-avatar ${member.position || member.isSmr ? 'dark-gray' : 'light-gray'}`}
35+
target={openNewTab ? '_blank' : undefined}
36+
>
3237
{member.photoURL ?
3338
<img
3439
alt="avatar"
@@ -44,16 +49,18 @@ class LeaderboardAvatar extends Component {
4449
}
4550
}
4651

47-
LeaderboardAvatar.propTypes = {
48-
member: PT.shape({}),
49-
domain: PT.string,
50-
url: PT.string,
51-
};
52-
5352
LeaderboardAvatar.defaultProps = {
54-
member: {},
5553
domain: process.env.domain,
54+
member: {},
55+
openNewTab: false,
5656
url: '',
5757
};
5858

59+
LeaderboardAvatar.propTypes = {
60+
domain: PT.string,
61+
member: PT.shape({}),
62+
openNewTab: PT.bool,
63+
url: PT.string,
64+
};
65+
5966
export default LeaderboardAvatar;

0 commit comments

Comments
 (0)