Skip to content

Commit f2ab320

Browse files
authored
Merge pull request #1348 from topcoder-platform/ai-reviewers-tables
Add ai reviewers on all tables
2 parents 8b265f2 + 9b81004 commit f2ab320

File tree

10 files changed

+203
-14
lines changed

10 files changed

+203
-14
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ const renderSubmissionTab = ({
178178
downloadSubmission={downloadSubmission}
179179
isActiveChallenge={isActiveChallenge}
180180
showScreeningColumns={!isSubmissionTab && !isTopgearSubmissionTab}
181+
aiReviewers={aiReviewers}
181182
/>
182183
)
183184
}
@@ -438,6 +439,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
438439
isDownloading={isDownloadingSubmission}
439440
downloadSubmission={handleSubmissionDownload}
440441
mode={checkpointMode}
442+
aiReviewers={aiReviewers}
441443
/>
442444
)
443445
}
@@ -479,6 +481,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
479481
downloadSubmission={handleSubmissionDownload}
480482
isActiveChallenge={props.isActiveChallenge}
481483
columnLabel='Post-Mortem'
484+
aiReviewers={aiReviewers}
482485
/>
483486
)
484487
}
@@ -494,6 +497,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
494497
downloadSubmission={handleSubmissionDownload}
495498
isActiveChallenge={props.isActiveChallenge}
496499
phaseIdFilter={props.selectedPhaseId}
500+
aiReviewers={aiReviewers}
497501
/>
498502
)
499503
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface Props {
2424
downloadSubmission: (submissionId: string) => void
2525
challengeStatus?: string
2626
mode?: 'submission' | 'screening' | 'review'
27+
aiReviewers?: { aiWorkflowId: string }[]
2728
}
2829

