From 3d98a117cbd023cb29290a8bbb1f8ab179ac704a Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Thu, 1 Jun 2023 16:08:16 +1000 Subject: [PATCH] =?UTF-8?q?Hide=20download=20buttons=20for=20challenges=20?= =?UTF-8?q?a=20user=20isn=E2=80=99t=20involved=20with?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/topcoder-platform/work-manager/issues/1538 https://github.com/topcoder-platform/work-manager/issues/1539 --- .../ChallengeEditor/ChallengeViewTabs/index.js | 13 ++++++++++++- .../Submissions/Submissions.module.scss | 13 +++++++------ src/components/ChallengeEditor/Submissions/index.js | 10 ++++++---- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/components/ChallengeEditor/ChallengeViewTabs/index.js b/src/components/ChallengeEditor/ChallengeViewTabs/index.js index 7b9a738a..231a279c 100644 --- a/src/components/ChallengeEditor/ChallengeViewTabs/index.js +++ b/src/components/ChallengeEditor/ChallengeViewTabs/index.js @@ -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 @@ -258,7 +264,12 @@ const ChallengeViewTabs = ({ )} {selectedTab === 2 && ( - + )} ) diff --git a/src/components/ChallengeEditor/Submissions/Submissions.module.scss b/src/components/ChallengeEditor/Submissions/Submissions.module.scss index b3689bf9..4c9f91f3 100644 --- a/src/components/ChallengeEditor/Submissions/Submissions.module.scss +++ b/src/components/ChallengeEditor/Submissions/Submissions.module.scss @@ -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; } @@ -197,7 +197,7 @@ $base-unit: 5px; .empty-left { flex: 1; - @media (max-width: 1420px) { + @media (max-width: 1488px) { display: none; } } @@ -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; } @@ -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; } diff --git a/src/components/ChallengeEditor/Submissions/index.js b/src/components/ChallengeEditor/Submissions/index.js index 44f5f318..c6f126a3 100644 --- a/src/components/ChallengeEditor/Submissions/index.js +++ b/src/components/ChallengeEditor/Submissions/index.js @@ -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' @@ -595,7 +595,8 @@ class SubmissionsComponent extends React.Component { SubmissionsComponent.defaultProps = { submissions: [], - token: '' + token: '', + isLoggedInUserHaveChallengeAccess: false } SubmissionsComponent.propTypes = { @@ -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