From 3822e50875315cad5fd1f30c7a545ced57d04074 Mon Sep 17 00:00:00 2001 From: FunamaYukina Date: Fri, 4 Apr 2025 18:26:41 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(MigrationDetailPage):=20Impr?= =?UTF-8?q?ove=20overall=20review=20handling=20and=20display=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Refactored the handling of overall review data to return default values when no review is found. - Updated the display logic to conditionally render review scores and comments, providing user feedback when no data is available. - Enhanced error handling for schema path fetching to ensure consistent return structure. --- .../MigrationDetailPage.tsx | 93 ++++++++++++------- 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx b/frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx index 9ff708278d..f1b28fc0a6 100644 --- a/frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx +++ b/frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx @@ -71,11 +71,6 @@ async function getMigrationContents(migrationId: string) { .limit(1) .single() - if (reviewError || !overallReview) { - console.error('OverallReview error:', reviewError) - return notFound() - } - const prDetails = await getPullRequestDetails( Number(repository.installationId), repository.owner, @@ -90,6 +85,23 @@ async function getMigrationContents(migrationId: string) { Number(pullRequest.pullNumber), ) + // If there's no overallReview, return with empty review data + if (reviewError || !overallReview) { + console.info('No OverallReview found for migration:', migrationId) + return { + migration, + overallReview: { + id: null, + projectId: null, + reviewComment: null, + reviewedAt: null, + reviewIssues: [], + reviewScores: [], + }, + erdLinks: [], + } + } + const { data: schemaPaths, error: pathsError } = await supabase .from('GitHubSchemaFilePath') .select('path') @@ -97,7 +109,11 @@ async function getMigrationContents(migrationId: string) { if (pathsError) { console.error('Error fetching schema paths:', pathsError) - return notFound() + return { + migration, + overallReview, + erdLinks: [], + } } const matchedFiles = files @@ -131,18 +147,20 @@ export const MigrationDetailPage: FC = async ({ migrationId }) => { const projectId = overallReview.projectId - const formattedReviewDate = new Date( - overallReview.reviewedAt, - ).toLocaleDateString('en-US') + const formattedReviewDate = overallReview.reviewedAt + ? new Date(overallReview.reviewedAt).toLocaleDateString('en-US') + : 'Not reviewed yet' return (
- - ← Back to Project Detail - + {projectId && ( + + ← Back to Project Detail + + )}

{migration.title}

@@ -152,16 +170,20 @@ export const MigrationDetailPage: FC = async ({ migrationId }) => {

Migration Health

-
- ({ - id: score.id, - overallReviewId: score.overallReviewId, - overallScore: score.overallScore, - category: score.category as CategoryEnum, - }))} - /> -
+ {overallReview.reviewScores.length > 0 ? ( +
+ ({ + id: score.id, + overallReviewId: score.overallReviewId, + overallScore: score.overallScore, + category: score.category as CategoryEnum, + }))} + /> +
+ ) : ( +

No review scores found.

+ )}
{erdLinks.map(({ path, filename }) => ( @@ -176,13 +198,20 @@ export const MigrationDetailPage: FC = async ({ migrationId }) => {

Review Content

-
-            {overallReview.reviewComment}
-          
- {/* Client-side user feedback component */} -
- -
+ {overallReview.reviewComment ? ( + <> +
+                {overallReview.reviewComment}
+              
+ {overallReview.traceId && ( +
+ +
+ )} + + ) : ( +

No review content found.

+ )}

Review Issues