Skip to content

Commit ace95d1

Browse files
authored
Merge pull request #6986 from topcoder-platform/develop
Show all past challenges to admins, regardless of registration or participation
2 parents bf6d6c6 + 383d30d commit ace95d1

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

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

+17-10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export default function Bucket({
4949
setSort,
5050
sort,
5151
userId,
52+
auth,
5253
expandedTags,
5354
expandTag,
5455
activeBucket,
@@ -65,6 +66,8 @@ export default function Bucket({
6566
};
6667
const activeSort = sort || 'startDate';
6768

69+
const roles = _.get(auth, 'user.roles');
70+
6871
// const sortedChallenges = activeBucket === 'all' ?
6972
// _.clone(challenges.slice(0, 10)) : _.clone(challenges);
7073
let sortedChallenges;
@@ -79,17 +82,19 @@ export default function Bucket({
7982
}
8083

8184
let filteredChallenges = sortedChallenges;
82-
filteredChallenges = sortedChallenges.filter((ch) => {
83-
if (ch.type === 'Task'
84-
&& ch.task
85-
&& ch.task.isTask
86-
&& ch.task.isAssigned
87-
&& Number(ch.task.memberId) !== Number(userId)) {
88-
return null;
89-
}
90-
return ch;
91-
});
9285

86+
if (!_.includes(roles, 'administrator')) {
87+
filteredChallenges = sortedChallenges.filter((ch) => {
88+
if (ch.type === 'Task'
89+
&& ch.task
90+
&& ch.task.isTask
91+
&& ch.task.isAssigned
92+
&& Number(ch.task.memberId) !== Number(userId)) {
93+
return null;
94+
}
95+
return ch;
96+
});
97+
}
9398
// sortedChallenges.sort(Sort[activeSort].func);
9499

95100
// const bucketQuery = qs.stringify({
@@ -276,6 +281,7 @@ Bucket.defaultProps = {
276281
openChallengesInNewTabs: false,
277282
sort: null,
278283
userId: '',
284+
auth: {},
279285
expandedTags: [],
280286
expandTag: null,
281287
activeBucket: '',
@@ -306,6 +312,7 @@ Bucket.propTypes = {
306312
setSort: PT.func.isRequired,
307313
sort: PT.string,
308314
userId: PT.number,
315+
auth: PT.shape(),
309316
expandedTags: PT.arrayOf(PT.number),
310317
expandTag: PT.func,
311318
activeBucket: PT.string,

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

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ function Listing({
197197
setSort={sort => setSort(bucket, sort)}
198198
sort={sorts[bucket]}
199199
userId={_.get(auth, 'user.userId')}
200+
auth={auth}
200201
activeBucket={activeBucket}
201202
// searchTimestamp={searchTimestamp}
202203
isLoggedIn={isLoggedIn}

0 commit comments

Comments
 (0)