Skip to content

Commit aede246

Browse files
authored
Merge pull request #1330 from topcoder-platform/PM-1944_ai-workflows-in-reviews-appeals
PM-1944 - ai workflows in reviews/appeals tabs
2 parents 78e28be + 853cc58 commit aede246

File tree

18 files changed

+348
-103
lines changed

18 files changed

+348
-103
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
392392
const renderSelectedTab = (): JSX.Element => {
393393
const selectedTabLower = (props.selectedTab || '').toLowerCase()
394394
const selectedTabNormalized = normalizeType(props.selectedTab)
395+
const aiReviewers = (
396+
challengeInfo?.reviewers?.filter(r => !!r.aiWorkflowId) as { aiWorkflowId: string }[]
397+
) ?? []
395398

396399
if (selectedTabLower === 'registration') {
397400
return <TabContentRegistration />
@@ -405,9 +408,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
405408

406409
if (SUBMISSION_TAB_KEYS.has(selectedTabNormalized)) {
407410
return renderSubmissionTab({
408-
aiReviewers: (
409-
challengeInfo?.reviewers?.filter(r => !!r.aiWorkflowId) as { aiWorkflowId: string }[]
410-
) ?? [],
411+
aiReviewers,
411412
allowTopgearSubmissionList,
412413
downloadSubmission: handleSubmissionDownload,
413414
isActiveChallenge: props.isActiveChallenge,
@@ -444,6 +445,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
444445
if (selectedTabLower === 'winners') {
445446
return (
446447
<TabContentWinners
448+
aiReviewers={aiReviewers}
447449
isLoading={isLoadingProjectResult}
448450
projectResults={projectResults}
449451
isDownloading={isDownloadingSubmission}
@@ -498,6 +500,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
498500

499501
return (
500502
<TabContentReview
503+
aiReviewers={aiReviewers}
501504
selectedTab={props.selectedTab}
502505
reviews={reviewTabReviews}
503506
submitterReviews={reviewTabSubmitterReviews}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
import { hasSubmitterPassedThreshold } from '../../utils/reviewScoring'
4545

4646
interface Props {
47+
aiReviewers?: { aiWorkflowId: string }[]
4748
selectedTab: string
4849
reviews: SubmissionInfo[]
4950
submitterReviews: SubmissionInfo[]
@@ -681,6 +682,7 @@ export const TabContentReview: FC<Props> = (props: Props) => {
681682
return (
682683
<TableAppealsResponse
683684
datas={resolvedReviewsWithSubmitter}
685+
aiReviewers={props.aiReviewers}
684686
isDownloading={props.isDownloading}
685687
downloadSubmission={props.downloadSubmission}
686688
mappingReviewAppeal={props.mappingReviewAppeal}
@@ -698,13 +700,15 @@ export const TabContentReview: FC<Props> = (props: Props) => {
698700
return isSubmitterView ? (
699701
<TableAppealsForSubmitter
700702
datas={filteredSubmitterReviews}
703+
aiReviewers={props.aiReviewers}
701704
isDownloading={props.isDownloading}
702705
downloadSubmission={props.downloadSubmission}
703706
mappingReviewAppeal={props.mappingReviewAppeal}
704707
/>
705708
) : (
706709
<TableAppeals
707710
datas={filteredReviews}
711+
aiReviewers={props.aiReviewers}
708712
isDownloading={props.isDownloading}
709713
downloadSubmission={props.downloadSubmission}
710714
mappingReviewAppeal={props.mappingReviewAppeal}
@@ -716,12 +720,14 @@ export const TabContentReview: FC<Props> = (props: Props) => {
716720
return isSubmitterView ? (
717721
<TableReviewForSubmitter
718722
datas={reviewRows}
723+
aiReviewers={props.aiReviewers}
719724
isDownloading={props.isDownloading}
720725
downloadSubmission={props.downloadSubmission}
721726
mappingReviewAppeal={props.mappingReviewAppeal}
722727
/>
723728
) : (
724729
<TableReview
730+
aiReviewers={props.aiReviewers}
725731
datas={reviewRows}
726732
isDownloading={props.isDownloading}
727733
downloadSubmission={props.downloadSubmission}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { TableWinners } from '../TableWinners'
1212

1313
interface Props {
1414
projectResults: ProjectResult[]
15+
aiReviewers?: { aiWorkflowId: string }[]
1516
isLoading: boolean
1617
isDownloading: IsRemovingType
1718
downloadSubmission: (submissionId: string) => void
@@ -30,6 +31,7 @@ export const TabContentWinners: FC<Props> = (props: Props) => {
3031

3132
return (
3233
<TableWinners
34+
aiReviewers={props.aiReviewers}
3335
datas={props.projectResults}
3436
isDownloading={props.isDownloading}
3537
downloadSubmission={props.downloadSubmission}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import { BackendSubmission } from '../../models'
99
import styles from './CollapsibleAiReviewsRow.module.scss'
1010

1111
interface CollapsibleAiReviewsRowProps {
12+
className?: string
1213
defaultOpen?: boolean
1314
aiReviewers: { aiWorkflowId: string }[]
14-
submission: BackendSubmission
15+
submission: Pick<BackendSubmission, 'id'|'virusScan'>
1516
}
1617

1718
const CollapsibleAiReviewsRow: FC<CollapsibleAiReviewsRowProps> = props => {
@@ -24,16 +25,16 @@ const CollapsibleAiReviewsRow: FC<CollapsibleAiReviewsRowProps> = props => {
2425
}, [])
2526

2627
return (
27-
<div className={styles.wrap}>
28-
<span className={styles.reviewersDropown} onClick={toggleOpen}>
28+
<div className={classNames(props.className, styles.wrap)}>
29+
<span className={classNames(styles.reviewersDropown, 'trigger')} onClick={toggleOpen}>
2930
{aiReviewersCount}
3031
{' '}
3132
AI Reviewer
3233
{aiReviewersCount === 1 ? '' : 's'}
3334
<IconOutline.ChevronDownIcon className={classNames('icon-xl', isOpen && styles.rotated)} />
3435
</span>
3536
{isOpen && (
36-
<div className={styles.table}>
37+
<div className={classNames(styles.table, 'reviews-table')}>
3738
<AiReviewsTable
3839
reviewers={props.aiReviewers}
3940
submission={props.submission}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,22 @@
6161
font-size: 14px;
6262
margin-right: $sp-2;
6363
}
64+
65+
.aiReviews {
66+
margin: $sp-2 0;
67+
:global(.trigger) {
68+
width: fit-content;
69+
margin-left: auto;
70+
}
71+
72+
:global(.reviews-table) {
73+
margin-left: auto;
74+
width: 75%;
75+
margin-bottom: -9px;
76+
77+
@include ltelg {
78+
width: auto;
79+
margin-left: -1*$sp-4;
80+
}
81+
}
82+
}

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ import type {
4444
SubmissionRow,
4545
} from '../common/types'
4646
import type { AggregatedSubmissionReviews } from '../../utils/aggregateSubmissionReviews'
47+
import { CollapsibleAiReviewsRow } from '../CollapsibleAiReviewsRow'
4748

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

5051
export interface TableAppealsProps {
5152
className?: string
53+
aiReviewers?: { aiWorkflowId: string }[]
5254
datas: SubmissionInfo[]
5355
isDownloading: IsRemovingType
5456
downloadSubmission: (submissionId: string) => void
@@ -357,6 +359,25 @@ export const TableAppeals: FC<TableAppealsProps> = (props: TableAppealsProps) =>
357359
}
358360
}
359361

362+
if (props.aiReviewers) {
363+
baseColumns.push({
364+
columnId: 'ai-reviews-table',
365+
isExpand: true,
366+
label: '',
367+
renderer: (submission: SubmissionRow, allRows: SubmissionRow[]) => (
368+
props.aiReviewers && (
369+
<CollapsibleAiReviewsRow
370+
className={styles.aiReviews}
371+
aiReviewers={props.aiReviewers}
372+
submission={submission as any}
373+
defaultOpen={allRows ? !allRows.indexOf(submission) : false}
374+
/>
375+
)
376+
),
377+
type: 'element',
378+
})
379+
}
380+
360381
return baseColumns
361382
}, [
362383
allowsAppeals,
@@ -369,7 +390,7 @@ export const TableAppeals: FC<TableAppealsProps> = (props: TableAppealsProps) =>
369390

370391
const columnsMobile = useMemo<MobileTableColumn<SubmissionRow>[][]>(
371392
() => columns.map(column => ([
372-
{
393+
column.label && {
373394
columnId: `${column.columnId}-label`,
374395
label: '',
375396
mobileType: 'label',
@@ -384,11 +405,12 @@ export const TableAppeals: FC<TableAppealsProps> = (props: TableAppealsProps) =>
384405
},
385406
{
386407
...column,
408+
colSpan: column.label ? 1 : 2,
387409
columnId: `${column.columnId}-value`,
388410
label: '',
389411
mobileType: 'last-value',
390412
},
391-
]) as MobileTableColumn<SubmissionRow>[]),
413+
]).filter(Boolean) as MobileTableColumn<SubmissionRow>[]),
392414
[columns],
393415
)
394416

@@ -408,6 +430,8 @@ export const TableAppeals: FC<TableAppealsProps> = (props: TableAppealsProps) =>
408430
<Table
409431
columns={columns}
410432
data={aggregatedRows}
433+
showExpand
434+
expandMode='always'
411435
disableSorting
412436
onToggleSort={_.noop}
413437
removeDefaultSort

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,22 @@
1818
.tableCellNoWrap {
1919
white-space: nowrap;
2020
}
21+
22+
.aiReviews {
23+
margin: $sp-2 0;
24+
:global(.trigger) {
25+
width: fit-content;
26+
margin-left: auto;
27+
}
28+
29+
:global(.reviews-table) {
30+
margin-left: auto;
31+
width: 75%;
32+
margin-bottom: -9px;
33+
34+
@include ltelg {
35+
width: auto;
36+
margin-left: -1*$sp-4;
37+
}
38+
}
39+
}

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ import {
5959
TRACK_CHALLENGE,
6060
WITHOUT_APPEAL,
6161
} from '../../../config/index.config'
62+
import { CollapsibleAiReviewsRow } from '../CollapsibleAiReviewsRow'
6263

6364
import styles from './TableAppealsForSubmitter.module.scss'
6465

6566
export interface TableAppealsForSubmitterProps {
6667
className?: string
68+
aiReviewers?: { aiWorkflowId: string }[]
6769
datas: SubmissionInfo[]
6870
isDownloading: IsRemovingType
6971
downloadSubmission: (submissionId: string) => void
@@ -377,6 +379,25 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop
377379
}
378380
}
379381

382+
if (props.aiReviewers) {
383+
baseColumns.push({
384+
columnId: 'ai-reviews-table',
385+
isExpand: true,
386+
label: '',
387+
renderer: (submission: SubmissionRow, allRows: SubmissionRow[]) => (
388+
props.aiReviewers && (
389+
<CollapsibleAiReviewsRow
390+
className={styles.aiReviews}
391+
aiReviewers={props.aiReviewers}
392+
submission={submission as any}
393+
defaultOpen={allRows ? !allRows.indexOf(submission) : false}
394+
/>
395+
)
396+
),
397+
type: 'element',
398+
})
399+
}
400+
380401
return baseColumns
381402
}, [
382403
allowsAppeals,
@@ -390,7 +411,7 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop
390411
const columnsMobile = useMemo<MobileTableColumn<SubmissionRow>[][]>(
391412
() => columns.map(column => (
392413
[
393-
{
414+
column.label && {
394415
...column,
395416
className: '',
396417
label: `${column.label as string} label`,
@@ -405,9 +426,10 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop
405426
},
406427
{
407428
...column,
429+
colSpan: column.label ? 1 : 2,
408430
mobileType: 'last-value',
409431
},
410-
] as MobileTableColumn<SubmissionRow>[]
432+
].filter(Boolean) as MobileTableColumn<SubmissionRow>[]
411433
)),
412434
[columns],
413435
)
@@ -428,6 +450,8 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop
428450
<Table
429451
columns={columns}
430452
data={submissionRows}
453+
showExpand
454+
expandMode='always'
431455
disableSorting
432456
onToggleSort={noop}
433457
removeDefaultSort

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,22 @@
9090
font-size: 14px;
9191
margin-right: $sp-2;
9292
}
93+
94+
.aiReviews {
95+
margin: $sp-2 0;
96+
:global(.trigger) {
97+
width: fit-content;
98+
margin-left: auto;
99+
}
100+
101+
:global(.reviews-table) {
102+
margin-left: auto;
103+
width: 75%;
104+
margin-bottom: -9px;
105+
106+
@include ltelg {
107+
width: auto;
108+
margin-left: -1*$sp-4;
109+
}
110+
}
111+
}

0 commit comments

Comments
 (0)