Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
const renderSelectedTab = (): JSX.Element => {
const selectedTabLower = (props.selectedTab || '').toLowerCase()
const selectedTabNormalized = normalizeType(props.selectedTab)
const aiReviewers = (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The aiReviewers variable is defined using a type assertion. Consider using a type guard or ensuring the type safety of challengeInfo?.reviewers to avoid potential runtime errors if the structure of reviewers changes.

challengeInfo?.reviewers?.filter(r => !!r.aiWorkflowId) as { aiWorkflowId: string }[]
) ?? []

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

if (SUBMISSION_TAB_KEYS.has(selectedTabNormalized)) {
return renderSubmissionTab({
aiReviewers: (
challengeInfo?.reviewers?.filter(r => !!r.aiWorkflowId) as { aiWorkflowId: string }[]
) ?? [],
aiReviewers,
allowTopgearSubmissionList,
downloadSubmission: handleSubmissionDownload,
isActiveChallenge: props.isActiveChallenge,
Expand Down Expand Up @@ -444,6 +445,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
if (selectedTabLower === 'winners') {
return (
<TabContentWinners
aiReviewers={aiReviewers}
isLoading={isLoadingProjectResult}
projectResults={projectResults}
isDownloading={isDownloadingSubmission}
Expand Down Expand Up @@ -498,6 +500,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {

return (
<TabContentReview
aiReviewers={aiReviewers}
selectedTab={props.selectedTab}
reviews={reviewTabReviews}
submitterReviews={reviewTabSubmitterReviews}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
import { hasSubmitterPassedThreshold } from '../../utils/reviewScoring'

interface Props {
aiReviewers?: { aiWorkflowId: string }[]
selectedTab: string
reviews: SubmissionInfo[]
submitterReviews: SubmissionInfo[]
Expand Down Expand Up @@ -681,6 +682,7 @@ export const TabContentReview: FC<Props> = (props: Props) => {
return (
<TableAppealsResponse
datas={resolvedReviewsWithSubmitter}
aiReviewers={props.aiReviewers}
isDownloading={props.isDownloading}
downloadSubmission={props.downloadSubmission}
mappingReviewAppeal={props.mappingReviewAppeal}
Expand All @@ -698,13 +700,15 @@ export const TabContentReview: FC<Props> = (props: Props) => {
return isSubmitterView ? (
<TableAppealsForSubmitter
datas={filteredSubmitterReviews}
aiReviewers={props.aiReviewers}
isDownloading={props.isDownloading}
downloadSubmission={props.downloadSubmission}
mappingReviewAppeal={props.mappingReviewAppeal}
/>
) : (
<TableAppeals
datas={filteredReviews}
aiReviewers={props.aiReviewers}
isDownloading={props.isDownloading}
downloadSubmission={props.downloadSubmission}
mappingReviewAppeal={props.mappingReviewAppeal}
Expand All @@ -716,12 +720,14 @@ export const TabContentReview: FC<Props> = (props: Props) => {
return isSubmitterView ? (
<TableReviewForSubmitter
datas={reviewRows}
aiReviewers={props.aiReviewers}
isDownloading={props.isDownloading}
downloadSubmission={props.downloadSubmission}
mappingReviewAppeal={props.mappingReviewAppeal}
/>
) : (
<TableReview
aiReviewers={props.aiReviewers}
datas={reviewRows}
isDownloading={props.isDownloading}
downloadSubmission={props.downloadSubmission}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { TableWinners } from '../TableWinners'

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

return (
<TableWinners
aiReviewers={props.aiReviewers}
datas={props.projectResults}
isDownloading={props.isDownloading}
downloadSubmission={props.downloadSubmission}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { BackendSubmission } from '../../models'
import styles from './CollapsibleAiReviewsRow.module.scss'

interface CollapsibleAiReviewsRowProps {
className?: string
defaultOpen?: boolean
aiReviewers: { aiWorkflowId: string }[]
submission: BackendSubmission
submission: Pick<BackendSubmission, 'id'|'virusScan'>
}

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

return (
<div className={styles.wrap}>
<span className={styles.reviewersDropown} onClick={toggleOpen}>
<div className={classNames(props.className, styles.wrap)}>
<span className={classNames(styles.reviewersDropown, 'trigger')} onClick={toggleOpen}>
{aiReviewersCount}
{' '}
AI Reviewer
{aiReviewersCount === 1 ? '' : 's'}
<IconOutline.ChevronDownIcon className={classNames('icon-xl', isOpen && styles.rotated)} />
</span>
{isOpen && (
<div className={styles.table}>
<div className={classNames(styles.table, 'reviews-table')}>
<AiReviewsTable
reviewers={props.aiReviewers}
submission={props.submission}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,22 @@
font-size: 14px;
margin-right: $sp-2;
}

.aiReviews {
margin: $sp-2 0;
:global(.trigger) {
width: fit-content;
margin-left: auto;
}

:global(.reviews-table) {
margin-left: auto;
width: 75%;
margin-bottom: -9px;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Using a negative margin (margin-bottom: -9px;) can lead to layout issues, especially if the surrounding elements or their styles change. Consider using a different approach to achieve the desired spacing.


@include ltelg {
width: auto;
margin-left: -1*$sp-4;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The use of margin-left: -1*$sp-4; with a negative value can cause unexpected layout shifts, especially in responsive designs. It would be better to review the layout strategy to avoid relying on negative margins.

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ import type {
SubmissionRow,
} from '../common/types'
import type { AggregatedSubmissionReviews } from '../../utils/aggregateSubmissionReviews'
import { CollapsibleAiReviewsRow } from '../CollapsibleAiReviewsRow'

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

export interface TableAppealsProps {
className?: string
aiReviewers?: { aiWorkflowId: string }[]
datas: SubmissionInfo[]
isDownloading: IsRemovingType
downloadSubmission: (submissionId: string) => void
Expand Down Expand Up @@ -357,6 +359,25 @@ export const TableAppeals: FC<TableAppealsProps> = (props: TableAppealsProps) =>
}
}

if (props.aiReviewers) {
baseColumns.push({
columnId: 'ai-reviews-table',
isExpand: true,
label: '',
renderer: (submission: SubmissionRow, allRows: SubmissionRow[]) => (
props.aiReviewers && (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The use of submission as any for type casting can lead to potential runtime errors and makes the code less type-safe. Consider defining a more specific type for submission to maintain type safety.

<CollapsibleAiReviewsRow
className={styles.aiReviews}
aiReviewers={props.aiReviewers}
submission={submission as any}
defaultOpen={allRows ? !allRows.indexOf(submission) : false}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 readability]
The expression allRows ? !allRows.indexOf(submission) : false is used to determine the defaultOpen state. This logic could be more explicit. Consider using allRows.indexOf(submission) === 0 to clearly indicate that the first row should be open by default.

/>
)
),
type: 'element',
})
}

return baseColumns
}, [
allowsAppeals,
Expand All @@ -369,7 +390,7 @@ export const TableAppeals: FC<TableAppealsProps> = (props: TableAppealsProps) =>

const columnsMobile = useMemo<MobileTableColumn<SubmissionRow>[][]>(
() => columns.map(column => ([
{
column.label && {
columnId: `${column.columnId}-label`,
label: '',
mobileType: 'label',
Expand All @@ -384,11 +405,12 @@ export const TableAppeals: FC<TableAppealsProps> = (props: TableAppealsProps) =>
},
{
...column,
colSpan: column.label ? 1 : 2,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ design]
The colSpan property is conditionally set to 1 or 2 based on column.label. Ensure that this logic aligns with the intended table structure, as incorrect colSpan values can lead to layout issues.

columnId: `${column.columnId}-value`,
label: '',
mobileType: 'last-value',
},
]) as MobileTableColumn<SubmissionRow>[]),
]).filter(Boolean) as MobileTableColumn<SubmissionRow>[]),
[columns],
)

Expand All @@ -408,6 +430,8 @@ export const TableAppeals: FC<TableAppealsProps> = (props: TableAppealsProps) =>
<Table
columns={columns}
data={aggregatedRows}
showExpand
expandMode='always'
disableSorting
onToggleSort={_.noop}
removeDefaultSort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,22 @@
.tableCellNoWrap {
white-space: nowrap;
}

.aiReviews {
margin: $sp-2 0;
:global(.trigger) {
width: fit-content;
margin-left: auto;
}

:global(.reviews-table) {
margin-left: auto;
width: 75%;
margin-bottom: -9px;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Using a negative margin value (-9px) can lead to unexpected layout issues, especially if the surrounding elements or the parent container's layout changes. Consider verifying that this negative margin is necessary and that it does not cause any overlap or visual issues in different screen sizes.


@include ltelg {
width: auto;
margin-left: -1*$sp-4;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The use of -1*$sp-4 for margin-left could lead to maintenance challenges if $sp-4 changes or is used elsewhere with different expectations. Consider defining a specific variable for this negative margin if it's a common pattern, or ensure that its impact is well-understood across different components.

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ import {
TRACK_CHALLENGE,
WITHOUT_APPEAL,
} from '../../../config/index.config'
import { CollapsibleAiReviewsRow } from '../CollapsibleAiReviewsRow'

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

export interface TableAppealsForSubmitterProps {
className?: string
aiReviewers?: { aiWorkflowId: string }[]
datas: SubmissionInfo[]
isDownloading: IsRemovingType
downloadSubmission: (submissionId: string) => void
Expand Down Expand Up @@ -377,6 +379,25 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop
}
}

if (props.aiReviewers) {
baseColumns.push({
columnId: 'ai-reviews-table',
isExpand: true,
label: '',
renderer: (submission: SubmissionRow, allRows: SubmissionRow[]) => (
props.aiReviewers && (
<CollapsibleAiReviewsRow
className={styles.aiReviews}
aiReviewers={props.aiReviewers}
submission={submission as any}
defaultOpen={allRows ? !allRows.indexOf(submission) : false}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The use of submission as any for type casting can lead to potential runtime errors and makes the code less type-safe. Consider defining a more specific type for submission to ensure type safety.

/>
)
),
type: 'element',
})
}

return baseColumns
}, [
allowsAppeals,
Expand All @@ -390,7 +411,7 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop
const columnsMobile = useMemo<MobileTableColumn<SubmissionRow>[][]>(
() => columns.map(column => (
[
{
column.label && {
...column,
className: '',
label: `${column.label as string} label`,
Expand All @@ -405,9 +426,10 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop
},
{
...column,
colSpan: column.label ? 1 : 2,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 design]
The colSpan property is conditionally set to 1 or 2 based on the presence of column.label. Ensure that this logic aligns with the intended table layout, as incorrect colSpan values can lead to unexpected rendering issues.

mobileType: 'last-value',
},
] as MobileTableColumn<SubmissionRow>[]
].filter(Boolean) as MobileTableColumn<SubmissionRow>[]
)),
[columns],
)
Expand All @@ -428,6 +450,8 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop
<Table
columns={columns}
data={submissionRows}
showExpand
expandMode='always'
disableSorting
onToggleSort={noop}
removeDefaultSort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,22 @@
font-size: 14px;
margin-right: $sp-2;
}

.aiReviews {
margin: $sp-2 0;
:global(.trigger) {
width: fit-content;
margin-left: auto;
}

:global(.reviews-table) {
margin-left: auto;
width: 75%;
margin-bottom: -9px;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Using a negative margin (margin-bottom: -9px;) can lead to unexpected layout issues, especially if the surrounding elements change. Consider using a different layout strategy to achieve the desired spacing.


@include ltelg {
width: auto;
margin-left: -1*$sp-4;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The use of margin-left: -1*$sp-4; with a negative value can cause layout issues and make the code harder to maintain. It would be better to adjust the layout using other CSS properties or parent container styles.

}
}
}
Loading
Loading