Skip to content

Commit b4f607e

Browse files
committed
PM-1905 - mobile view
1 parent c624467 commit b4f607e

File tree

7 files changed

+138
-1
lines changed

7 files changed

+138
-1
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,30 @@
6161
}
6262
}
6363
}
64+
65+
.mobileCard {
66+
border-top: 1px solid #A8A8A8;
67+
margin-top: $sp-2;
68+
}
69+
70+
.mobileRow {
71+
display: flex;
72+
padding-top: $sp-2;
73+
padding-left: $sp-4;
74+
padding-right: $sp-4;
75+
> * {
76+
flex: 1 1 50%;
77+
}
78+
}
79+
.label {
80+
font-weight: bold;
81+
}
82+
.value {
83+
84+
svg {
85+
display: inline;
86+
vertical-align: middle;
87+
margin-right: $sp-1;
88+
}
89+
90+
}

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { FC, useMemo } from 'react'
22
import moment from 'moment'
33

44
import { CheckIcon, MinusCircleIcon } from '@heroicons/react/outline'
5+
import { useWindowSize, WindowSize } from '~/libs/shared'
56

67
import { AiWorkflowRunsResponse, useFetchAiWorkflowsRuns } from '../../hooks'
78
import { IconAiReview } from '../../assets/icons'
@@ -18,6 +19,85 @@ const AiReviewsTable: FC<AiReviewsTableProps> = props => {
1819
const aiWorkflowIds = useMemo(() => props.reviewers.map(r => r.aiWorkflowId), [props.reviewers])
1920
const { runs, isLoading }: AiWorkflowRunsResponse = useFetchAiWorkflowsRuns(props.submissionId, aiWorkflowIds)
2021

22+
const windowSize: WindowSize = useWindowSize()
23+
const isTablet = useMemo(
24+
() => (windowSize.width ?? 0) <= 984,
25+
[windowSize.width],
26+
)
27+
28+
if (isTablet) {
29+
return (
30+
<div className={styles.wrap}>
31+
{!runs.length && isLoading && (
32+
<div className={styles.mobileLoading}>Loading...</div>
33+
)}
34+
35+
{!runs.length && !isLoading && (
36+
<div className={styles.mobileLoading}>No reviews</div>
37+
)}
38+
39+
{runs.map(run => (
40+
<div key={run.id} className={styles.mobileCard}>
41+
<div className={styles.mobileRow}>
42+
<div className={styles.label}>Reviewer</div>
43+
<div className={styles.value}>
44+
<span className={styles.icon}>
45+
<IconAiReview />
46+
</span>
47+
<span className={styles.workflowName} title={run.workflow.name}>
48+
{run.workflow.name}
49+
</span>
50+
</div>
51+
</div>
52+
53+
<div className={styles.mobileRow}>
54+
<div className={styles.label}>Review Date</div>
55+
<div className={styles.value}>
56+
{run.status === 'SUCCESS'
57+
? moment(run.completedAt)
58+
.local()
59+
.format(TABLE_DATE_FORMAT)
60+
: '-'}
61+
</div>
62+
</div>
63+
64+
<div className={styles.mobileRow}>
65+
<div className={styles.label}>Score</div>
66+
<div className={styles.value}>
67+
{run.status === 'SUCCESS' ? run.score : '-'}
68+
</div>
69+
</div>
70+
71+
<div className={styles.mobileRow}>
72+
<div className={styles.label}>Result</div>
73+
<div className={`${styles.value} ${styles.resultCol}`}>
74+
{run.status === 'SUCCESS' ? (
75+
<div className={styles.result}>
76+
{run.score >= run.workflow.scorecard.minimumPassingScore ? (
77+
<>
78+
<CheckIcon className='icon icon-xl passed' />
79+
{' '}
80+
Passed
81+
</>
82+
) : (
83+
<>
84+
<MinusCircleIcon className='icon icon-xl' />
85+
{' '}
86+
Failed
87+
</>
88+
)}
89+
</div>
90+
) : (
91+
'-'
92+
)}
93+
</div>
94+
</div>
95+
</div>
96+
))}
97+
</div>
98+
)
99+
}
100+
21101
return (
22102
<div className={styles.wrap}>
23103
<table className={styles.reviewsTable}>

src/apps/review/src/lib/components/ChallengeDetailsContent/TabContentSubmissions.module.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,13 @@
126126
pointer-events: none;
127127
}
128128
}
129+
130+
.aiReviewerRow {
131+
@include ltelg {
132+
tr:has(&) {
133+
td:first-child {
134+
display: none;
135+
}
136+
}
137+
}
138+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@ export const TabContentSubmissions: FC<Props> = props => {
343343
type: 'element',
344344
},
345345
...(!props.aiReviewers?.length ? [] : [{
346+
className: styles.aiReviewerRow,
346347
label: 'Reviewer',
348+
mobileColSpan: 2,
347349
propertyName: 'submittedDate',
348350
renderer: (submission: BackendSubmission) => (
349351
<CollapsibleAiReviewsRow
@@ -418,6 +420,7 @@ export const TabContentSubmissions: FC<Props> = props => {
418420
},
419421
{
420422
...column,
423+
colSpan: column.mobileColSpan,
421424
mobileType: 'last-value',
422425
},
423426
] as MobileTableColumn<BackendSubmission>[],

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
display: flex;
1010
align-items: center;
1111
gap: $sp-2;
12+
cursor: pointer;
13+
14+
@include ltelg {
15+
justify-content: space-between;
16+
font-weight: 600;
17+
}
1218

1319
svg {
1420
color: #767676;
@@ -18,4 +24,13 @@
1824
.table {
1925
margin-top: $sp-2;
2026
margin-left: -1 * $sp-4;
27+
@include ltelg {
28+
margin-top: 0;
29+
margin-left: -1 * $sp-4;
30+
margin-right: -1 * $sp-4;
31+
}
32+
}
33+
34+
.rotated {
35+
transform: rotate(180deg);
2136
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FC, useCallback, useState } from 'react'
2+
import classNames from 'classnames'
23

34
import { IconOutline } from '~/libs/ui'
45

@@ -27,7 +28,7 @@ const CollapsibleAiReviewsRow: FC<CollapsibleAiReviewsRowProps> = props => {
2728
{' '}
2829
AI Reviewer
2930
{aiReviewersCount === 1 ? '' : 's'}
30-
<IconOutline.ChevronDownIcon className='icon-xl' />
31+
<IconOutline.ChevronDownIcon className={classNames('icon-xl', isOpen && styles.rotated)} />
3132
</span>
3233
{isOpen && (
3334
<div className={styles.table}>

src/libs/ui/lib/components/table/table-column.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export interface TableColumn<T> {
1313
readonly type: TableCellType
1414
readonly isSortable?: boolean
1515
readonly columnId?: string
16+
readonly mobileColSpan?: number
1617
}

0 commit comments

Comments
 (0)