Skip to content

Commit baa7ac4

Browse files
committed
Updates for submitter privileges
1 parent 8e96cb8 commit baa7ac4

File tree

3 files changed

+107
-31
lines changed

3 files changed

+107
-31
lines changed

src/apps/review/src/lib/components/TableIterativeReview/TableIterativeReview.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ const hasActiveReview = (review: ReviewInfo | undefined): boolean => (
115115
Boolean(review?.id)
116116
)
117117

118-
const DOWNLOAD_OWN_SUBMISSION_TOOLTIP = 'You can only download your own submissions.'
118+
const DOWNLOAD_OWN_SUBMISSION_TOOLTIP
119+
= 'You can download only your own submissions until the challenge completes or fails review.'
119120
const VIEW_OWN_SCORECARD_TOOLTIP = 'You can only view scorecards for your own submissions.'
120121

121122
interface CompletedReviewRenderParams {
@@ -239,6 +240,7 @@ export const TableIterativeReview: FC<Props> = (props: Props) => {
239240
restrictionMessage,
240241
isSubmissionDownloadRestrictedForMember,
241242
getRestrictionMessageForMember,
243+
shouldRestrictSubmitterToOwnSubmission,
242244
}: UseSubmissionDownloadAccessResult = useSubmissionDownloadAccess()
243245
const { width: screenWidth }: WindowSize = useWindowSize()
244246
const isTablet = useMemo(() => screenWidth <= 744, [screenWidth])
@@ -305,7 +307,9 @@ export const TableIterativeReview: FC<Props> = (props: Props) => {
305307
const isOwnedSubmission = data.memberId
306308
? ownedMemberIds.has(data.memberId)
307309
: false
308-
const isOwnershipRestricted = isSubmitterView && !isOwnedSubmission
310+
const isOwnershipRestricted = shouldRestrictSubmitterToOwnSubmission
311+
&& isSubmitterView
312+
&& !isOwnedSubmission
309313
const isRestrictedForMember = isSubmissionDownloadRestrictedForMember(
310314
data.memberId,
311315
)
@@ -414,6 +418,7 @@ export const TableIterativeReview: FC<Props> = (props: Props) => {
414418
isDownloading,
415419
restrictionMessage,
416420
isSubmitterView,
421+
shouldRestrictSubmitterToOwnSubmission,
417422
ownedMemberIds,
418423
],
419424
)

src/apps/review/src/lib/components/TableReviewAppealsForSubmitter/TableReviewAppealsForSubmitter.tsx

Lines changed: 95 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ type SubmissionRow = SubmissionInfo & {
6060
aggregated?: AggregatedSubmissionReviews
6161
}
6262

63-
const DOWNLOAD_OWN_SUBMISSION_TOOLTIP = 'You can only download your own submissions.'
63+
const DOWNLOAD_OWN_SUBMISSION_TOOLTIP
64+
= 'You can download only your own submissions until the challenge completes or fails review.'
6465
const VIEW_OWN_SCORECARD_TOOLTIP = 'You can only view scorecards for your own submissions.'
6566

6667
export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
@@ -77,6 +78,7 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
7778
isSubmissionDownloadRestricted,
7879
isSubmissionDownloadRestrictedForMember,
7980
restrictionMessage,
81+
shouldRestrictSubmitterToOwnSubmission,
8082
}: UseSubmissionDownloadAccessResult = useSubmissionDownloadAccess()
8183
const challengeType = challengeInfo?.type
8284
const challengeTrack = challengeInfo?.track
@@ -361,20 +363,26 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
361363
const isOwnedSubmission = data.memberId
362364
? ownedMemberIds.has(data.memberId)
363365
: false
364-
const isOwnershipRestricted = !isOwnedSubmission
366+
const isOwnershipRestricted = shouldRestrictSubmitterToOwnSubmission
367+
&& !isOwnedSubmission
368+
const isRestrictedForMember = isSubmissionDownloadRestrictedForMember(
369+
data.memberId,
370+
)
371+
const memberRestrictionMessage = getRestrictionMessageForMember(
372+
data.memberId,
373+
)
365374
const failedScan = data.virusScan === false
366375
const isButtonDisabled = Boolean(
367376
isDownloading[data.id]
368-
|| isSubmissionDownloadRestricted
369-
|| failedScan
370-
|| isOwnershipRestricted,
377+
|| isRestrictedForMember
378+
|| failedScan,
371379
)
372380

