Skip to content

Commit 9f80f06

Browse files
committed
QA fixes
1 parent 9955d88 commit 9f80f06

File tree

18 files changed

+1249
-350
lines changed

18 files changed

+1249
-350
lines changed

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

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,19 @@ interface Props {
5151
selectedTab: string
5252
isLoadingSubmission: boolean
5353
screening: Screening[]
54+
screeningMinimumPassingScore: number | null | undefined
5455
submissions: BackendSubmission[]
5556
checkpoint: Screening[]
57+
checkpointScreeningMinimumPassingScore: number | null | undefined
5658
checkpointReview: Screening[]
59+
checkpointReviewMinimumPassingScore: number | null | undefined
5760
review: SubmissionInfo[]
61+
reviewMinimumPassingScore: number | null | undefined
5862
submitterReviews: SubmissionInfo[]
5963
approvalReviews: SubmissionInfo[]
64+
approvalMinimumPassingScore: number | null | undefined
6065
postMortemReviews: SubmissionInfo[]
66+
postMortemMinimumPassingScore: number | null | undefined
6167
mappingReviewAppeal: MappingReviewAppeal // from review id to appeal info
6268
isActiveChallenge: boolean
6369
selectedPhaseId?: string
@@ -80,11 +86,13 @@ const SUBMISSION_TAB_KEYS = new Set([
8086
normalizeType('topgear submission'),
8187
])
8288

89+
const CHECKPOINT_REVIEW_KEY = normalizeType('checkpoint review')
90+
const CHECKPOINT_SCREENING_KEY = normalizeType('checkpoint screening')
8391
const CHECKPOINT_TAB_KEYS = new Set([
8492
normalizeType('checkpoint'),
8593
normalizeType('checkpoint submission'),
86-
normalizeType('checkpoint screening'),
87-
normalizeType('checkpoint review'),
94+
CHECKPOINT_SCREENING_KEY,
95+
CHECKPOINT_REVIEW_KEY,
8896
])
8997

9098
interface BuildScreeningRowsParams {
@@ -98,19 +106,22 @@ const buildScreeningRows = ({
98106
actionChallengeRole,
99107
currentMemberId,
100108
}: BuildScreeningRowsParams): Screening[] => {
101-
const filteredScreening = actionChallengeRole === SUBMITTER && currentMemberId
102-
? screening.filter(entry => entry.memberId === currentMemberId)
103-
: screening
109+
if (actionChallengeRole === SUBMITTER && currentMemberId) {
110+
const mySubmissions = screening.filter(entry => entry.memberId === currentMemberId)
104111

105-
return hasIsLatestFlag(filteredScreening)
106-
? filteredScreening.filter(submission => submission.isLatest === true)
107-
: filteredScreening
112+
return hasIsLatestFlag(mySubmissions)
113+
? mySubmissions.filter(submission => submission.isLatest === true)
114+
: mySubmissions
115+
}
116+
117+
return screening
108118
}
109119

110120
interface SubmissionTabParams {
111121
selectedTabNormalized: string
112122
submissions: BackendSubmission[]
113123
screeningRows: Screening[]
124+
screeningMinimumPassingScore: number | null | undefined
114125
isLoadingSubmission: boolean
115126
isDownloadingSubmission: useDownloadSubmissionProps['isLoading']
116127
downloadSubmission: useDownloadSubmissionProps['downloadSubmission']
@@ -121,6 +132,7 @@ const renderSubmissionTab = ({
121132
selectedTabNormalized,
122133
submissions,
123134
screeningRows,
135+
screeningMinimumPassingScore,
124136
isLoadingSubmission,
125137
isDownloadingSubmission,
126138
downloadSubmission,
@@ -154,6 +166,7 @@ const renderSubmissionTab = ({
154166
return (
155167
<TabContentScreening
156168
screening={screeningRows}
169+
screeningMinimumPassingScore={screeningMinimumPassingScore}
157170
isLoadingScreening={isLoadingSubmission}
158171
isDownloading={isDownloadingSubmission}
159172
downloadSubmission={downloadSubmission}
@@ -326,21 +339,30 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
326339
isActiveChallenge: props.isActiveChallenge,
327340
isDownloadingSubmission,
328341
isLoadingSubmission: props.isLoadingSubmission,
342+
screeningMinimumPassingScore: props.screeningMinimumPassingScore,
329343
screeningRows,
330344
selectedTabNormalized,
331345
submissions: props.submissions,
332346
})
333347
}
334348

335349
if (CHECKPOINT_TAB_KEYS.has(selectedTabNormalized)) {
350+
const checkpointMode: 'submission' | 'screening' | 'review' = selectedTabNormalized
351+
.startsWith(CHECKPOINT_REVIEW_KEY)
352+
? 'review'
353+
: selectedTabNormalized.startsWith(CHECKPOINT_SCREENING_KEY)
354+
? 'screening'
355+
: 'submission'
336356
return (
337357
<TabContentCheckpoint
338358
checkpoint={props.checkpoint}
339359
checkpointReview={props.checkpointReview}
360+
checkpointScreeningMinimumPassingScore={props.checkpointScreeningMinimumPassingScore}
361+
checkpointReviewMinimumPassingScore={props.checkpointReviewMinimumPassingScore}
340362
isLoading={props.isLoadingSubmission}
341363
isDownloading={isDownloadingSubmission}
342364
downloadSubmission={downloadSubmission}
343-
selectedTab={props.selectedTab}
365+
mode={checkpointMode}
344366
/>
345367
)
346368
}
@@ -361,6 +383,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
361383
<TabContentApproval
362384
reviews={props.approvalReviews}
363385
submitterReviews={props.submitterReviews}
386+
approvalMinimumPassingScore={props.approvalMinimumPassingScore}
364387
isLoadingReview={props.isLoadingSubmission}
365388
isDownloading={isDownloadingSubmission}
366389
downloadSubmission={downloadSubmission}
@@ -374,6 +397,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
374397
<TabContentIterativeReview
375398
reviews={postMortemReviewRows}
376399
submitterReviews={postMortemSubmitterReviews}
400+
postMortemMinimumPassingScore={props.postMortemMinimumPassingScore}
377401
isLoadingReview={props.isLoadingSubmission}
378402
isDownloading={isDownloadingSubmission}
379403
downloadSubmission={downloadSubmission}
@@ -388,6 +412,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
388412
<TabContentIterativeReview
389413
reviews={props.review}
390414
submitterReviews={props.submitterReviews}
415+
postMortemMinimumPassingScore={props.postMortemMinimumPassingScore}
391416
isLoadingReview={props.isLoadingSubmission}
392417
isDownloading={isDownloadingSubmission}
393418
downloadSubmission={downloadSubmission}
@@ -402,6 +427,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
402427
selectedTab={props.selectedTab}
403428
reviews={reviewTabReviews}
404429
submitterReviews={reviewTabSubmitterReviews}
430+
reviewMinimumPassingScore={props.reviewMinimumPassingScore}
405431
isLoadingReview={props.isLoadingSubmission}
406432
isDownloading={isDownloadingSubmission}
407433
downloadSubmission={downloadSubmission}

src/apps/review/src/lib/components/ChallengeDetailsContent/TabContentApproval.tsx

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,60 @@ import {
1515
SUBMITTER,
1616
} from '../../../config/index.config'
1717
import { ChallengeDetailContext } from '../../contexts'
18+
import { hasSubmitterPassedThreshold } from '../../utils/reviewScoring'
1819

1920
interface Props {
2021
reviews: SubmissionInfo[]
2122
submitterReviews: SubmissionInfo[]
23+
approvalMinimumPassingScore?: number | null
2224
isLoadingReview: boolean
2325
isDownloading: IsRemovingType
2426
downloadSubmission: (submissionId: string) => void
2527
isActiveChallenge: boolean
2628
}
2729

2830
export const TabContentApproval: FC<Props> = (props: Props) => {
29-
const { actionChallengeRole }: useRoleProps = useRole()
31+
const {
32+
challengeInfo,
33+
myResources = [],
34+
}: ChallengeDetailContextModel = useContext(ChallengeDetailContext)
35+
const {
36+
actionChallengeRole,
37+
approverResourceIds,
38+
isPrivilegedRole,
39+
}: useRoleProps = useRole()
3040
const hideHandleColumn = props.isActiveChallenge
3141
&& actionChallengeRole === REVIEWER
3242

33-
const isSubmitterView = actionChallengeRole === SUBMITTER
34-
const rawRows = isSubmitterView ? props.submitterReviews : props.reviews
43+
const myMemberIds = useMemo<Set<string>>(
44+
() => new Set((myResources ?? []).map(resource => resource.memberId)),
45+
[myResources],
46+
)
47+
48+
const isSubmitterOnly = actionChallengeRole === SUBMITTER
49+
&& approverResourceIds.size === 0
50+
const rawRows = isSubmitterOnly ? props.submitterReviews : props.reviews
51+
52+
const hasPassedApprovalThreshold = useMemo(
53+
() => hasSubmitterPassedThreshold(
54+
rawRows ?? [],
55+
myMemberIds,
56+
props.approvalMinimumPassingScore,
57+
),
58+
[rawRows, myMemberIds, props.approvalMinimumPassingScore],
59+
)
60+
61+
const isChallengeCompleted = useMemo(
62+
() => {
63+
const normalizedStatus = (challengeInfo?.status ?? '').toUpperCase()
64+
return normalizedStatus === 'COMPLETED'
65+
|| normalizedStatus === 'CANCELLED'
66+
|| normalizedStatus.startsWith('CANCELLED_')
67+
},
68+
[challengeInfo?.status],
69+
)
3570

3671
// Only show Approval-phase reviews on the Approval tab
37-
const { challengeInfo }: ChallengeDetailContextModel = useContext(ChallengeDetailContext)
3872
const approvalPhaseIds = useMemo<Set<string>>(
3973
() => new Set(
4074
(challengeInfo?.phases ?? [])
@@ -61,17 +95,46 @@ export const TabContentApproval: FC<Props> = (props: Props) => {
6195
[rawRows, approvalPhaseIds],
6296
)
6397

98+
const filteredApprovalRows = useMemo<SubmissionInfo[]>(
99+
() => {
100+
if (isPrivilegedRole || (isChallengeCompleted && hasPassedApprovalThreshold)) {
101+
return approvalRows
102+
}
103+
104+
return approvalRows.filter(row => {
105+
if (row.review?.resourceId
106+
&& approverResourceIds.has(row.review.resourceId)) {
107+
return true
108+
}
109+
110+
if (row.memberId && myMemberIds.has(row.memberId)) {
111+
return true
112+
}
113+
114+
return false
115+
})
116+
},
117+
[
118+
approvalRows,
119+
isPrivilegedRole,
120+
isChallengeCompleted,
121+
hasPassedApprovalThreshold,
122+
approverResourceIds,
123+
myMemberIds,
124+
],
125+
)
126+
64127
if (props.isLoadingReview) {
65128
return <TableLoading />
66129
}
67130

68-
if (!approvalRows.length) {
131+
if (!filteredApprovalRows.length) {
69132
return <TableNoRecord message='No approvals yet' />
70133
}
71134

72135
return (
73136
<TableIterativeReview
74-
datas={approvalRows}
137+
datas={filteredApprovalRows}
75138
isDownloading={props.isDownloading}
76139
downloadSubmission={props.downloadSubmission}
77140
hideHandleColumn={hideHandleColumn}

0 commit comments

Comments
 (0)