Skip to content

Commit a320438

Browse files
committed
Show all past challenges to admins, regardless of registration status (CORE-296)
1 parent b76d878 commit a320438

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

Lines changed: 17 additions & 10 deletions
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,20 @@ 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+
}
98+
9399
// sortedChallenges.sort(Sort[activeSort].func);
94100

95101
// const bucketQuery = qs.stringify({
@@ -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

Lines changed: 1 addition & 0 deletions
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)