Skip to content

Commit 3ef7095

Browse files
Merge branch 'listing-develop-sync' into issue-5056
2 parents d683364 + 52d9250 commit 3ef7095

File tree

13 files changed

+233
-9
lines changed

13 files changed

+233
-9
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = `
2828
expanding={false}
2929
filterState={Object {}}
3030
loadMoreActive={null}
31+
loadMoreAll={null}
3132
loadMoreMy={null}
3233
loadMoreOnGoing={null}
3334
loadMoreOpenForRegistration={null}
@@ -93,6 +94,7 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
9394
expanding={false}
9495
filterState={Object {}}
9596
loadMoreActive={null}
97+
loadMoreAll={null}
9698
loadMoreMy={null}
9799
loadMoreOnGoing={null}
98100
loadMoreOpenForRegistration={null}

src/shared/actions/challenge-listing/index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ function getMyChallengesInit(uuid, page, frontFilter) {
8787
return { uuid, page, frontFilter };
8888
}
8989

90+
function getAllChallengesInit(uuid, page, frontFilter) {
91+
return { uuid, page, frontFilter };
92+
}
93+
9094
/**
9195
* Get all challenges and match with user challenges
9296
* @param {String} uuid progress id
@@ -270,6 +274,31 @@ function getMyChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter = {
270274
}));
271275
}
272276

277+
function getAllChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter = {}) {
278+
const { sorts, status } = frontFilter;
279+
const filter = {
280+
backendFilter,
281+
frontFilter: {
282+
...frontFilter,
283+
perPage: PAGE_SIZE,
284+
page: page + 1,
285+
sortBy: sorts[BUCKETS.ALL],
286+
sortOrder: SORT[sorts[BUCKETS.ALL]].order,
287+
},
288+
};
289+
delete filter.frontFilter.sorts;
290+
if (status === 'All') {
291+
delete filter.frontFilter.status;
292+
}
293+
const service = getService(tokenV3);
294+
return service.getChallenges(filter).then(ch => ({
295+
uuid,
296+
allChallenges: ch.challenges,
297+
meta: ch.meta,
298+
frontFilter,
299+
}));
300+
}
301+
273302
function getTotalChallengesCountInit(uuid) {
274303
return { uuid };
275304
}
@@ -463,6 +492,7 @@ export default createActions({
463492
DROP_ACTIVE_CHALLENGES: _.noop,
464493
DROP_OPEN_FOR_REGISTRATION_CHALLENGES: _.noop,
465494
DROP_MY_CHALLENGES: _.noop,
495+
DROP_ALL_CHALLENGES: _.noop,
466496
DROP_PAST_CHALLENGES: _.noop,
467497

468498
// GET_ALL_ACTIVE_CHALLENGES_INIT: getAllActiveChallengesInit,
@@ -474,6 +504,9 @@ export default createActions({
474504
// GET_ALL_RECOMMENDED_CHALLENGES_INIT: getAllRecommendedChallengesInit,
475505
// GET_ALL_RECOMMENDED_CHALLENGES_DONE: getAllRecommendedChallengesDone,
476506

507+
GET_ALL_CHALLENGES_INIT: getAllChallengesInit,
508+
GET_ALL_CHALLENGES_DONE: getAllChallengesDone,
509+
477510
GET_ACTIVE_CHALLENGES_INIT: getActiveChallengesInit,
478511
GET_ACTIVE_CHALLENGES_DONE: getActiveChallengesDone,
479512

src/shared/components/challenge-listing/Filters/ChallengeFilters.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default function ChallengeFilters({
3030
auth,
3131
// isCardTypeSet,
3232
isReviewOpportunitiesBucket,
33+
activeBucket,
3334
// saveFilter,
3435
searchText,
3536
selectCommunity,
@@ -171,6 +172,7 @@ export default function ChallengeFilters({
171172
isAuth={isAuth}
172173
auth={auth}
173174
isReviewOpportunitiesBucket={isReviewOpportunitiesBucket}
175+
activeBucket={activeBucket}
174176
filterState={filterState}
175177
onClose={() => setExpanded(false)}
176178
// onSaveFilter={saveFilter}
@@ -212,6 +214,7 @@ ChallengeFilters.propTypes = {
212214
communityFilters: PT.arrayOf(PT.shape()).isRequired,
213215
communityName: PT.string,
214216
defaultCommunityId: PT.string.isRequired,
217+
activeBucket: PT.string.isRequired,
215218
// challenges: PT.arrayOf(PT.shape()),
216219
expanded: PT.bool.isRequired,
217220
filterState: PT.shape().isRequired,

src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import Tooltip from 'components/Tooltip';
3232
import { config, Link } from 'topcoder-react-utils';
3333
import { COMPOSE, PRIORITY } from 'react-css-super-themr';
3434
import { REVIEW_OPPORTUNITY_TYPES } from 'utils/tc';
35-
import { isFilterEmpty } from 'utils/challenge-listing/buckets';
35+
import { BUCKETS, isFilterEmpty } from 'utils/challenge-listing/buckets';
3636
import CheckmarkIcon from './CheckmarkIcon';
3737
import DateRangePicker from '../DateRangePicker';
3838
import style from './style.scss';
@@ -49,6 +49,7 @@ export default function FiltersPanel({
4949
isAuth,
5050
auth,
5151
isReviewOpportunitiesBucket,
52+
activeBucket,
5253
onClose,
5354
// onSaveFilter,
5455
selectCommunity,
@@ -66,6 +67,8 @@ export default function FiltersPanel({
6667
_.intersection(visitorGroupIds, communityGroupIds).length,
6768
);
6869

70+
const isAllBucket = activeBucket === BUCKETS.ALL;
71+
6972
const getLabel = (community) => {
7073
const { communityName } = community;
7174
if (!isAuth) {
@@ -339,6 +342,28 @@ export default function FiltersPanel({
339342
</div>
340343
) : null
341344
}
345+
{/* Only shown when the All Challenges bucket is selected */}
346+
{ isAllBucket
347+
? (
348+
<div styleName="filter status">
349+
<label htmlFor="status-select" styleName="left-label">
350+
Status
351+
<input type="hidden" />
352+
</label>
353+
<Select
354+
placeholder="Select Status"
355+
id="status-select"
356+
onChange={(value) => {
357+
const status = value;
358+
setFilterState({ ..._.clone(filterState), status });
359+
}}
360+
options={['Active', 'Completed', 'All'].map(mapOps)}
361+
simpleValue
362+
value={filterState.status || 'Active'}
363+
/>
364+
</div>
365+
) : null
366+
}
342367
<div styleName="filter dates hidetwomonthdatepicker">
343368
<label htmlFor="date-range-picker-one-month">
344369
Date range
@@ -448,6 +473,7 @@ FiltersPanel.propTypes = {
448473
communityName: PT.string.isRequired,
449474
})).isRequired,
450475
defaultCommunityId: PT.string.isRequired,
476+
activeBucket: PT.string.isRequired,
451477
filterState: PT.shape().isRequired,
452478
// challenges: PT.arrayOf(PT.shape()),
453479
hidden: PT.bool,

src/shared/components/challenge-listing/Filters/FiltersPanel/style.scss

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,32 @@ $panel-radius-4: $corner-radius * 2;
382382
}
383383
}
384384
}
385+
386+
&.status {
387+
@include calc(width, '50% - 45px - (12px + 112px) * 2 - 96px');
388+
389+
order: 3; // Show after Date Picker when in lg screen mode
390+
391+
@include xs-to-sm {
392+
margin-top: $panel-space-15;
393+
width: 100%;
394+
}
395+
396+
:global(.Select) {
397+
z-index: 3;
398+
}
399+
400+
margin-right: $panel-space-30;
401+
402+
:global(.Select-value) {
403+
top: inherit;
404+
background: $tc-white !important;
405+
font-weight: 300;
406+
font-size: 13px;
407+
color: $tc-gray-50;
408+
line-height: $panel-space-30 - 2;
409+
}
410+
}
385411
}
386412
}
387413

src/shared/components/challenge-listing/Listing/index.jsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ function Listing({
2323
auth,
2424
allActiveChallengesLoaded,
2525
allMyChallengesLoaded,
26+
allChallengesLoaded,
2627
allOpenForRegistrationChallengesLoaded,
2728
challenges,
2829
openForRegistrationChallenges,
2930
myChallenges,
31+
allChallenges,
3032
// pastChallenges,
3133
challengeTypes,
3234
// userChallenges,
@@ -39,6 +41,8 @@ function Listing({
3941
loadingReviewOpportunities,
4042
loadingMyChallenges,
4143
loadMoreMy,
44+
loadingAllChallenges,
45+
loadMoreAll,
4246
loadingOpenForRegistrationChallenges,
4347
loadMoreOpenForRegistration,
4448
loadingOnGoingChallenges,
@@ -108,6 +112,12 @@ function Listing({
108112
loadMore = allActiveChallengesLoaded ? null : loadMoreOnGoing;
109113
newExpanded = newExpanded || (+meta.ongoingChallengesCount === bucketChallenges.length);
110114
break;
115+
case BUCKETS.ALL:
116+
bucketChallenges = [].concat(allChallenges);
117+
loading = loadingAllChallenges;
118+
loadMore = allChallengesLoaded ? null : loadMoreAll;
119+
newExpanded = newExpanded || (+meta.allChallengesCount === bucketChallenges.length);
120+
break;
111121
default:
112122
break;
113123
}
@@ -199,14 +209,15 @@ function Listing({
199209
|| loadingOpenForRegistrationChallenges
200210
|| loadingOnGoingChallenges;
201211
const placeholders = [];
202-
if (challenges.length > 0) {
212+
if (challenges.length > 0 || (activeBucket === BUCKETS.ALL && allChallenges.length > 0)) {
203213
return (
204214
<div styleName="challengeCardContainer">
205215
{preListingMsg}
206-
{(auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null}
216+
{/* (auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null */}
207217
{/* {extraBucket ? getBucket(extraBucket) : null} */}
208-
{openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
218+
{/* openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION) */}
209219
{/* {getBucket(BUCKETS.ONGOING)} */}
220+
{getBucket(BUCKETS.ALL)}
210221
</div>
211222
);
212223
}
@@ -233,6 +244,7 @@ Listing.defaultProps = {
233244
challenges: [],
234245
openForRegistrationChallenges: [],
235246
myChallenges: [],
247+
allChallenges: [],
236248
// pastChallenges: [],
237249
challengeTypes: [],
238250
communityName: null,
@@ -244,6 +256,7 @@ Listing.defaultProps = {
244256
// loadMorePast: null,
245257
loadMoreReviewOpportunities: null,
246258
loadMoreMy: null,
259+
loadMoreAll: null,
247260
loadMoreOpenForRegistration: null,
248261
loadMoreOnGoing: null,
249262
preListingMsg: null,
@@ -267,10 +280,12 @@ Listing.propTypes = {
267280
}).isRequired,
268281
allActiveChallengesLoaded: PT.bool.isRequired,
269282
allMyChallengesLoaded: PT.bool.isRequired,
283+
allChallengesLoaded: PT.bool.isRequired,
270284
allOpenForRegistrationChallengesLoaded: PT.bool.isRequired,
271285
challenges: PT.arrayOf(PT.shape()),
272286
openForRegistrationChallenges: PT.arrayOf(PT.shape()),
273287
myChallenges: PT.arrayOf(PT.shape()),
288+
allChallenges: PT.arrayOf(PT.shape()),
274289
// pastChallenges: PT.arrayOf(PT.shape()),
275290
challengeTypes: PT.arrayOf(PT.shape()),
276291
challengesUrl: PT.string.isRequired,
@@ -282,10 +297,12 @@ Listing.propTypes = {
282297
keepPastPlaceholders: PT.bool.isRequired,
283298
// loadingPastChallenges: PT.bool.isRequired,
284299
loadingMyChallenges: PT.bool.isRequired,
300+
loadingAllChallenges: PT.bool.isRequired,
285301
loadingOpenForRegistrationChallenges: PT.bool.isRequired,
286302
loadingOnGoingChallenges: PT.bool.isRequired,
287303
loadingReviewOpportunities: PT.bool.isRequired,
288304
loadMoreMy: PT.func,
305+
loadMoreAll: PT.func,
289306
loadMoreOnGoing: PT.func,
290307
loadMoreOpenForRegistration: PT.func,
291308
// loadMorePast: PT.func,
@@ -313,6 +330,7 @@ const mapStateToProps = (state) => {
313330
// allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
314331
allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
315332
allMyChallengesLoaded: cl.allMyChallengesLoaded,
333+
allChallengesLoaded: cl.allChallengesLoaded,
316334
allOpenForRegistrationChallengesLoaded: cl.allOpenForRegistrationChallengesLoaded,
317335
// pastSearchTimestamp: cl.pastSearchTimestamp,
318336
challengeTypes: cl.challengeTypes,

src/shared/components/challenge-listing/Sidebar/BucketSelector/Bucket/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function Bucket({
6868
return (
6969
<div styleName="active bucket">
7070
{BUCKET_DATA[bucket].name}
71-
{countEl}
71+
{bucket !== BUCKETS.ALL && countEl}
7272
{/* {error} */}
7373
</div>
7474
);
@@ -83,7 +83,7 @@ function Bucket({
8383
tabIndex={0}
8484
>
8585
{BUCKET_DATA[bucket].name}
86-
{countEl}
86+
{bucket !== BUCKETS.ALL && countEl}
8787
{/* {error} */}
8888
</div>
8989
);

src/shared/components/challenge-listing/Sidebar/BucketSelector/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export default function BucketSelector({
8383
{isAuth ? getBucket(BUCKETS.MY) : null}
8484
{/* {extraBucket ? getBucket(extraBucket) : null} */}
8585
{getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
86-
{getBucket(BUCKETS.ONGOING)}
86+
{/* DISABLED: Until api receive fix community-app#5073 */}
87+
{/* {getBucket(BUCKETS.ONGOING)} */}
8788
<hr />
8889
{getBucket(BUCKETS.REVIEW_OPPORTUNITIES)}
8990
{/* {getBucket(BUCKETS.PAST)} */}

src/shared/components/challenge-listing/index.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default function ChallengeListing(props) {
3131
challenges,
3232
openForRegistrationChallenges,
3333
myChallenges,
34+
allChallenges,
3435
// pastChallenges,
3536
// communityFilter,
3637
communityName,
@@ -100,6 +101,7 @@ export default function ChallengeListing(props) {
100101
challenges={challenges}
101102
openForRegistrationChallenges={openForRegistrationChallenges}
102103
myChallenges={myChallenges}
104+
allChallenges={allChallenges}
103105
// pastChallenges={pastChallenges}
104106
challengesUrl={props.challengesUrl}
105107
communityName={props.communityName}
@@ -110,10 +112,12 @@ export default function ChallengeListing(props) {
110112
keepPastPlaceholders={keepPastPlaceholders}
111113
// loadingPastChallenges={props.loadingPastChallenges}
112114
loadingMyChallenges={props.loadingMyChallenges}
115+
loadingAllChallenges={props.loadingAllChallenges}
113116
loadingOpenForRegistrationChallenges={props.loadingOpenForRegistrationChallenges}
114117
loadingOnGoingChallenges={props.loadingOnGoingChallenges}
115118
loadingReviewOpportunities={props.loadingReviewOpportunities}
116119
loadMoreMy={props.loadMoreMy}
120+
loadMoreAll={props.loadMoreAll}
117121
loadMoreOpenForRegistration={props.loadMoreOpenForRegistration}
118122
loadMoreOnGoing={props.loadMoreOnGoing}
119123
// loadMorePast={props.loadMorePast}
@@ -180,6 +184,7 @@ ChallengeListing.defaultProps = {
180184
// extraBucket: null,
181185
hideTcLinksInFooter: false,
182186
loadMoreMy: null,
187+
loadMoreAll: null,
183188
loadMoreOpenForRegistration: null,
184189
loadMoreOnGoing: null,
185190
// loadMorePast: null,
@@ -203,6 +208,7 @@ ChallengeListing.propTypes = {
203208
challenges: PT.arrayOf(PT.shape()).isRequired,
204209
openForRegistrationChallenges: PT.arrayOf(PT.shape()).isRequired,
205210
myChallenges: PT.arrayOf(PT.arrayOf()).isRequired,
211+
allChallenges: PT.arrayOf(PT.arrayOf()).isRequired,
206212
// pastChallenges: PT.arrayOf(PT.arrayOf()).isRequired,
207213
challengesUrl: PT.string.isRequired,
208214
// communityFilter: PT.shape(),
@@ -218,11 +224,13 @@ ChallengeListing.propTypes = {
218224
// lastUpdateOfActiveChallenges: PT.number.isRequired,
219225
// loadingChallenges: PT.bool.isRequired,
220226
loadingMyChallenges: PT.bool.isRequired,
227+
loadingAllChallenges: PT.bool.isRequired,
221228
loadingOpenForRegistrationChallenges: PT.bool.isRequired,
222229
loadingOnGoingChallenges: PT.bool.isRequired,
223230
// loadingPastChallenges: PT.bool.isRequired,
224231
loadingReviewOpportunities: PT.bool.isRequired,
225232
loadMoreMy: PT.func,
233+
loadMoreAll: PT.func,
226234
loadMoreOpenForRegistration: PT.func,
227235
loadMoreOnGoing: PT.func,
228236
// loadMorePast: PT.func,

src/shared/containers/challenge-listing/FilterPanel.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export class Container extends React.Component {
123123
}}
124124
// isSavingFilter={isSavingFilter}
125125
isReviewOpportunitiesBucket={isForReviewOpportunities}
126+
activeBucket={activeBucket}
126127
/>
127128
);
128129
}

0 commit comments

Comments
 (0)