Skip to content

Commit 66c3116

Browse files
committed
Hides Blockchain community's Challenge Listing from non-registered visitors
the ticket
1 parent 57dc78b commit 66c3116

File tree

8 files changed

+75
-15
lines changed

8 files changed

+75
-15
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* The message to show instead of the challenge listing to visitors, who are
3+
* not members of community, when they come to the challenge listing.
4+
*/
5+
6+
import JoinCommunity from 'containers/tc-communities/JoinCommunity';
7+
import React from 'react';
8+
import Section from 'components/tc-communities/Section';
9+
import style from './style.scss';
10+
11+
export default function RegisterToSee() {
12+
return (
13+
<Section
14+
theme={{
15+
content: style.message,
16+
}}
17+
>
18+
<div>
19+
Join now to participate in exclusive blockchain challenges!
20+
<JoinCommunity />
21+
</div>
22+
</Section>
23+
);
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import "~styles/mixins";
2+
3+
.message {
4+
color: #394146 !important;
5+
font: 15px/160% 'Open Sans' !important;
6+
justify-content: center !important;
7+
margin-top: 19px !important;
8+
opacity: 0.7 !important;
9+
}

src/shared/containers/tc-communities/Loader.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ class Loader extends React.Component {
6565
return <LoadingPagePlaceholder />;
6666
}
6767

68+
const visitorGroupIds = visitorGroups.map(g => g.id);
69+
const member = meta.groupId && visitorGroupIds.includes(meta.groupId);
70+
6871
/* Community does not require authorization. */
69-
if (!meta.authorizedGroupIds) return Community({ meta });
72+
if (!meta.authorizedGroupIds) return Community({ member, meta });
7073

7174
/* Visitor is not authenticated. */
7275
if (!visitorGroups) {
@@ -81,9 +84,8 @@ class Loader extends React.Component {
8184

8285
/* Visitor belongs to at least one of the groups authorized to access this
8386
* community. */
84-
const visitorGroupIds = visitorGroups.map(g => g.id);
8587
if (_.intersection(visitorGroupIds, meta.authorizedGroupIds).length) {
86-
return Community({ meta });
88+
return Community({ member, meta });
8789
}
8890

8991
/* Visitor is not authorized to access this community. */

src/shared/routes/Communities/Blockchain/Routes.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
* Routing of Wipro Community.
33
*/
44

5+
/* TODO: This assembly of custom challenge listing page should be split out into
6+
* a separate component. But, it is good enough for now. */
57
import ChallengeListingTopBanner from
68
'components/tc-communities/communities/blockchain/ChallengeListing/TopBanner';
9+
import ChallengeListingRegisterToSee from
10+
'components/tc-communities/communities/blockchain/ChallengeListing/RegisterToSee';
11+
712
import Error404 from 'components/Error404';
813
import Footer from 'containers/tc-communities/Footer';
914
import Header from 'containers/tc-communities/Header';
@@ -16,7 +21,7 @@ import { Route, Switch } from 'react-router-dom';
1621
import ChallengeListing from '../ChallengeListing';
1722
import Leaderboard from '../Leaderboard';
1823

19-
export default function Routes({ base, meta }) {
24+
export default function Routes({ base, member, meta }) {
2025
return (
2126
<Route
2227
component={({ match }) => (
@@ -27,7 +32,9 @@ export default function Routes({ base, meta }) {
2732
component={() => (
2833
<div>
2934
<ChallengeListingTopBanner />
30-
<ChallengeListing listingOnly meta={meta} />
35+
{ member ? (
36+
<ChallengeListing listingOnly meta={meta} />
37+
) : <ChallengeListingRegisterToSee /> }
3138
</div>
3239
)}
3340
exact
@@ -69,5 +76,6 @@ Routes.defaultProps = {
6976

7077
Routes.propTypes = {
7178
base: PT.string,
79+
member: PT.bool.isRequired,
7280
meta: PT.shape().isRequired,
7381
};

src/shared/routes/Communities/Blockchain/index.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React from 'react';
99
import { StaticRouter } from 'react-router-dom';
1010
import { requireWeak, resolveWeak, SplitRoute } from 'utils/router';
1111

12-
export default function ChunkLoader({ base, meta }) {
12+
export default function ChunkLoader({ base, member, meta }) {
1313
return (
1414
<SplitRoute
1515
cacheCss
@@ -18,7 +18,9 @@ export default function ChunkLoader({ base, meta }) {
1818
import(
1919
/* webpackChunkName: "blockchain-community" */
2020
'./Routes',
21-
).then(({ default: Routes }) => <Routes base={base} meta={meta} />)
21+
).then(({ default: Routes }) => (
22+
<Routes base={base} member={member} meta={meta} />
23+
))
2224
}
2325
renderPlaceholder={() => <LoadingIndicator />}
2426
renderServer={(routeProps) => {
@@ -28,7 +30,7 @@ export default function ChunkLoader({ base, meta }) {
2830
<StaticRouter
2931
context={routeProps.staticContext}
3032
location={routeProps.location.pathname}
31-
><Routes base={base} meta={meta} /></StaticRouter>
33+
><Routes base={base} member={member} meta={meta} /></StaticRouter>
3234
);
3335
}}
3436
/>
@@ -37,5 +39,6 @@ export default function ChunkLoader({ base, meta }) {
3739

3840
ChunkLoader.propTypes = {
3941
base: PT.string.isRequired,
42+
member: PT.bool.isRequired,
4043
meta: PT.shape().isRequired,
4144
};

src/shared/routes/Communities/Routes.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import TcProdDev from './TcProdDev';
1515
import Veterans from './Veterans';
1616
import Wipro from './Wipro';
1717

18-
export default function Communities({ base, communityId, meta }) {
18+
export default function Communities({ base, communityId, member, meta }) {
1919
switch (communityId) {
20-
case 'blockchain': return <Blockchain base={base} meta={meta} />;
20+
case 'blockchain':
21+
return <Blockchain base={base} member={member} meta={meta} />;
2122
case 'community-2': return <Community2 base={base} meta={meta} />;
2223
case 'demo-expert': return <DemoExpert base={base} meta={meta} />;
2324
case 'qa': return <QA base={base} meta={meta} />;
@@ -37,5 +38,6 @@ Communities.defaultProps = {
3738
Communities.propTypes = {
3839
base: PT.string,
3940
communityId: PT.string.isRequired,
41+
member: PT.bool.isRequired,
4042
meta: PT.shape().isRequired,
4143
};

src/shared/routes/Communities/index.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React from 'react';
99
import { StaticRouter } from 'react-router-dom';
1010
import { requireWeak, resolveWeak, SplitRoute } from 'utils/router';
1111

12-
export default function ChunkLoader({ base, communityId, meta }) {
12+
export default function ChunkLoader({ base, communityId, member, meta }) {
1313
return (
1414
<SplitRoute
1515
chunkName="communities"
@@ -18,7 +18,12 @@ export default function ChunkLoader({ base, communityId, meta }) {
1818
/* webpackChunkName: "communities" */
1919
'./Routes',
2020
).then(({ default: Routes }) => (
21-
<Routes base={base} communityId={communityId} meta={meta} />
21+
<Routes
22+
base={base}
23+
communityId={communityId}
24+
member={member}
25+
meta={meta}
26+
/>
2227
))
2328
}
2429
renderPlaceholder={() => <LoadingIndicator />}
@@ -33,6 +38,7 @@ export default function ChunkLoader({ base, communityId, meta }) {
3338
<Routes
3439
base={base}
3540
communityId={communityId}
41+
member={member}
3642
meta={meta}
3743
/>
3844
</StaticRouter>
@@ -45,5 +51,6 @@ export default function ChunkLoader({ base, communityId, meta }) {
4551
ChunkLoader.propTypes = {
4652
base: PT.string.isRequired,
4753
communityId: PT.string.isRequired,
54+
member: PT.bool.isRequired,
4855
meta: PT.shape().isRequired,
4956
};

src/shared/routes/index.jsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ function Routes({ subdomains }) {
3131
if (communityId) {
3232
return (
3333
<CommunityLoader
34-
communityComponent={({ meta }) => (
35-
<Communities communityId={communityId} meta={meta} />
34+
communityComponent={({ member, meta }) => (
35+
<Communities
36+
communityId={communityId}
37+
member={member}
38+
meta={meta}
39+
/>
3640
)}
3741
communityId={communityId}
3842
/>
@@ -45,13 +49,14 @@ function Routes({ subdomains }) {
4549
<Route
4650
render={({ match }) => (
4751
<CommunityLoader
48-
communityComponent={({ meta }) => {
52+
communityComponent={({ member, meta }) => {
4953
let base = match.url;
5054
while (base.endsWith('/')) base = base.slice(0, -1);
5155
return (
5256
<Communities
5357
base={base}
5458
communityId={match.params.communityId}
59+
member={member}
5560
meta={meta}
5661
/>
5762
);

0 commit comments

Comments
 (0)