-
Notifications
You must be signed in to change notification settings - Fork 23
PM-4401 stacked view for submitter #1553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ import { | |
| import type { | ||
| DownloadButtonConfig, | ||
| ScoreVisibilityConfig, | ||
| SubmissionReviewerRow, | ||
| SubmissionRow, | ||
| } from '../common/types' | ||
| import { | ||
|
|
@@ -60,6 +61,7 @@ import { | |
| WITHOUT_APPEAL, | ||
| } from '../../../config/index.config' | ||
| import { CollapsibleAiReviewsRow } from '../CollapsibleAiReviewsRow' | ||
| import { buildSubmissionReviewerRows } from '../common/reviewResult' | ||
|
|
||
| import styles from './TableAppealsForSubmitter.module.scss' | ||
|
|
||
|
|
@@ -244,12 +246,9 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop | |
| [aggregatedRows], | ||
| ) | ||
|
|
||
| const maxReviewCount = useMemo<number>( | ||
| () => aggregatedRows.reduce( | ||
| (count, row) => Math.max(count, row.reviews.length), | ||
| 0, | ||
| ), | ||
| [aggregatedRows], | ||
| const reviewerRows = useMemo<SubmissionReviewerRow[]>( | ||
| () => buildSubmissionReviewerRows(submissionRows), | ||
| [submissionRows], | ||
| ) | ||
|
|
||
| const { | ||
|
|
@@ -292,26 +291,63 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop | |
| [ownedMemberIds], | ||
| ) | ||
|
|
||
| const columns = useMemo<TableColumn<SubmissionRow>[]>(() => { | ||
| const baseColumns: TableColumn<SubmissionRow>[] = [] | ||
| const columns = useMemo<TableColumn<SubmissionReviewerRow>[]>(() => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| const baseColumns: TableColumn<SubmissionReviewerRow>[] = [] | ||
|
|
||
| baseColumns.push({ | ||
| className: styles.submissionColumn, | ||
| className: classNames(styles.submissionColumn, 'no-row-border'), | ||
| columnId: 'submission-id', | ||
| label: 'Submission ID', | ||
| renderer: submission => renderSubmissionIdCell(submission, downloadConfigBase), | ||
| renderer: submission => ( | ||
| submission.isFirstReviewerRow | ||
| ? renderSubmissionIdCell(submission, downloadConfigBase) | ||
| : <span /> | ||
| ), | ||
| type: 'element', | ||
| }) | ||
|
|
||
| if (isChallengeCompleted) { | ||
| baseColumns.push({ | ||
| className: 'no-row-border', | ||
| columnId: 'submitter', | ||
| label: 'Submitter', | ||
| renderer: submission => renderSubmitterHandleCell(submission), | ||
| renderer: submission => ( | ||
| submission.isFirstReviewerRow | ||
| ? renderSubmitterHandleCell(submission) | ||
| : <span /> | ||
| ), | ||
| type: 'element', | ||
| }) | ||
| } | ||
|
|
||
| baseColumns.push({ | ||
| className: 'no-row-border', | ||
| columnId: 'review-score', | ||
| label: 'Review Score', | ||
| renderer: submission => { | ||
| if (!submission.isFirstReviewerRow) { | ||
| return <span /> | ||
| } | ||
|
|
||
| const isOwnedSubmission = isOwned(submission) | ||
| const scoreConfig: ScoreVisibilityConfig = { | ||
| canDisplayScores, | ||
| canViewScorecard: isChallengeCompleted || isOwnedSubmission, | ||
| isAppealsTab: true, | ||
| } | ||
|
|
||
| return renderReviewScoreCell(submission, scoreConfig) | ||
| }, | ||
| type: 'element', | ||
| }) | ||
|
|
||
| baseColumns.push({ | ||
| columnId: 'reviewer', | ||
| label: 'Reviewer', | ||
| renderer: submission => renderReviewerCell(submission, submission.reviewerIndex), | ||
| type: 'element', | ||
| }) | ||
|
|
||
| baseColumns.push({ | ||
| columnId: 'review-date', | ||
| label: 'Review Date', | ||
|
|
@@ -320,8 +356,8 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop | |
| }) | ||
|
|
||
| baseColumns.push({ | ||
| columnId: 'review-score', | ||
| label: 'Review Score', | ||
| columnId: 'score', | ||
| label: 'Score', | ||
| renderer: submission => { | ||
| const isOwnedSubmission = isOwned(submission) | ||
| const scoreConfig: ScoreVisibilityConfig = { | ||
|
|
@@ -330,22 +366,16 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop | |
| isAppealsTab: true, | ||
| } | ||
|
|
||
| return renderReviewScoreCell(submission, scoreConfig) | ||
| return renderScoreCell(submission, submission.reviewerIndex, scoreConfig) | ||
| }, | ||
| type: 'element', | ||
| }) | ||
|
|
||
| for (let index = 0; index < maxReviewCount; index += 1) { | ||
| baseColumns.push({ | ||
| columnId: `reviewer-${index}`, | ||
| label: `Reviewer ${index + 1}`, | ||
| renderer: submission => renderReviewerCell(submission, index), | ||
| type: 'element', | ||
| }) | ||
|
|
||
| if (allowsAppeals) { | ||
| baseColumns.push({ | ||
| columnId: `score-${index}`, | ||
| label: `Score ${index + 1}`, | ||
| className: styles.tableCellNoWrap, | ||
| columnId: 'appeals', | ||
| label: 'Appeals', | ||
| renderer: submission => { | ||
| const isOwnedSubmission = isOwned(submission) | ||
| const scoreConfig: ScoreVisibilityConfig = { | ||
|
|
@@ -354,46 +384,36 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop | |
| isAppealsTab: true, | ||
| } | ||
|
|
||
| return renderScoreCell(submission, index, scoreConfig) | ||
| return renderAppealsCell(submission, submission.reviewerIndex, scoreConfig) | ||
| }, | ||
| type: 'element', | ||
| }) | ||
|
|
||
| if (allowsAppeals) { | ||
| baseColumns.push({ | ||
| className: styles.tableCellNoWrap, | ||
| columnId: `appeals-${index}`, | ||
| label: `Appeals ${index + 1}`, | ||
| renderer: submission => { | ||
| const isOwnedSubmission = isOwned(submission) | ||
| const scoreConfig: ScoreVisibilityConfig = { | ||
| canDisplayScores, | ||
| canViewScorecard: isChallengeCompleted || isOwnedSubmission, | ||
| isAppealsTab: true, | ||
| } | ||
|
|
||
| return renderAppealsCell(submission, index, scoreConfig) | ||
| }, | ||
| type: 'element', | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| if (props.aiReviewers) { | ||
| baseColumns.push({ | ||
| columnId: 'ai-reviews-table', | ||
| isExpand: true, | ||
| label: '', | ||
| renderer: (submission: SubmissionRow, allRows: SubmissionRow[]) => ( | ||
| props.aiReviewers && ( | ||
| renderer: (submission: SubmissionReviewerRow, allRows: SubmissionReviewerRow[]) => { | ||
| if (!submission.isLastReviewerRow || !props.aiReviewers) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
| return <span /> | ||
| } | ||
|
|
||
| const firstIndexForSubmission = allRows.findIndex(candidate => ( | ||
| candidate.id === submission.id && candidate.isFirstReviewerRow | ||
| )) | ||
| const defaultOpen = firstIndexForSubmission === 0 | ||
|
|
||
| return ( | ||
| <CollapsibleAiReviewsRow | ||
| className={styles.aiReviews} | ||
| aiReviewers={props.aiReviewers} | ||
| submission={submission as any} | ||
| defaultOpen={allRows ? !allRows.indexOf(submission) : false} | ||
| defaultOpen={defaultOpen} | ||
| /> | ||
| ) | ||
| ), | ||
| }, | ||
| type: 'element', | ||
| }) | ||
| } | ||
|
|
@@ -405,10 +425,9 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop | |
| downloadConfigBase, | ||
| isChallengeCompleted, | ||
| isOwned, | ||
| maxReviewCount, | ||
| ]) | ||
|
|
||
| const columnsMobile = useMemo<MobileTableColumn<SubmissionRow>[][]>( | ||
| const columnsMobile = useMemo<MobileTableColumn<SubmissionReviewerRow>[][]>( | ||
| () => columns.map(column => ( | ||
| [ | ||
| column.label && { | ||
|
|
@@ -429,7 +448,7 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop | |
| colSpan: column.label ? 1 : 2, | ||
| mobileType: 'last-value', | ||
| }, | ||
| ].filter(Boolean) as MobileTableColumn<SubmissionRow>[] | ||
| ].filter(Boolean) as MobileTableColumn<SubmissionReviewerRow>[] | ||
| )), | ||
| [columns], | ||
| ) | ||
|
|
@@ -445,11 +464,11 @@ export const TableAppealsForSubmitter: FC<TableAppealsForSubmitterProps> = (prop | |
| )} | ||
| > | ||
| {isTablet ? ( | ||
| <TableMobile columns={columnsMobile} data={submissionRows} /> | ||
| <TableMobile columns={columnsMobile} data={reviewerRows} /> | ||
| ) : ( | ||
| <Table | ||
| columns={columns} | ||
| data={submissionRows} | ||
| data={reviewerRows} | ||
| showExpand | ||
| expandMode='always' | ||
| disableSorting | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[⚠️
correctness]The
useMemohook is used to memoizereviewerRows, but the dependency array only includessubmissionRows. Ensure thatbuildSubmissionReviewerRowsis a pure function and does not rely on any external state or variables that could change, as this could lead to stale data being used.