Skip to content

Commit 3d98a11

Browse files
committed
Hide download buttons for challenges a user isn’t involved with
#1538 #1539
1 parent af4ba58 commit 3d98a11

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

src/components/ChallengeEditor/ChallengeViewTabs/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ const ChallengeViewTabs = ({
5050
onApproveChallenge
5151
}) => {
5252
const [selectedTab, setSelectedTab] = useState(0)
53+
const isLoggedInUserHaveChallengeAccess = useMemo(
54+
() =>
55+
loggedInUser &&
56+
!!_.find(challengeResources, { memberId: `${loggedInUser.userId}` }),
57+
[loggedInUser, challengeResources]
58+
)
5359

5460
const registrants = useMemo(() => {
5561
const { resourceRoles } = metadata
@@ -258,7 +264,12 @@ const ChallengeViewTabs = ({
258264
<Registrants challenge={challenge} registrants={registrants} />
259265
)}
260266
{selectedTab === 2 && (
261-
<Submissions challenge={challenge} submissions={submissions} token={token} />
267+
<Submissions
268+
challenge={challenge}
269+
submissions={submissions}
270+
token={token}
271+
isLoggedInUserHaveChallengeAccess={isLoggedInUserHaveChallengeAccess}
272+
/>
262273
)}
263274
</div>
264275
)

src/components/ChallengeEditor/Submissions/Submissions.module.scss

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ $base-unit: 5px;
2222
margin-right: auto;
2323
display: flex;
2424
justify-content: center;
25-
gap: 40px;
2625

27-
@media (max-width: 1420px) {
26+
@media (max-width: 1488px) {
27+
gap: 40px;
2828
flex-direction: column;
2929
align-items: center;
3030
}
@@ -197,7 +197,7 @@ $base-unit: 5px;
197197
.empty-left {
198198
flex: 1;
199199

200-
@media (max-width: 1420px) {
200+
@media (max-width: 1488px) {
201201
display: none;
202202
}
203203
}
@@ -209,8 +209,9 @@ $base-unit: 5px;
209209
gap: 40px;
210210
flex: 1;
211211
padding-right: 20px;
212+
padding-left: 40px;
212213

213-
@media (max-width: 1420px) {
214+
@media (max-width: 1488px) {
214215
justify-content: center;
215216
padding-right: 0;
216217
}
@@ -384,8 +385,8 @@ $base-unit: 5px;
384385
.submissionsContainer {
385386
display: flex;
386387
flex-direction: column;
387-
max-width: 1300px;
388-
width: 100%;
388+
width: auto;
389+
max-width: 100%;
389390
overflow: auto;
390391
}
391392

src/components/ChallengeEditor/Submissions/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ class SubmissionsComponent extends React.Component {
212212
}
213213

214214
render () {
215-
const { challenge, token } = this.props
215+
const { challenge, token, isLoggedInUserHaveChallengeAccess } = this.props
216216
const { checkpoints, track, type, tags } = challenge
217-
const haveManagePermission = checkManageRoles(token)
217+
const haveManagePermission = checkManageRoles(token) && isLoggedInUserHaveChallengeAccess
218218

219219
const { field, sort } = this.getSubmissionsSortParam()
220220
const revertSort = sort === 'desc' ? 'asc' : 'desc'
@@ -595,7 +595,8 @@ class SubmissionsComponent extends React.Component {
595595

596596
SubmissionsComponent.defaultProps = {
597597
submissions: [],
598-
token: ''
598+
token: '',
599+
isLoggedInUserHaveChallengeAccess: false
599600
}
600601

601602
SubmissionsComponent.propTypes = {
@@ -611,7 +612,8 @@ SubmissionsComponent.propTypes = {
611612
phases: PT.any
612613
}).isRequired,
613614
submissions: PT.arrayOf(PT.shape()),
614-
token: PT.string
615+
token: PT.string,
616+
isLoggedInUserHaveChallengeAccess: PT.bool
615617
}
616618

617619
export default SubmissionsComponent

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy