Rename missed state -> status occurrences

This commit is contained in:
Sebastian Martinez
2024-07-15 14:43:15 +02:00
parent 1a5830b54a
commit 1775dd284d
12 changed files with 69 additions and 78 deletions
-6
View File
@@ -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,
+2 -2
View File
@@ -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[]> {
-6
View File
@@ -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(),
+1 -1
View File
@@ -101,7 +101,7 @@ describe("project", () => {
await api.project.getAllIssues(cobRid, {
page: 0,
perPage: 5,
state: "open",
status: "open",
});
});
+13 -13
View File
@@ -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}
+16 -13
View File
@@ -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}
+17 -17
View File
@@ -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}`;
+1 -1
View File
@@ -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 }) => {
+1 -1
View File
@@ -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();
+2 -2
View File
@@ -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",
});
});
+8 -8
View File
@@ -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 });
+8 -8
View File
@@ -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();