2930
export const TabContentCheckpoint: FC<Props> = (props: Props) => {
@@ -148,6 +149,7 @@ export const TabContentCheckpoint: FC<Props> = (props: Props) => {
148149
isDownloading={props.isDownloading}
149150
downloadSubmission={props.downloadSubmission}
150151
mode={mode}
152+
aiReviewers={props.aiReviewers}
151153
/>
152154
)
153155
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ interface Props {
2828
isActiveChallenge: boolean
2929
columnLabel?: string
3030
phaseIdFilter?: string
31+
aiReviewers?: { aiWorkflowId: string }[]
3132
}
3233

3334
const getSubmissionPriority = (submission: SubmissionInfo): number => {
@@ -203,6 +204,7 @@ export const TabContentIterativeReview: FC<Props> = (props: Props) => {
203204
hideSubmissionColumn={shouldHideSubmissionColumn}
204205
isChallengeCompleted={isChallengeCompleted}
205206
hasPassedThreshold={hasPassedPostMortemThreshold}
207+
aiReviewers={props.aiReviewers}
206208
/>
207209
)
208210
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface Props {
2323
isActiveChallenge: boolean
2424
showScreeningColumns?: boolean
2525
challengeStatus?: string
26+
aiReviewers?: { aiWorkflowId: string }[]
2627
}
2728

2829
export const TabContentScreening: FC<Props> = (props: Props) => {
@@ -136,6 +137,7 @@ export const TabContentScreening: FC<Props> = (props: Props) => {
136137
downloadSubmission={props.downloadSubmission}
137138
hideHandleColumn={hideHandleColumn}
138139
showScreeningColumns={showScreeningColumns}
140+
aiReviewers={props.aiReviewers}
139141
/>
140142
)
141143
}

src/apps/review/src/lib/components/TableCheckpointSubmissions/TableCheckpointSubmissions.module.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,23 @@
184184
color: var(--GrayFontColor);
185185
font-size: 14px;
186186
}
187+
188+
.aiReviews {
189+
margin: $sp-2 0;
190+
191+
:global(.trigger) {
192+
width: fit-content;
193+
margin-left: auto;
194+
}
195+
196+
:global(.reviews-table) {
197+
margin-left: auto;
198+
width: 75%;
199+
margin-bottom: -9px;
200+
201+
@include ltelg {
202+
width: auto;
203+
margin-left: -1*$sp-4;
204+
}
205+
}
206+
}

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

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { UserRole } from '~/libs/core'
1616
import { handleError } from '~/apps/admin/src/lib/utils'
1717

1818
import {
19+
BackendSubmission,
1920
ChallengeDetailContextModel,
2021
ReviewAppContextModel,
2122
Screening,
@@ -33,6 +34,7 @@ import { updateReview } from '../../services'
3334
import { ConfirmModal } from '../ConfirmModal'
3435
import { useSubmissionDownloadAccess } from '../../hooks'
3536
import type { UseSubmissionDownloadAccessResult } from '../../hooks/useSubmissionDownloadAccess'
37+
import { CollapsibleAiReviewsRow } from '../CollapsibleAiReviewsRow'
3638

3739
import styles from './TableCheckpointSubmissions.module.scss'
3840

@@ -42,6 +44,7 @@ interface Props {
4244
isDownloading: IsRemovingType
4345
downloadSubmission: (submissionId: string) => void
4446
mode?: 'submission' | 'screening' | 'review'
47+
aiReviewers?: { aiWorkflowId: string }[]
4548
}
4649

4750
const isInProgressStatus = (value: string | undefined): boolean => (
@@ -161,6 +164,45 @@ export const TableCheckpointSubmissions: FC<Props> = (props: Props) => {
161164
[datas],
162165
)
163166

167+
const aiReviewsColumn = useMemo<TableColumn<Screening> | undefined>(
168+
() => {
169+
if (!props.aiReviewers?.length) {
170+
return undefined
171+
}
172+
173+
return {
174+
columnId: 'ai-reviews-table',
175+
isExpand: true,
176+
label: '',
177+
renderer: (data: Screening, allRows: Screening[]) => {
178+
const submissionPayload = {
179+
id: data.submissionId ?? '',
180+
virusScan: data.virusScan,
181+
} as Pick<BackendSubmission, 'id'|'virusScan'>
182+
183+
if (!submissionPayload.id) {
184+
return <></>
185+
}
186+
187+
return (
188+
<CollapsibleAiReviewsRow
189+
className={styles.aiReviews}
190+
aiReviewers={props.aiReviewers!}
191+
submission={submissionPayload}
192+
defaultOpen={allRows ? !allRows.indexOf(data) : false}
193+
/>
194+
)
195+
},
196+
type: 'element',
197+
} as TableColumn<Screening>
198+
},
199+
[props.aiReviewers],
200+
)
201+
202+
const appendAiColumn = (columns: TableColumn<Screening>[]): TableColumn<Screening>[] => (
203+
aiReviewsColumn ? [...columns, aiReviewsColumn] : columns
204+
)
205+
164206
const columns = useMemo<TableColumn<Screening>[]>(
165207
() => {
166208
const tableMode = mode
@@ -312,7 +354,7 @@ export const TableCheckpointSubmissions: FC<Props> = (props: Props) => {
312354
}
313355

314356
if (tableMode === 'submission') {
315-
return baseColumns
357+
return appendAiColumn(baseColumns)
316358
}
317359

318360
if (tableMode === 'screening') {
@@ -410,7 +452,7 @@ export const TableCheckpointSubmissions: FC<Props> = (props: Props) => {
410452
const hasAnyMyAssignment = rows.some(row => Boolean(row.myReviewResourceId))
411453
const canShowReopenActions = rows.some(row => computeReopenEligibility(row).canReopen)
412454
if (!hasAnyMyAssignment && !canShowReopenActions) {
413-
return screeningColumns
455+
return appendAiColumn(screeningColumns)
414456
}
415457

416458
const actionColumn: TableColumn<Screening> = {
@@ -502,10 +544,10 @@ export const TableCheckpointSubmissions: FC<Props> = (props: Props) => {
502544
type: 'element',
503545
}
504546

505-
return [
547+
return appendAiColumn([
506548
...screeningColumns,
507549
actionColumn,
508-
]
550+
])
509551
}
510552

511553
// mode === 'review'
@@ -574,7 +616,7 @@ export const TableCheckpointSubmissions: FC<Props> = (props: Props) => {
574616
const hasAnyMyAssignment = rows.some(row => Boolean(row.myReviewResourceId))
575617
const canShowReopenActions = rows.some(row => computeReopenEligibility(row).canReopen)
576618
if (!hasAnyMyAssignment && !canShowReopenActions) {
577-
return reviewColumns
619+
return appendAiColumn(reviewColumns)
578620
}
579621

580622
const actionColumn: TableColumn<Screening> = {
@@ -666,10 +708,10 @@ export const TableCheckpointSubmissions: FC<Props> = (props: Props) => {
666708
type: 'element',
667709
}
668710

669-
return [
711+
return appendAiColumn([
670712
...reviewColumns,
671713
actionColumn,
672-
]
714+
])
673715
},
674716
[
675717
challengeInfo,
@@ -730,6 +772,8 @@ export const TableCheckpointSubmissions: FC<Props> = (props: Props) => {
730772
<Table
731773
columns={columns}
732774
data={visibleRows}
775+
showExpand
776+
expandMode='always'
733777
disableSorting
734778
onToggleSort={_.noop}
735779
removeDefaultSort

src/apps/review/src/lib/components/TableIterativeReview/TableIterativeReview.module.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,23 @@
240240
.reviewerList > span {
241241
display: inline-flex;
242242
}
243+
244+
.aiReviews {
245+
margin: $sp-2 0;
246+
247+
:global(.trigger) {
248+
width: fit-content;
249+
margin-left: auto;
250+
}
251+
252+
:global(.reviews-table) {
253+
margin-left: auto;
254+
width: 75%;
255+
margin-bottom: -9px;
256+
257+
@include ltelg {
258+
width: auto;
259+
margin-left: -1*$sp-4;
260+
}
261+
}
262+
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import type { SubmissionRow } from '../common/types'
4444
import { resolveSubmissionReviewResult } from '../common/reviewResult'
4545
import { ProgressBar } from '../ProgressBar'
4646
import { TableWrapper } from '../TableWrapper'
47+
import { CollapsibleAiReviewsRow } from '../CollapsibleAiReviewsRow'
4748

4849
import styles from './TableIterativeReview.module.scss'
4950

@@ -57,6 +58,7 @@ interface Props {
5758
hideSubmissionColumn?: boolean
5859
isChallengeCompleted?: boolean
5960
hasPassedThreshold?: boolean
61+
aiReviewers?: { aiWorkflowId: string }[]
6062
}
6163

6264
interface ScoreMetadata {
@@ -1335,6 +1337,25 @@ export const TableIterativeReview: FC<Props> = (props: Props) => {
13351337
baseColumns.push(reviewerColumn)
13361338
}
13371339

1340+
if (props.aiReviewers) {
1341+
baseColumns.push({
1342+
columnId: 'ai-reviews-table',
1343+
isExpand: true,
1344+
label: '',
1345+
renderer: (submission: SubmissionInfo, allRows: SubmissionInfo[]) => (
1346+
props.aiReviewers && (
1347+
<CollapsibleAiReviewsRow
1348+
className={styles.aiReviews}
1349+
aiReviewers={props.aiReviewers}
1350+
submission={submission as any}
1351+
defaultOpen={allRows ? !allRows.indexOf(submission) : false}
1352+
/>
1353+
)
1354+
),
1355+
type: 'element',
1356+
})
1357+
}
1358+
13381359
return baseColumns
13391360
}, [
13401361
approverColumn,
@@ -1349,6 +1370,7 @@ export const TableIterativeReview: FC<Props> = (props: Props) => {
13491370
reviewDateColumn,
13501371
reviewerColumn,
13511372
submissionColumn,
1373+
props.aiReviewers,
13521374
])
13531375

13541376
const columnsMobile = useMemo<MobileTableColumn<SubmissionInfo>[][]>(() => (
@@ -1387,6 +1409,8 @@ export const TableIterativeReview: FC<Props> = (props: Props) => {
13871409
<Table
13881410
columns={actionColumn ? [...columns, actionColumn] : columns}
13891411
data={datas}
1412+
showExpand
1413+
expandMode='always'
13901414
disableSorting
13911415
onToggleSort={_.noop}
13921416
removeDefaultSort

src/apps/review/src/lib/components/TableSubmissionScreening/TableSubmissionScreening.module.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,23 @@
194194
height: 18px;
195195
}
196196
}
197+
198+
.aiReviews {
199+
margin: $sp-2 0;
200+
201+
:global(.trigger) {
202+
width: fit-content;
203+
margin-left: auto;
204+
}
205+
206+
:global(.reviews-table) {
207+
margin-left: auto;
208+
width: 75%;
209+
margin-bottom: -9px;
210+
211+
@include ltelg {
212+
width: auto;
213+
margin-left: -1*$sp-4;
214+
}
215+
}
216+
}

0 commit comments

Comments
 (0)