373381
const downloadButton = (
374382
<button
375383
onClick={function onClick() {
376384
if (
377-
isSubmissionDownloadRestricted
385+
isRestrictedForMember
378386
|| failedScan
379387
|| isOwnershipRestricted
380388
) {
@@ -410,6 +418,10 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
410418
let tooltipContent: string | undefined
411419
if (failedScan) {
412420
tooltipContent = 'Submission failed virus scan'
421+
} else if (isRestrictedForMember) {
422+
tooltipContent = memberRestrictionMessage
423+
?? restrictionMessage
424+
?? DOWNLOAD_OWN_SUBMISSION_TOOLTIP
413425
} else if (isOwnershipRestricted) {
414426
tooltipContent = DOWNLOAD_OWN_SUBMISSION_TOOLTIP
415427
} else if (isSubmissionDownloadRestricted && restrictionMessage) {
@@ -532,30 +544,33 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
532544
const reviewDetail = data.aggregated?.reviews?.[0]
533545
const reviewId = reviewDetail?.reviewInfo?.id || reviewDetail?.reviewId
534546
if (reviewId) {
535-
const scoreElement = isOwnedSubmission ? (
536-
<Link
537-
to={`./../review/${reviewId}`}
538-
className={styles.textBlue}
539-
>
540-
{scoreDisplay}
541-
</Link>
542-
) : (
547+
const canViewScorecard = isChallengeCompleted || isOwnedSubmission
548+
const scoreContent = (
543549
<span className={styles.textBlue}>
544550
{scoreDisplay}
545551
</span>
546552
)
547553

548-
return !isOwnedSubmission ? (
549-
<Tooltip
550-
content={VIEW_OWN_SCORECARD_TOOLTIP}
551-
triggerOn='click-hover'
554+
if (!canViewScorecard) {
555+
return (
556+
<Tooltip
557+
content={VIEW_OWN_SCORECARD_TOOLTIP}
558+
triggerOn='click-hover'
559+
>
560+
<span className={styles.tooltipTrigger}>
561+
{scoreContent}
562+
</span>
563+
</Tooltip>
564+
)
565+
}
566+
567+
return (
568+
<Link
569+
to={`./../review/${reviewId}`}
570+
className={styles.textBlue}
552571
>
553-
<span className={styles.tooltipTrigger}>
554-
{scoreElement}
555-
</span>
556-
</Tooltip>
557-
) : (
558-
scoreElement
572+
{scoreDisplay}
573+
</Link>
559574
)
560575
}
561576
}
@@ -635,6 +650,29 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
635650
const formattedScore = typeof finalScore === 'number' && Number.isFinite(finalScore)
636651
? finalScore.toFixed(2)
637652
: undefined
653+
const isOwnedSubmission = data.memberId
654+
? ownedMemberIds.has(data.memberId)
655+
: false
656+
const canViewScorecard = isChallengeCompleted || isOwnedSubmission
657+
const scoreContent = (
658+
<span className={styles.textBlue}>
659+
{formattedScore ?? '--'}
660+
</span>
661+
)
662+
663+
if (!canViewScorecard) {
664+
return (
665+
<Tooltip
666+
content={VIEW_OWN_SCORECARD_TOOLTIP}
667+
triggerOn='click-hover'
668+
>
669+
<span className={styles.tooltipTrigger}>
670+
{scoreContent}
671+
</span>
672+
</Tooltip>
673+
)
674+
}
675+
638676
return (
639677
<Link
640678
to={`./../review/${reviewId}`}
@@ -673,6 +711,35 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
673711
)
674712
}
675713

714+
const isOwnedSubmission = data.memberId
715+
? ownedMemberIds.has(data.memberId)
716+
: false
717+
const canViewScorecard = isChallengeCompleted || isOwnedSubmission
718+
const appealsContent = (
719+
<span className={styles.textBlue}>
720+
{totalAppeals}
721+
</span>
722+
)
723+
724+
if (!canViewScorecard) {
725+
return (
726+
<Tooltip
727+
content={VIEW_OWN_SCORECARD_TOOLTIP}
728+
triggerOn='click-hover'
729+
>
730+
<span
731+
className={classNames(
732+
styles.tooltipTrigger,
733+
styles.appealsLink,
734+
'last-element',
735+
)}
736+
>
737+
{appealsContent}
738+
</span>
739+
</Tooltip>
740+
)
741+
}
742+
676743
return (
677744
<Link
678745
className={classNames(
@@ -681,7 +748,7 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
681748
)}
682749
to={`./../review/${reviewId}`}
683750
>
684-
<span className={styles.textBlue}>{totalAppeals}</span>
751+
{appealsContent}
685752
</Link>
686753
)
687754
}
@@ -794,8 +861,10 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
794861
canDisplayScores,
795862
shouldShowHistoryActions,
796863
downloadSubmission,
864+
getRestrictionMessageForMember,
797865
historyByMember,
798866
isSubmissionDownloadRestricted,
867+
isSubmissionDownloadRestrictedForMember,
799868
isDownloading,
800869
isChallengeCompleted,
801870
maxReviewCount,
@@ -808,6 +877,7 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
808877
isSubmissionTab,
809878
isAppealsTab,
810879
ownedMemberIds,
880+
shouldRestrictSubmitterToOwnSubmission,
811881
])
812882

813883
const columnsMobile = useMemo<MobileTableColumn<SubmissionRow>[][]>(

src/apps/review/src/lib/hooks/useSubmissionDownloadAccess.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ChallengeDetailContext, ReviewAppContext } from '../contexts'
1111
export const SUBMISSION_DOWNLOAD_RESTRICTION_MESSAGE
1212
= 'Submissions are available once the submission phase closes.'
1313
export const SUBMISSION_DOWNLOAD_SUBMITTER_RESTRICTION_MESSAGE
14-
= 'You can download only your own submissions until the challenge completes.'
14+
= 'You can download only your own submissions until the challenge completes or fails review.'
1515

1616
export interface UseSubmissionDownloadAccessResult {
1717
isSubmissionPhaseOpen: boolean
@@ -42,7 +42,8 @@ export function useSubmissionDownloadAccess(): UseSubmissionDownloadAccessResult
4242
)
4343

4444
const challengeStatus = challengeInfo?.status?.toLowerCase()
45-
const isChallengeCompleted = challengeStatus === 'completed'
45+
const isChallengeClosedForDownload = ['completed', 'cancelled_failed_review']
46+
.includes(challengeStatus ?? '')
4647

4748
const isSubmissionPhaseOpen = useMemo(
4849
() => challengeInfo?.phases?.some(
@@ -96,13 +97,13 @@ export function useSubmissionDownloadAccess(): UseSubmissionDownloadAccessResult
9697
const shouldRestrictSubmitterToOwnSubmission = useMemo(
9798
() => hasSubmitterRole
9899
&& !(hasCopilotRole || isAdmin)
99-
&& !isChallengeCompleted
100+
&& !isChallengeClosedForDownload
100101
&& !hasIterativeReviewerRole,
101102
[
102103
hasSubmitterRole,
103104
hasCopilotRole,
104105
isAdmin,
105-
isChallengeCompleted,
106+
isChallengeClosedForDownload,
106107
hasIterativeReviewerRole,
107108
],
108109
)

0 commit comments

Comments
 (0)