From a320438eabaa9d2bbb4f3fda695e2fcb45f08c00 Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Sat, 1 Jun 2024 01:05:13 +0000 Subject: [PATCH 1/2] Show all past challenges to admins, regardless of registration status (CORE-296) --- .../Listing/Bucket/index.jsx | 27 ++++++++++++------- .../challenge-listing/Listing/index.jsx | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/shared/components/challenge-listing/Listing/Bucket/index.jsx b/src/shared/components/challenge-listing/Listing/Bucket/index.jsx index 5c1fd07350..7d0fb95b5c 100644 --- a/src/shared/components/challenge-listing/Listing/Bucket/index.jsx +++ b/src/shared/components/challenge-listing/Listing/Bucket/index.jsx @@ -49,6 +49,7 @@ export default function Bucket({ setSort, sort, userId, + auth, expandedTags, expandTag, activeBucket, @@ -65,6 +66,8 @@ export default function Bucket({ }; const activeSort = sort || 'startDate'; + const roles = _.get(auth, 'user.roles'); + // const sortedChallenges = activeBucket === 'all' ? // _.clone(challenges.slice(0, 10)) : _.clone(challenges); let sortedChallenges; @@ -79,17 +82,20 @@ export default function Bucket({ } let filteredChallenges = sortedChallenges; - filteredChallenges = sortedChallenges.filter((ch) => { - if (ch.type === 'Task' - && ch.task - && ch.task.isTask - && ch.task.isAssigned - && Number(ch.task.memberId) !== Number(userId)) { - return null; - } - return ch; - }); + if(!_.includes(roles, 'administrator')){ + filteredChallenges = sortedChallenges.filter((ch) => { + if (ch.type === 'Task' + && ch.task + && ch.task.isTask + && ch.task.isAssigned + && Number(ch.task.memberId) !== Number(userId)) { + return null; + } + return ch; + }); + } + // sortedChallenges.sort(Sort[activeSort].func); // const bucketQuery = qs.stringify({ @@ -306,6 +312,7 @@ Bucket.propTypes = { setSort: PT.func.isRequired, sort: PT.string, userId: PT.number, + auth: PT.shape(), expandedTags: PT.arrayOf(PT.number), expandTag: PT.func, activeBucket: PT.string, diff --git a/src/shared/components/challenge-listing/Listing/index.jsx b/src/shared/components/challenge-listing/Listing/index.jsx index 6392d2db5a..badc681731 100644 --- a/src/shared/components/challenge-listing/Listing/index.jsx +++ b/src/shared/components/challenge-listing/Listing/index.jsx @@ -197,6 +197,7 @@ function Listing({ setSort={sort => setSort(bucket, sort)} sort={sorts[bucket]} userId={_.get(auth, 'user.userId')} + auth={auth} activeBucket={activeBucket} // searchTimestamp={searchTimestamp} isLoggedIn={isLoggedIn} From 383d30d3351b780a019a53349de90abcf35bb697 Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Sat, 1 Jun 2024 01:12:14 +0000 Subject: [PATCH 2/2] Lint --- .../components/challenge-listing/Listing/Bucket/index.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/components/challenge-listing/Listing/Bucket/index.jsx b/src/shared/components/challenge-listing/Listing/Bucket/index.jsx index 7d0fb95b5c..22a21d39bc 100644 --- a/src/shared/components/challenge-listing/Listing/Bucket/index.jsx +++ b/src/shared/components/challenge-listing/Listing/Bucket/index.jsx @@ -83,7 +83,7 @@ export default function Bucket({ let filteredChallenges = sortedChallenges; - if(!_.includes(roles, 'administrator')){ + if (!_.includes(roles, 'administrator')) { filteredChallenges = sortedChallenges.filter((ch) => { if (ch.type === 'Task' && ch.task @@ -95,7 +95,6 @@ export default function Bucket({ return ch; }); } - // sortedChallenges.sort(Sort[activeSort].func); // const bucketQuery = qs.stringify({ @@ -282,6 +281,7 @@ Bucket.defaultProps = { openChallengesInNewTabs: false, sort: null, userId: '', + auth: {}, expandedTags: [], expandTag: null, activeBucket: '',