From 9294e23ea49f691683df45120608df0b4934a62d Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Mon, 10 Jul 2023 10:44:19 +0200 Subject: [PATCH] Update patch review schemas To address changes to patch code review, implemented in Heartwood in commit 45e87a6. Signed-off-by: Sebastian Martinez --- httpd-client/lib/project/patch.ts | 47 +++++--------------------- src/views/projects/Cob/Revision.svelte | 4 +-- tests/e2e/project/patches.spec.ts | 2 +- 3 files changed, 11 insertions(+), 42 deletions(-) diff --git a/httpd-client/lib/project/patch.ts b/httpd-client/lib/project/patch.ts index 6af948ac3..1c09825aa 100644 --- a/httpd-client/lib/project/patch.ts +++ b/httpd-client/lib/project/patch.ts @@ -52,51 +52,21 @@ const mergeSchema = object({ timestamp: number(), }) satisfies ZodSchema; -interface CodeLocation { - path: string; - commit: string; - lines: { - start: number; - end: number; - }; -} - -const codeLocationSchema = object({ - path: string(), - commit: string(), - lines: object({ - start: number(), - end: number(), - }), -}) satisfies ZodSchema; - -interface CodeComment { - location: CodeLocation; - comment: string; - timestamp: number; -} - -const codeCommentSchema = object({ - location: codeLocationSchema, - comment: string(), - timestamp: number(), -}) satisfies ZodSchema; - type Verdict = "accept" | "reject"; export interface Review { author: { id: string; alias?: string }; verdict?: Verdict | null; - comment?: string | null; - inline: CodeComment[]; + summary: string | null; + comments: string[]; timestamp: number; } const reviewSchema = object({ author: object({ id: string(), alias: string().optional() }), verdict: optional(union([literal("accept"), literal("reject")]).nullable()), - comment: optional(string().nullable()), - inline: array(codeCommentSchema), + comments: array(string()), + summary: string().nullable(), timestamp: number(), }) satisfies ZodSchema; @@ -151,19 +121,18 @@ export const patchSchema = object({ export const patchesSchema = array(patchSchema) satisfies ZodSchema; export type PatchUpdateAction = - | { type: "edit"; title: string; description: string; target: string } + | { type: "edit"; title: string; target: string } | { type: "editRevision"; revision: string; description: string } + | { type: "editReview"; review: string; summary?: string } | { type: "tag"; add: string[]; remove: string[] } | { type: "revision"; description: string; base: string; oid: string } | { type: "lifecycle"; state: PatchState } | { type: "redact"; revision: string } | { type: "review"; - author: { id: string; alias?: string }; revision: string; - verdict?: Verdict; - comment?: string; - inline: CodeComment; + summary?: string; + verdict?: Verdict | null; } | { type: "merge"; revision: string; commit: string } | { type: "thread"; revision: string; action: ThreadUpdateAction }; diff --git a/src/views/projects/Cob/Revision.svelte b/src/views/projects/Cob/Revision.svelte index 17a7c00e6..eec40b421 100644 --- a/src/views/projects/Cob/Revision.svelte +++ b/src/views/projects/Cob/Revision.svelte @@ -372,7 +372,7 @@ {:else if element.type === "review"} {@const [author, review] = element.inner} - {#if review.comment} + {#if review.summary}
+ body={review.summary} />
{:else}
{ ).toHaveText("Add more text"); // Switching to the initial revision - await page.getByText("Revision 2592b1e").click(); + await page.getByText("Revision 779ce78").click(); await expect(page.locator(".dropdown")).toBeVisible(); await page.getByRole("link", { name: "Revision 0f3697f" }).click(); await expect(page.locator(".dropdown")).toBeHidden();