Skip to content

Commit 009d1ae

Browse files
Merge branch 'server_side_filtering' of https://github.com/nauhil/community-app into server_side_filtering
2 parents 5b50ca9 + 9f5051c commit 009d1ae

File tree

7 files changed

+32
-22
lines changed

7 files changed

+32
-22
lines changed

src/shared/components/Contentful/Menu/index.jsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ import ContentfulLoader from 'containers/ContentfulLoader';
77
import LoadingIndicator from 'components/LoadingIndicator';
88
import PT from 'prop-types';
99
import React from 'react';
10-
import { isomorphy } from 'topcoder-react-utils';
1110
import { url } from 'topcoder-react-lib';
12-
import { removeTrailingSlash } from 'utils/url';
1311
import { isActive, target } from 'utils/contentful';
1412
import NavMenu from './Menu';
1513

14+
const { removeTrailingSlash } = url;
1615
/* eslint-disable global-require */
1716
const THEMES = {
1817
Default: require('./themes/default.scss'),

src/shared/containers/ChallengesBlock.jsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* to a separate component, to expose it to Contentful. Should be further
55
* enhanced for usability in other places.
66
*/
7-
7+
import _ from 'lodash';
88
import { actions, challenge as challengeUtil } from 'topcoder-react-lib';
99
import challengeListingSidebarActions from 'actions/challenge-listing/sidebar';
1010
import ChallengesBlock from 'components/ChallengesBlock';
@@ -15,6 +15,7 @@ import React from 'react';
1515
import shortId from 'shortid';
1616
import { connect } from 'react-redux';
1717

18+
1819
const { BUCKETS } = challengeUtil.buckets;
1920

2021
/* Holds cache time [ms] for the data demanded by this container. */
@@ -76,7 +77,8 @@ ChallengesBlockContiner.propTypes = {
7677

7778
function mapStateToProps(state) {
7879
return {
79-
challenges: state.challengeListing.challenges,
80+
challenges: !_.isEmpty(state.challengeListing.challenges[BUCKETS.ALL])
81+
? state.challengeListing.challenges[BUCKETS.ALL] : [],
8082
lastUpdateOfActiveChallenges:
8183
state.challengeListing.lastUpdateOfActiveChallenges,
8284
loadingActiveChallenges:
@@ -87,7 +89,7 @@ function mapStateToProps(state) {
8789

8890
function mapDispatchToActions(dispatch) {
8991
const cla = actions.challengeListing;
90-
const clsa = challengeListingSidebarActions.challengeListing.sidebar;
92+
const clsa = challengeListingSidebarActions.challengeListingFrontend.sidebar;
9193
return {
9294
getAllActiveChallenges: (tokenV3) => {
9395
const uuid = shortId();

src/shared/containers/Dashboard/index.jsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ export class DashboardPageContainer extends React.Component {
162162
communityStats,
163163
finances,
164164
financesLoading,
165-
handle,
166165
selectChallengeDetailsTab,
167166
setChallengeListingFilter,
168167
showChallengeFilter,
@@ -201,7 +200,7 @@ export class DashboardPageContainer extends React.Component {
201200
achievementsLoading={achievementsLoading}
202201
announcementPreviewId={announcementPreviewId}
203202
challengeFilter={challengeFilter}
204-
challenges={activeChallenges.filter(x => x.users[handle])}
203+
challenges={activeChallenges}
205204
challengesLoading={activeChallengesLoading}
206205
communities={communities}
207206
communitiesLoading={communitiesLoading}
@@ -238,7 +237,6 @@ DashboardPageContainer.defaultProps = {
238237
achievementsTimestamp: 0,
239238
finances: [],
240239
financesTimestamp: 0,
241-
handle: '',
242240
profile: null,
243241
showEarnings:
244242
isomorphy.isClientSide() ? cookies.get('showEarningsInDashboard') !== 'false' : true,
@@ -275,7 +273,6 @@ DashboardPageContainer.propTypes = {
275273
getMemberStats: PT.func.isRequired, // eslint-disable-line react/no-unused-prop-types
276274
getSrms: PT.func.isRequired, // eslint-disable-line react/no-unused-prop-types
277275
getTopcoderBlogFeed: PT.func.isRequired, // eslint-disable-line react/no-unused-prop-types
278-
handle: PT.string,
279276
profile: PT.shape(), // eslint-disable-line react/no-unused-prop-types
280277
selectChallengeDetailsTab: PT.func.isRequired,
281278
setChallengeListingFilter: PT.func.isRequired,
@@ -321,7 +318,8 @@ function mapStateToProps(state, props) {
321318
achievements: achievements.data,
322319
achievementsLoading: Boolean(achievements.loadingUuid),
323320
achievementsTimestamp: achievements.timestamp,
324-
activeChallenges: state.challengeListing.challenges,
321+
activeChallenges: !_.isEmpty(state.challengeListing.challenges[BUCKETS.MY])
322+
? state.challengeListing.challenges[BUCKETS.MY] : [],
325323
activeChallengesLoading:
326324
Boolean(state.challengeListing.loadingActiveChallengesUUID),
327325
activeChallengesTimestamp:

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class CommunityStatsContainer extends React.Component {
5252

5353
if (nextProps.token
5454
&& (nextProps.token !== token
55-
|| nextProps.community !== community
56-
|| nextProps.challenges !== challenges)) {
55+
|| !_.isEqual(nextProps.community, community)
56+
|| !_.isEqual(nextProps.challenges, challenges))) {
5757
getCommunityStats(nextProps.community, nextProps.challenges, nextProps.token);
5858
}
5959

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

+12-6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ class Loader extends React.Component {
8282
if (!meta.authorizedGroupIds) return Community({ member, meta });
8383

8484
/* Visitor is not authenticated. */
85+
const viewportId = _.isEmpty(_.pick(meta, 'accessDeniedPage.viewportId'))
86+
? null : meta.accessDeniedPage.viewportId;
87+
const spaceName = _.isEmpty(_.pick(meta, 'accessDeniedPage.spaceName'))
88+
? null : meta.accessDeniedPage.spaceName;
89+
const environment = _.isEmpty(_.pick(meta, 'accessDeniedPage.environment'))
90+
? null : meta.accessDeniedPage.environment;
8591
if (!visitorGroups) {
8692
/* TODO: In case of TopGear (Wipro) community, if user is not
8793
* authenticated he is automatically redirected to SSO auth URL,
@@ -99,9 +105,9 @@ class Loader extends React.Component {
99105
<AccessDenied
100106
cause={ACCESS_DENIED_REASON.NOT_AUTHENTICATED}
101107
communityId={communityId}
102-
viewportId={meta.accessDeniedPage.viewportId}
103-
spaceName={meta.accessDeniedPage.spaceName}
104-
environment={meta.accessDeniedPage.environment}
108+
viewportId={viewportId}
109+
spaceName={spaceName}
110+
environment={environment}
105111
/>
106112
);
107113
}
@@ -122,9 +128,9 @@ class Loader extends React.Component {
122128
return (
123129
<AccessDenied
124130
cause={ACCESS_DENIED_REASON.NOT_AUTHORIZED}
125-
viewportId={meta.accessDeniedPage.viewportId}
126-
spaceName={meta.accessDeniedPage.spaceName}
127-
environment={meta.accessDeniedPage.environment}
131+
viewportId={viewportId}
132+
spaceName={spaceName}
133+
environment={environment}
128134
/>
129135
);
130136
}

src/shared/containers/tc-communities/cognitive/home.jsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import shortId from 'shortid';
99
import { USER_GROUP_MAXAGE } from 'config';
1010

1111
import { connect } from 'react-redux';
12-
import { challenge as challengeUtils, actions } from 'topcoder-react-lib';
12+
import { challenge as challengeUtil, actions } from 'topcoder-react-lib';
13+
14+
const { BUCKETS } = challengeUtil.buckets;
1315

1416
/* Holds cache time [ms] for the data demanded by this container. */
1517
const MAXAGE = 30 * 60 * 1000;
1618

17-
const Filter = challengeUtils.filter;
19+
const Filter = challengeUtil.filter;
1820

1921
class HomeContainer extends React.Component {
2022
componentDidMount() {
@@ -96,7 +98,8 @@ HomeContainer.propTypes = {
9698
function mapStateToProps(state) {
9799
return {
98100
auth: state.auth,
99-
activeChallenges: state.challengeListing.challenges,
101+
activeChallenges: !_.isEmpty(state.challengeListing.challenges[BUCKETS.ALL])
102+
? state.challengeListing.challenges[BUCKETS.ALL] : [],
100103
activeChallengesTimestamp:
101104
state.challengeListing.lastUpdateOfActiveChallenges,
102105
allFaqItemsClosedInResourcesPage:

src/shared/utils/contentful.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import _ from 'lodash';
22
import { isomorphy } from 'topcoder-react-utils';
3-
import { removeTrailingSlash } from 'utils/url';
3+
import { url as urlUtil } from 'topcoder-react-lib';
4+
5+
const { removeTrailingSlash } = urlUtil;
46

57
/**
68
* Normalizes styles object to ReactJS format (camelCase property names).

0 commit comments

Comments
 (0)