Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Update patch review schemas
Sebastian Martinez committed 2 years ago
commit 9294e23ea49f691683df45120608df0b4934a62d
parent 145169d03dfb2dc33a001c4db4964db24f20e51d
3 files changed +11 -42
modified httpd-client/lib/project/patch.ts
@@ -52,51 +52,21 @@ const mergeSchema = object({
  timestamp: number(),
}) satisfies ZodSchema<Merge>;

-
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<CodeLocation>;
-

-
interface CodeComment {
-
  location: CodeLocation;
-
  comment: string;
-
  timestamp: number;
-
}
-

-
const codeCommentSchema = object({
-
  location: codeLocationSchema,
-
  comment: string(),
-
  timestamp: number(),
-
}) satisfies ZodSchema<CodeComment>;
-

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<Review>;

@@ -151,19 +121,18 @@ export const patchSchema = object({
export const patchesSchema = array(patchSchema) satisfies ZodSchema<Patch[]>;

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 };
modified src/views/projects/Cob/Revision.svelte
@@ -372,7 +372,7 @@
            </div>
          {:else if element.type === "review"}
            {@const [author, review] = element.inner}
-
            {#if review.comment}
+
            {#if review.summary}
              <div
                class="action"
                class:comment-review={review.verdict === null}
@@ -389,7 +389,7 @@
                    baseUrl,
                    projectHead,
                  )}
-
                  body={review.comment} />
+
                  body={review.summary} />
              </div>
            {:else}
              <div
modified tests/e2e/project/patches.spec.ts
@@ -52,7 +52,7 @@ test("use revision selector", async ({ page }) => {
  ).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();