Skip to content

Commit

Permalink
fix(mass-pr): extract components
Browse files Browse the repository at this point in the history
extract components
  • Loading branch information
snomiao committed Jan 20, 2025
1 parent 1e654a1 commit 36d4e54
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 31 deletions.
16 changes: 2 additions & 14 deletions app/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Link from "next/link";
import { Header } from "../Components/Header";

/**
*
Expand All @@ -7,19 +7,7 @@ import Link from "next/link";
export default function ComponentLayout({ children }: { children: React.ReactNode }) {
return (
<div className="w-full min-h-screen flex bg-cyan-800 card-body text-white gap-8">
<header className="flex w-full gap-4 flex-wrap">
<Link href="/">
<h1 className="text-5xl">Comfy-PR</h1>
</Link>
<nav className="flex gap-2 flex-wrap">
<Link href="/details" className="text-2xl">
Details
</Link>
<Link href="/rules" className="text-2xl">
Rules
</Link>
</nav>
</header>
<Header />
<div className="shadow-xl bg-cyan-900 text-white w-full card">{children}</div>
</div>
);
Expand Down
22 changes: 22 additions & 0 deletions app/Components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Link from "next/link";

export function Header() {
return <header className="flex w-full gap-4 flex-wrap">
<Link href="/">
<h1 className="text-5xl">Comfy-PR</h1>
</Link>
<nav className="flex gap-2 flex-wrap">
<Link href="/details" className="text-2xl">
Details
</Link>
<Link href="/rules" className="text-2xl">
Rules
</Link>
<Link href="/tasks" className="text-2xl">
Tasks
</Link>
</nav>
</header>;
}


12 changes: 12 additions & 0 deletions app/tasks/GithubActionUpdateTask/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getAuthUser } from "@/app/(dashboard)/rules/getAuthUser";
import "@/app/markdown.css";
import "@/app/tasks-panel.css";
import {
Expand All @@ -8,13 +9,16 @@ import {
import { parseTitleBodyOfMarkdown } from "@/src/parseTitleBodyOfMarkdown";
import { yaml } from "@/src/utils/yaml";
import DIE from "@snomiao/die";
import { forbidden } from "next/navigation";
import Markdown from "react-markdown";
import remarkGfm from "remark-gfm";
/**
*
* @author: snomiao <[email protected]>
*/
export default async function GithubActionUpdateTaskPage() {
const user = await getAuthUser();
if (!user.admin) forbidden();
const data = await listGithubActionUpdateTask();
const errorData = data.filter((e) => e.error);
const processingData = data.filter((e) => !e.pullRequestMessage);
Expand All @@ -29,6 +33,13 @@ export default async function GithubActionUpdateTaskPage() {
return (
<div className="tasks-panel">
<h1>GithubActionUpdateTasks in Total x{data.length}</h1>
<ul className="pl-4">
<li>1. Drafting PRs x{processingData.length}</li>
<li>2. Pending Reviews x{pendingReviewsData.length}</li>
<li>3. Pending Create Pull Request x{pendingCreatePRData.length}</li>
<li>4. Pull Request Created x{prCreatedData.length}</li>
<li>5. Errors x{errorData.length}</li>
</ul>

<h2>1. Drafting PRs x{processingData.length}</h2>
<ol className="flex flex-col max-w-full px-4">
Expand Down Expand Up @@ -60,6 +71,7 @@ export default async function GithubActionUpdateTaskPage() {
className="btn"
onClick={async () => {
"use server";
await getAuthUser();
await approveGithubActionUpdateTask(e.repo, e.branchVersionHash ?? DIE("missing branchVersionHash"));
return "ok";
}}
Expand Down
18 changes: 3 additions & 15 deletions app/tasks/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from "next/link";
import { Suspense } from "react";
import { Header } from "../Components/Header";

/**
*
Expand All @@ -8,22 +8,10 @@ import { Suspense } from "react";
export default function ComponentLayout({ children }: { children: React.ReactNode }) {
return (
<div className="w-full min-h-screen flex bg-grey-300 card-body text-black gap-8">
<header className="flex w-full gap-4 flex-wrap">
<Link href="/">
<h1 className="text-5xl">Comfy-PR</h1>
</Link>
<nav className="flex gap-2 flex-wrap">
<Link href="/details" className="text-2xl">
Details
</Link>
<Link href="/rules" className="text-2xl">
Rules
</Link>
</nav>
</header>
<Header />
<div className="shadow-xl w-full card">
<Suspense>{children}</Suspense>
</div>
</div>
);
}
}
11 changes: 9 additions & 2 deletions app/tasks/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GithubActionUpdateTask } from "@/src/2025-01-20-GithubActionUpdateTask/GithubActionUpdateTask";
import { yaml } from "@/src/utils/yaml";
import Link from "next/link";
import pProps from "p-props";

/**
Expand All @@ -10,5 +10,12 @@ export default async function TasksIndexPage() {
const counts = await pProps({
GithubActionUpdateTask: GithubActionUpdateTask.estimatedDocumentCount(),
});
return <pre>{yaml.stringify(counts)}</pre>;

return (
<ol>
<li>
<Link href="/tasks/GithubActionUpdateTask">GithubActionUpdateTask x {counts.GithubActionUpdateTask}</Link>
</li>
</ol>
);
}

0 comments on commit 36d4e54

Please sign in to comment.