Skip to content

Commit 32af683

Browse files
authored
Merge pull request #1350 from topcoder-platform/update-ai-reviewers-tables
update rendering for ai reviewers
2 parents f2ab320 + b2619eb commit 32af683

File tree

3 files changed

+73
-86
lines changed

3 files changed

+73
-86
lines changed

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

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -165,37 +165,31 @@ export const TableCheckpointSubmissions: FC<Props> = (props: Props) => {
165165
)
166166

167167
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-
}
168+
() => ({
169+
columnId: 'ai-reviews-table',
170+
isExpand: true,
171+
label: '',
172+
renderer: (data: Screening, allRows: Screening[]) => {
173+
const submissionPayload = {
174+
id: data.submissionId ?? '',
175+
virusScan: data.virusScan,
176+
} as Pick<BackendSubmission, 'id'|'virusScan'>
177+
178+
if (!submissionPayload.id) {
179+
return <></>
180+
}
186181

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-
},
182+
return (
183+
<CollapsibleAiReviewsRow
184+
className={styles.aiReviews}
185+
aiReviewers={props.aiReviewers ?? []}
186+
submission={submissionPayload}
187+
defaultOpen={allRows ? !allRows.indexOf(data) : false}
188+
/>
189+
)
190+
},
191+
type: 'element',
192+
} as TableColumn<Screening>),
199193
[props.aiReviewers],
200194
)
201195

@@ -733,7 +727,7 @@ export const TableCheckpointSubmissions: FC<Props> = (props: Props) => {
733727
const columnsMobile = useMemo<MobileTableColumn<Screening>[][]>(
734728
() => columns.map(
735729
column => [
736-
{
730+
column.label && {
737731
...column,
738732
className: '',
739733
label: `${column.label as string} label`,
@@ -748,9 +742,10 @@ export const TableCheckpointSubmissions: FC<Props> = (props: Props) => {
748742
},
749743
{
750744
...column,
745+
colSpan: column.label ? 1 : 2,
751746
mobileType: 'last-value',
752747
},
753-
] as MobileTableColumn<Screening>[],
748+
].filter(Boolean) as MobileTableColumn<Screening>[],
754749
),
755750
[columns],
756751
)

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

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,24 +1337,20 @@ export const TableIterativeReview: FC<Props> = (props: Props) => {
13371337
baseColumns.push(reviewerColumn)
13381338
}
13391339

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-
}
1340+
baseColumns.push({
1341+
columnId: 'ai-reviews-table',
1342+
isExpand: true,
1343+
label: '',
1344+
renderer: (submission: SubmissionInfo, allRows: SubmissionInfo[]) => (
1345+
<CollapsibleAiReviewsRow
1346+
className={styles.aiReviews}
1347+
aiReviewers={props.aiReviewers ?? []}
1348+
submission={submission as any}
1349+
defaultOpen={allRows ? !allRows.indexOf(submission) : false}
1350+
/>
1351+
),
1352+
type: 'element',
1353+
})
13581354

13591355
return baseColumns
13601356
}, [
@@ -1375,7 +1371,7 @@ export const TableIterativeReview: FC<Props> = (props: Props) => {
13751371

13761372
const columnsMobile = useMemo<MobileTableColumn<SubmissionInfo>[][]>(() => (
13771373
(actionColumn ? [...columns, actionColumn] : columns).map(column => ([
1378-
{
1374+
column.label && {
13791375
...column,
13801376
className: '',
13811377
label: `${column.label as string} label`,
@@ -1390,9 +1386,10 @@ export const TableIterativeReview: FC<Props> = (props: Props) => {
13901386
},
13911387
{
13921388
...column,
1389+
colSpan: column.label ? 1 : 2,
13931390
mobileType: 'last-value',
13941391
},
1395-
] as MobileTableColumn<SubmissionInfo>[]))
1392+
].filter(Boolean) as MobileTableColumn<SubmissionInfo>[]))
13961393
), [actionColumn, columns])
13971394

13981395
return (

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

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -789,40 +789,34 @@ export const TableSubmissionScreening: FC<Props> = (props: Props) => {
789789
}, [filteredChallengeSubmissions, props.screenings])
790790

791791
const aiReviewersColumn = useMemo<TableColumn<Screening> | undefined>(
792-
() => {
793-
if (!props.aiReviewers?.length) {
794-
return undefined
795-
}
796-
797-
return {
798-
columnId: 'ai-reviews-table',
799-
isExpand: true,
800-
label: '',
801-
renderer: (
802-
data: Screening,
803-
allRows: Screening[],
804-
) => {
805-
const submissionPayload = submissionMetaById.get(data.submissionId) ?? {
806-
id: data.submissionId ?? '',
807-
virusScan: data.virusScan,
808-
}
792+
() => ({
793+
columnId: 'ai-reviews-table',
794+
isExpand: true,
795+
label: '',
796+
renderer: (
797+
data: Screening,
798+
allRows: Screening[],
799+
) => {
800+
const submissionPayload = submissionMetaById.get(data.submissionId) ?? {
801+
id: data.submissionId ?? '',
802+
virusScan: data.virusScan,
803+
}
809804

810-
if (!submissionPayload?.id) {
811-
return <></>
812-
}
805+
if (!submissionPayload?.id) {
806+
return <></>
807+
}
813808

814-
return (
815-
<CollapsibleAiReviewsRow
816-
className={styles.aiReviews}
817-
aiReviewers={props.aiReviewers!}
818-
submission={submissionPayload as Pick<BackendSubmission, 'id'|'virusScan'>}
819-
defaultOpen={allRows ? !allRows.indexOf(data) : false}
820-
/>
821-
)
822-
},
823-
type: 'element',
824-
} as TableColumn<Screening>
825-
},
809+
return (
810+
<CollapsibleAiReviewsRow
811+
className={styles.aiReviews}
812+
aiReviewers={props.aiReviewers!}
813+
submission={submissionPayload as Pick<BackendSubmission, 'id'|'virusScan'>}
814+
defaultOpen={allRows ? !allRows.indexOf(data) : false}
815+
/>
816+
)
817+
},
818+
type: 'element',
819+
} as TableColumn<Screening>),
826820
[props.aiReviewers, submissionMetaById],
827821
)
828822

@@ -1191,7 +1185,7 @@ export const TableSubmissionScreening: FC<Props> = (props: Props) => {
11911185
const columnsMobile = useMemo<MobileTableColumn<Screening>[][]>(
11921186
() => columns.map(
11931187
column => [
1194-
{
1188+
column.label && {
11951189
...column,
11961190
className: '',
11971191
label: `${column.label as string} label`,
@@ -1206,9 +1200,10 @@ export const TableSubmissionScreening: FC<Props> = (props: Props) => {
12061200
},
12071201
{
12081202
...column,
1203+
colSpan: column.label ? 1 : 2,
12091204
mobileType: 'last-value',
12101205
},
1211-
] as MobileTableColumn<Screening>[],
1206+
].filter(Boolean) as MobileTableColumn<Screening>[],
12121207
),
12131208
[columns],
12141209
)

0 commit comments

Comments
 (0)