Skip to content

Commit

Permalink
Hide download buttons for challenges a user isn’t involved with
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgasper committed Jun 1, 2023
1 parent af4ba58 commit 3d98a11
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
13 changes: 12 additions & 1 deletion src/components/ChallengeEditor/ChallengeViewTabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const ChallengeViewTabs = ({
onApproveChallenge
}) => {
const [selectedTab, setSelectedTab] = useState(0)
const isLoggedInUserHaveChallengeAccess = useMemo(
() =>
loggedInUser &&
!!_.find(challengeResources, { memberId: `${loggedInUser.userId}` }),
[loggedInUser, challengeResources]
)

const registrants = useMemo(() => {
const { resourceRoles } = metadata
Expand Down Expand Up @@ -258,7 +264,12 @@ const ChallengeViewTabs = ({
<Registrants challenge={challenge} registrants={registrants} />
)}
{selectedTab === 2 && (
<Submissions challenge={challenge} submissions={submissions} token={token} />
<Submissions
challenge={challenge}
submissions={submissions}
token={token}
isLoggedInUserHaveChallengeAccess={isLoggedInUserHaveChallengeAccess}
/>
)}
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ $base-unit: 5px;
margin-right: auto;
display: flex;
justify-content: center;
gap: 40px;

@media (max-width: 1420px) {
@media (max-width: 1488px) {
gap: 40px;
flex-direction: column;
align-items: center;
}
Expand Down Expand Up @@ -197,7 +197,7 @@ $base-unit: 5px;
.empty-left {
flex: 1;

@media (max-width: 1420px) {
@media (max-width: 1488px) {
display: none;
}
}
Expand All @@ -209,8 +209,9 @@ $base-unit: 5px;
gap: 40px;
flex: 1;
padding-right: 20px;
padding-left: 40px;

@media (max-width: 1420px) {
@media (max-width: 1488px) {
justify-content: center;
padding-right: 0;
}
Expand Down Expand Up @@ -384,8 +385,8 @@ $base-unit: 5px;
.submissionsContainer {
display: flex;
flex-direction: column;
max-width: 1300px;
width: 100%;
width: auto;
max-width: 100%;
overflow: auto;
}

Expand Down
10 changes: 6 additions & 4 deletions src/components/ChallengeEditor/Submissions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ class SubmissionsComponent extends React.Component {
}

render () {
const { challenge, token } = this.props
const { challenge, token, isLoggedInUserHaveChallengeAccess } = this.props
const { checkpoints, track, type, tags } = challenge
const haveManagePermission = checkManageRoles(token)
const haveManagePermission = checkManageRoles(token) && isLoggedInUserHaveChallengeAccess

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

SubmissionsComponent.defaultProps = {
submissions: [],
token: ''
token: '',
isLoggedInUserHaveChallengeAccess: false
}

SubmissionsComponent.propTypes = {
Expand All @@ -611,7 +612,8 @@ SubmissionsComponent.propTypes = {
phases: PT.any
}).isRequired,
submissions: PT.arrayOf(PT.shape()),
token: PT.string
token: PT.string,
isLoggedInUserHaveChallengeAccess: PT.bool
}

export default SubmissionsComponent

0 comments on commit 3d98a11

Please sign in to comment.