Radish alpha
r
rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5
Radicle web interface
Radicle
Git
Rename missed `state` -> `status` occurrences
Open did:key:z6MkkfM3...sVz5 opened 1 year ago
  • Remove more unused patch and issue schemas

check check-visual check-unit-test check-http-client-unit-test check-radicle-httpd check-e2e check-build check-http

👉 Preview 👉 Workflow runs 👉 Branch on GitHub

14 files changed +70 -222 c4aa4f04 1775dd28
modified http-client/index.ts
@@ -10,8 +10,6 @@ import type {
} from "./lib/project.js";
import type {
  Config,
-
  CodeLocation,
-
  Range,
  SeedingPolicy,
  DefaultSeedingPolicy,
} from "./lib/shared.js";
@@ -34,7 +32,6 @@ import type {
  Merge,
  Patch,
  PatchState,
-
  PatchUpdateAction,
  Review,
  Revision,
  Verdict,
@@ -58,7 +55,6 @@ export type {
  Blob,
  ChangesetWithDiff,
  ChangesetWithoutDiff,
-
  CodeLocation,
  Comment,
  Commit,
  CommitBlob,
@@ -78,10 +74,8 @@ export type {
  Merge,
  Patch,
  PatchState,
-
  PatchUpdateAction,
  Project,
  ProjectListQuery,
-
  Range,
  Reaction,
  Remote,
  Review,
modified http-client/lib/project.ts
@@ -349,7 +349,7 @@ export class Client {
    query?: {
      page?: number;
      perPage?: number;
-
      state?: string;
+
      status?: string;
    },
    options?: RequestOptions,
  ): Promise<Issue[]> {
@@ -384,7 +384,7 @@ export class Client {
    query?: {
      page?: number;
      perPage?: number;
-
      state?: string;
+
      status?: string;
    },
    options?: RequestOptions,
  ): Promise<Patch[]> {
modified http-client/lib/project/issue.ts
@@ -1,6 +1,5 @@
-
import type { Embed } from "./comment.js";
import type { ZodSchema, z } from "zod";
-
import { array, boolean, literal, object, string, union } from "zod";
+
import { array, literal, object, string, union } from "zod";

import { commentSchema } from "./comment.js";
import { authorSchema } from "../shared.js";
@@ -29,42 +28,4 @@ export const issueSchema = object({

export type Issue = z.infer<typeof issueSchema>;

-
export interface IssueCreated {
-
  success: boolean;
-
  id: string;
-
}
-

-
export const issueCreatedSchema = object({
-
  success: boolean(),
-
  id: string(),
-
}) satisfies ZodSchema<IssueCreated>;
-

export const issuesSchema = array(issueSchema) satisfies ZodSchema<Issue[]>;
-

-
export type IssueUpdateAction =
-
  | { type: "edit"; title: string }
-
  | { type: "label"; labels: string[] }
-
  | {
-
      type: "assign";
-
      assignees: string[];
-
    }
-
  | { type: "lifecycle"; state: IssueState }
-
  | {
-
      type: "comment";
-
      body: string;
-
      embeds?: Embed[];
-
      replyTo?: string;
-
    }
-
  | {
-
      type: "comment.edit";
-
      id: string;
-
      body: string;
-
      embeds: Embed[];
-
    }
-
  | { type: "comment.redact"; id: string }
-
  | {
-
      type: "comment.react";
-
      id: string;
-
      reaction: string;
-
      active: boolean;
-
    };
modified http-client/lib/project/patch.ts
@@ -1,12 +1,9 @@
-
import type { Embed } from "./comment.js";
import type { ZodSchema, z } from "zod";
-
import type { CodeLocation } from "../shared.js";

import { commentSchema } from "./comment.js";

import {
  array,
-
  boolean,
  literal,
  number,
  optional,
@@ -107,104 +104,3 @@ export type LifecycleState =
  | { status: "draft" }
  | { status: "open" }
  | { status: "archived" };
-

-
export type PatchUpdateAction =
-
  | { type: "edit"; title: string; target: "delegates" }
-
  | { type: "label"; labels: string[] }
-
  | { type: "assign"; assignees: string[] }
-
  | { type: "merge"; revision: string; commit: string }
-
  | { type: "lifecycle"; state: LifecycleState }
-
  | {
-
      type: "review";
-
      revision: string;
-
      summary?: string;
-
      verdict?: Verdict | null;
-
    }
-
  | { type: "review.edit"; review: string; summary?: string }
-
  | { type: "review.redact"; review: string }
-
  | {
-
      type: "review.comment";
-
      review: string;
-
      body: string;
-
      location: CodeLocation;
-
      replyTo?: string;
-
      embeds?: Embed[];
-
    }
-
  | {
-
      type: "review.comment.edit";
-
      review: string;
-
      comment: string;
-
      body: string;
-
      embeds: Embed[];
-
    }
-
  | {
-
      type: "review.comment.redact";
-
      review: string;
-
      comment: string;
-
    }
-
  | {
-
      type: "review.comment.react";
-
      review: string;
-
      comment: string;
-
      reaction: string;
-
      active: boolean;
-
    }
-
  | { type: "revision"; description: string; base: string; oid: string }
-
  | {
-
      type: "revision.edit";
-
      revision: string;
-
      description: string;
-
      embeds?: Embed[];
-
    }
-
  | {
-
      type: "revision.react";
-
      revision: string;
-
      reaction: string;
-
      location?: CodeLocation;
-
      active: boolean;
-
    }
-
  | { type: "revision.redact"; revision: string }
-
  | {
-
      type: "revision.comment";
-
      revision: string;
-
      body: string;
-
      embeds?: Embed[];
-
      location?: CodeLocation;
-
      replyTo?: string;
-
    }
-
  | {
-
      type: "revision.comment.edit";
-
      revision: string;
-
      comment: string;
-
      body: string;
-
      embeds: Embed[];
-
    }
-
  | {
-
      type: "revision.comment.redact";
-
      revision: string;
-
      comment: string;
-
    }
-
  | {
-
      type: "revision.comment.react";
-
      revision: string;
-
      comment: string;
-
      reaction: string;
-
      active: boolean;
-
    };
-

-
export const patchCreateSchema = object({
-
  title: string(),
-
  description: string(),
-
  target: string(),
-
  oid: string(),
-
  labels: array(string()),
-
});
-

-
export type PatchCreate = z.infer<typeof patchCreateSchema>;
-

-
export const patchCreatedSchema = object({
-
  success: boolean(),
-
  id: string(),
-
});
-

-
export type PatchCreated = z.infer<typeof patchCreatedSchema>;
modified http-client/lib/shared.ts
@@ -2,10 +2,6 @@ import type { z } from "zod";

import { array, boolean, literal, number, object, string, union } from "zod";

-
export interface SuccessResponse {
-
  success: true;
-
}
-

export const scopeSchema = union([literal("followed"), literal("all")]);

export const seedingPolicySchema = union([
@@ -121,8 +117,6 @@ export const codeLocationSchema = object({
  new: rangeSchema.nullable(),
});

-
export type CodeLocation = z.infer<typeof codeLocationSchema>;
-

export const authorSchema = object({
  id: string(),
  alias: string().optional(),
modified http-client/tests/project.test.ts
@@ -101,7 +101,7 @@ describe("project", () => {
    await api.project.getAllIssues(cobRid, {
      page: 0,
      perPage: 5,
-
      state: "open",
+
      status: "open",
    });
  });

modified src/views/projects/Issues.svelte
@@ -31,7 +31,7 @@
  export let seedingPolicy: SeedingPolicy;
  export let issues: Issue[];
  export let project: Project;
-
  export let state: IssueState["status"];
+
  export let status: IssueState["status"];

  let loading = false;
  let page = 0;
@@ -46,12 +46,12 @@

  const api = new HttpdClient(baseUrl);

-
  async function loadIssues(state: IssueState["status"]): Promise<void> {
+
  async function loadIssues(status: IssueState["status"]): Promise<void> {
    loading = true;
    page += 1;
    try {
      const response = await api.project.getAllIssues(project.id, {
-
        state,
+
        status,
        page,
        perPage: ISSUES_PER_PAGE,
      });
@@ -70,7 +70,7 @@
  };

  $: showMoreButton =
-
    !loading && !error && allIssues.length < project.issues[state];
+
    !loading && !error && allIssues.length < project.issues[status];
</script>

<style>
@@ -128,12 +128,12 @@
        on:click={toggle}
        ariaLabel="filter-dropdown"
        title="Filter issues by state">
-
        <div style:color={stateColor[state]}>
+
        <div style:color={stateColor[status]}>
          <IconSmall name="issue" />
        </div>
-
        {capitalize(state)}
+
        {capitalize(status)}
        <div class="dropdown-button-counter">
-
          {project.issues[state]}
+
          {project.issues[status]}
        </div>
        <IconSmall name={expanded ? "chevron-up" : "chevron-down"} />
      </Button>
@@ -147,9 +147,9 @@
            resource: "project.issues",
            project: project.id,
            node: baseUrl,
-
            state: item,
+
            status: item,
          }}>
-
          <DropdownListItem selected={item === state}>
+
          <DropdownListItem selected={item === status}>
            <div style:color={stateColor[item]}>
              <IconSmall name="issue" />
            </div>
@@ -158,7 +158,7 @@
              {capitalize(item)}
              <div
                class="dropdown-list-counter"
-
                class:selected={item === state}>
+
                class:selected={item === status}>
                {project.issues[item]}
              </div>
            </div>
@@ -188,9 +188,9 @@
      {error} />
  {/if}

-
  {#if project.issues[state] === 0}
+
  {#if project.issues[status] === 0}
    <div class="placeholder">
-
      <Placeholder iconName="no-issues" caption={`No ${state} issues`} />
+
      <Placeholder iconName="no-issues" caption={`No ${status} issues`} />
    </div>
  {/if}

@@ -204,7 +204,7 @@
        <Button
          size="large"
          variant="outline"
-
          on:click={() => loadIssues(state)}>
+
          on:click={() => loadIssues(status)}>
          More
        </Button>
      {/if}
modified src/views/projects/Patches.svelte
@@ -31,7 +31,7 @@
  export let seedingPolicy: SeedingPolicy;
  export let patches: Patch[];
  export let project: Project;
-
  export let state: PatchState["status"];
+
  export let status: PatchState["status"];

  let loading = false;
  let page = 0;
@@ -46,12 +46,12 @@

  const api = new HttpdClient(baseUrl);

-
  async function loadMore(state: PatchState["status"]): Promise<void> {
+
  async function loadMore(status: PatchState["status"]): Promise<void> {
    loading = true;
    page += 1;
    try {
      const response = await api.project.getAllPatches(project.id, {
-
        state,
+
        status,
        page,
        perPage: PATCHES_PER_PAGE,
      });
@@ -78,7 +78,7 @@
  };

  $: showMoreButton =
-
    !loading && !error && allPatches.length < project.patches[state];
+
    !loading && !error && allPatches.length < project.patches[status];
</script>

<style>
@@ -136,12 +136,12 @@
        on:click={toggle}
        ariaLabel="filter-dropdown"
        title="Filter patches by state">
-
        <div style:color={stateColor[state]}>
+
        <div style:color={stateColor[status]}>
          <IconSmall name="patch" />
        </div>
-
        {capitalize(state)}
+
        {capitalize(status)}
        <div class="dropdown-button-counter">
-
          {project.patches[state]}
+
          {project.patches[status]}
        </div>
        <IconSmall name={expanded ? "chevron-up" : "chevron-down"} />
      </Button>
@@ -154,9 +154,9 @@
            resource: "project.patches",
            project: project.id,
            node: baseUrl,
-
            search: `state=${item}`,
+
            search: `status=${item}`,
          }}>
-
          <DropdownListItem selected={item === state}>
+
          <DropdownListItem selected={item === status}>
            <div style:color={stateColor[item]}>
              <IconSmall name="patch" />
            </div>
@@ -165,7 +165,7 @@
              {capitalize(item)}
              <div
                class="dropdown-list-counter"
-
                class:selected={item === state}>
+
                class:selected={item === status}>
                {project.patches[item]}
              </div>
            </div>
@@ -195,9 +195,9 @@
      {error} />
  {/if}

-
  {#if project.patches[state] === 0}
+
  {#if project.patches[status] === 0}
    <div class="placeholder">
-
      <Placeholder iconName="no-patches" caption={`No ${state} patches`} />
+
      <Placeholder iconName="no-patches" caption={`No ${status} patches`} />
    </div>
  {/if}

@@ -210,7 +210,10 @@
      {/if}

      {#if showMoreButton}
-
        <Button size="large" variant="outline" on:click={() => loadMore(state)}>
+
        <Button
+
          size="large"
+
          variant="outline"
+
          on:click={() => loadMore(status)}>
          More
        </Button>
      {/if}
modified src/views/projects/router.ts
@@ -51,7 +51,7 @@ interface ProjectIssuesRoute {
  resource: "project.issues";
  node: BaseUrl;
  project: string;
-
  state?: "open" | "closed";
+
  status?: "open" | "closed";
}

interface ProjectIssueRoute {
@@ -163,7 +163,7 @@ export type ProjectLoadedRoute =
        seedingPolicy: SeedingPolicy;
        project: Project;
        issues: Issue[];
-
        state: IssueState["status"];
+
        status: IssueState["status"];
      };
    }
  | {
@@ -173,7 +173,7 @@ export type ProjectLoadedRoute =
        seedingPolicy: SeedingPolicy;
        project: Project;
        patches: Patch[];
-
        state: PatchState["status"];
+
        status: PatchState["status"];
      };
    }
  | {
@@ -309,12 +309,12 @@ async function loadPatchesView(
): Promise<ProjectLoadedRoute> {
  const api = new HttpdClient(route.node);
  const searchParams = new URLSearchParams(route.search || "");
-
  const state = (searchParams.get("state") as PatchState["status"]) || "open";
+
  const status = (searchParams.get("status") as PatchState["status"]) || "open";

  const [project, patches, seedingPolicy] = await Promise.all([
    api.project.getById(route.project),
    api.project.getAllPatches(route.project, {
-
      state,
+
      status,
      page: 0,
      perPage: PATCHES_PER_PAGE,
    }),
@@ -327,7 +327,7 @@ async function loadPatchesView(
      baseUrl: route.node,
      seedingPolicy,
      patches,
-
      state,
+
      status,
      project,
    },
  };
@@ -337,12 +337,12 @@ async function loadIssuesView(
  route: ProjectIssuesRoute,
): Promise<ProjectLoadedRoute> {
  const api = new HttpdClient(route.node);
-
  const state = route.state || "open";
+
  const status = route.status || "open";

  const [project, issues, seedingPolicy] = await Promise.all([
    api.project.getById(route.project),
    api.project.getAllIssues(route.project, {
-
      state,
+
      status,
      page: 0,
      perPage: ISSUES_PER_PAGE,
    }),
@@ -355,7 +355,7 @@ async function loadIssuesView(
      baseUrl: route.node,
      seedingPolicy,
      issues,
-
      state,
+
      status,
      project,
    },
  };
@@ -741,18 +741,18 @@ export function resolveProjectRoute(
        issue: issueOrAction,
      };
    } else {
-
      const rawState = new URLSearchParams(sanitizeQueryString(urlSearch)).get(
-
        "state",
+
      const rawStatus = new URLSearchParams(sanitizeQueryString(urlSearch)).get(
+
        "status",
      );
-
      let state: "open" | "closed" | undefined;
-
      if (rawState === "open" || rawState === "closed") {
-
        state = rawState;
+
      let status: "open" | "closed" | undefined;
+
      if (rawStatus === "open" || rawStatus === "closed") {
+
        status = rawStatus;
      }
      return {
        resource: "project.issues",
        node,
        project,
-
        state,
+
        status,
      };
    }
  } else if (content === "patches") {
@@ -861,8 +861,8 @@ export function projectRouteToPath(route: ProjectRoute): string {
  } else if (route.resource === "project.issues") {
    let url = [...pathSegments, "issues"].join("/");
    const searchParams = new URLSearchParams();
-
    if (route.state) {
-
      searchParams.set("state", route.state);
+
    if (route.status) {
+
      searchParams.set("status", route.status);
    }
    if (searchParams.size > 0) {
      url += `?${searchParams}`;
modified tests/e2e/project/issues.spec.ts
@@ -8,7 +8,7 @@ test("navigate issue listing", async ({ page }) => {

  await page.getByRole("button", { name: "filter-dropdown" }).first().click();
  await page.getByRole("link", { name: "Closed 2" }).click();
-
  await expect(page).toHaveURL(`${cobUrl}/issues?state=closed`);
+
  await expect(page).toHaveURL(`${cobUrl}/issues?status=closed`);
});

test("issue counters", async ({ page, peer }) => {
modified tests/e2e/project/patches.spec.ts
@@ -8,7 +8,7 @@ test("navigate patch listing", async ({ page }) => {

  await page.getByRole("button", { name: "filter-dropdown" }).first().click();
  await page.getByRole("link", { name: "Merged 1" }).click();
-
  await expect(page).toHaveURL(`${cobUrl}/patches?state=merged`);
+
  await expect(page).toHaveURL(`${cobUrl}/patches?status=merged`);
  await expect(
    page.locator(".comments").filter({ hasText: "5" }),
  ).toBeVisible();
modified tests/unit/router.test.ts
@@ -113,12 +113,12 @@ describe("route invariant when parsed", () => {
    });
  });

-
  test("projects.issues with state", () => {
+
  test("projects.issues with status", () => {
    expectParsingInvariant({
      resource: "project.issues",
      node,
      project: "PROJECT",
-
      state: "closed",
+
      status: "closed",
    });
  });

modified tests/visual/desktop/cob.spec.ts
@@ -15,7 +15,7 @@ test("issues page", async ({ page }) => {
  await page.goto(`${cobUrl}/issues`, { waitUntil: "networkidle" });
  await expect(page).toHaveScreenshot({ fullPage: true });

-
  await page.goto(`${cobUrl}/issues?state=closed`, {
+
  await page.goto(`${cobUrl}/issues?status=closed`, {
    waitUntil: "networkidle",
  });
  await expect(page).toHaveScreenshot({ fullPage: true });
@@ -27,8 +27,8 @@ test("issue page", async ({ page }) => {
    ["A closed issue", "closed"],
    ["A solved issue", "closed"],
  ];
-
  for (const [name, state] of issues) {
-
    await page.goto(`${cobUrl}/issues?state=${state}`);
+
  for (const [name, status] of issues) {
+
    await page.goto(`${cobUrl}/issues?status=${status}`);
    await page.getByRole("link", { name }).click();
    await page.getByRole("heading", { name }).waitFor();
    await expect(page).toHaveScreenshot({ fullPage: true });
@@ -40,15 +40,15 @@ test("patches page", async ({ page }) => {
    waitUntil: "networkidle",
  });
  await expect(page).toHaveScreenshot({ fullPage: true });
-
  await page.goto(`${cobUrl}/patches?state=draft`, {
+
  await page.goto(`${cobUrl}/patches?status=draft`, {
    waitUntil: "networkidle",
  });
  await expect(page).toHaveScreenshot({ fullPage: true });
-
  await page.goto(`${cobUrl}/patches?state=archived`, {
+
  await page.goto(`${cobUrl}/patches?status=archived`, {
    waitUntil: "networkidle",
  });
  await expect(page).toHaveScreenshot({ fullPage: true });
-
  await page.goto(`${cobUrl}/patches?state=merged`, {
+
  await page.goto(`${cobUrl}/patches?status=merged`, {
    waitUntil: "networkidle",
  });
  await expect(page).toHaveScreenshot({ fullPage: true });
@@ -63,8 +63,8 @@ test("patch page", async ({ page }) => {
    ["Taking another stab at the README", "open"],
  ];

-
  for (const [name, state] of patches) {
-
    await page.goto(`${cobUrl}/patches?state=${state}`);
+
  for (const [name, status] of patches) {
+
    await page.goto(`${cobUrl}/patches?status=${status}`);
    await page.getByRole("link", { name }).click();
    await page.getByRole("heading", { name }).waitFor();
    await expect(page).toHaveScreenshot({ fullPage: true });
modified tests/visual/mobile/cob.spec.ts
@@ -15,7 +15,7 @@ test("issues page", async ({ page }) => {
  await page.goto(`${cobUrl}/issues`, { waitUntil: "networkidle" });
  await expect(page).toHaveScreenshot({ fullPage: true });

-
  await page.goto(`${cobUrl}/issues?state=closed`, {
+
  await page.goto(`${cobUrl}/issues?status=closed`, {
    waitUntil: "networkidle",
  });
  await expect(page).toHaveScreenshot({ fullPage: true });
@@ -27,8 +27,8 @@ test("issue page", async ({ page }) => {
    ["A closed issue", "closed"],
    ["A solved issue", "closed"],
  ];
-
  for (const [name, state] of issues) {
-
    await page.goto(`${cobUrl}/issues?state=${state}`);
+
  for (const [name, status] of issues) {
+
    await page.goto(`${cobUrl}/issues?status=${status}`);
    await page.getByRole("link", { name }).click();
    await page.getByRole("heading", { name }).waitFor();
    await expect(page).toHaveScreenshot({ fullPage: true });
@@ -40,15 +40,15 @@ test("patches page", async ({ page }) => {
    waitUntil: "networkidle",
  });
  await expect(page).toHaveScreenshot({ fullPage: true });
-
  await page.goto(`${cobUrl}/patches?state=draft`, {
+
  await page.goto(`${cobUrl}/patches?status=draft`, {
    waitUntil: "networkidle",
  });
  await expect(page).toHaveScreenshot({ fullPage: true });
-
  await page.goto(`${cobUrl}/patches?state=archived`, {
+
  await page.goto(`${cobUrl}/patches?status=archived`, {
    waitUntil: "networkidle",
  });
  await expect(page).toHaveScreenshot({ fullPage: true });
-
  await page.goto(`${cobUrl}/patches?state=merged`, {
+
  await page.goto(`${cobUrl}/patches?status=merged`, {
    waitUntil: "networkidle",
  });
  await expect(page).toHaveScreenshot({ fullPage: true });
@@ -62,8 +62,8 @@ test("patch page", async ({ page }) => {
    ["Add subtitle to README", "open"],
  ];

-
  for (const [name, state] of patches) {
-
    await page.goto(`${cobUrl}/patches?state=${state}`, {
+
  for (const [name, status] of patches) {
+
    await page.goto(`${cobUrl}/patches?status=${status}`, {
      waitUntil: "networkidle",
    });
    await page.getByRole("link", { name }).click();