-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Migrate from pages directory to app router #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
snomiao
wants to merge
20
commits into
main
Choose a base branch
from
sno-migrate-app-router
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b38e787
feat: Migrate from pages directory to app router
snomiao 4839d40
fix: Remove conflicting pages directory files after app router migration
snomiao f62cc98
Merge remote-tracking branch 'origin/main' into sno-migrate-app-router
snomiao ee5b56d
fix: Complete app router migration by moving page components and addi…
snomiao 74c8799
format: Apply prettier --fix changes
snomiao b18a36e
fix: Address Copilot review comments - fix comment and import paths
snomiao b72ee1d
Merge branch 'main' into sno-migrate-app-router
snomiao 4135388
fix: Use @ alias for imports in app/providers.tsx
snomiao 472d1d5
fix: Remove unused i18next import from app/layout.tsx
snomiao f3c206d
format: Apply prettier --fix changes
snomiao 1b284e9
Merge branch 'main' into sno-migrate-app-router
snomiao 955e548
docs: Add TODO comment for singletonRouter migration
snomiao 14b2fbd
refactor: Migrate node pages to proper App Router structure
snomiao 4d5f37f
refactor: Migrate publisher pages to proper App Router structure
snomiao 3962362
feat: Add App Router version of useRouterQuery hook
snomiao e6778e1
refactor: Remove migrated page components from components/pages
snomiao bec08b9
refactor: Move components/pages into app directory
snomiao 3172d3b
fix: Address Copilot review comments and fix build errors
snomiao d6fee20
chore: Resolve merge conflicts with main
snomiao 63ca204
format: Apply prettier --fix changes
snomiao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/admin/add-unclaimed-node' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/admin/claim-nodes' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/admin/node-version-compatibility' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/admin/nodes' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/admin/nodeversions' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| 'use client' | ||
|
|
||
| import { Breadcrumb } from 'flowbite-react' | ||
| import Link from 'next/link' | ||
| import { useRouter } from 'next/navigation' | ||
snomiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import { | ||
| HiHome, | ||
| HiOutlineAdjustments, | ||
| HiOutlineClipboardCheck, | ||
| HiOutlineCollection, | ||
| } from 'react-icons/hi' | ||
| import AdminTreeNavigation from '@/components/admin/AdminTreeNavigation' | ||
| import withAdmin from '@/components/common/HOC/authAdmin' | ||
| import { useNextTranslation } from '@/src/hooks/i18n' | ||
|
|
||
| function AdminDashboard() { | ||
| const router = useRouter() | ||
snomiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
snomiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const { t } = useNextTranslation() | ||
|
|
||
| return ( | ||
| <div className="p-4"> | ||
| <Breadcrumb className="py-4"> | ||
| <Breadcrumb.Item href="/" icon={HiHome} className="dark"> | ||
| {t('Home')} | ||
| </Breadcrumb.Item> | ||
| <Breadcrumb.Item href="#" className="dark"> | ||
| {t('Admin Dashboard')} | ||
| </Breadcrumb.Item> | ||
| </Breadcrumb> | ||
|
|
||
| <h1 className="text-2xl font-bold text-gray-200 mb-6"> | ||
| {t('Admin Dashboard')} | ||
| </h1> | ||
|
|
||
| <div className="grid grid-cols-1 lg:grid-cols-4 gap-6"> | ||
| <div className="lg:col-span-1"> | ||
| <AdminTreeNavigation /> | ||
| </div> | ||
|
|
||
| <div className="lg:col-span-3"> | ||
| <div className="bg-gray-800 rounded-lg p-6"> | ||
| <h2 className="text-xl font-semibold text-gray-200 mb-4"> | ||
| {t('Quick Actions')} | ||
| </h2> | ||
| <div className="grid grid-cols-1 md:grid-cols-2 gap-4"> | ||
| <Link | ||
| href="/admin/search-ranking" | ||
| className="bg-blue-600 hover:bg-blue-700 text-white rounded-lg p-4 flex items-center transition-colors" | ||
| > | ||
| <HiOutlineAdjustments className="h-8 w-8 mr-3" /> | ||
| <span>{t('Search Ranking Table')}</span> | ||
| </Link> | ||
| <Link | ||
| href="/admin/nodeversions?filter=flagged" | ||
| className="bg-yellow-600 hover:bg-yellow-700 text-white rounded-lg p-4 flex items-center transition-colors" | ||
| > | ||
| <HiOutlineClipboardCheck className="h-8 w-8 mr-3" /> | ||
| <span>{t('Review Flagged Versions')}</span> | ||
| </Link> | ||
| <Link | ||
| href="/admin/claim-nodes" | ||
| className="bg-green-600 hover:bg-green-700 text-white rounded-lg p-4 flex items-center transition-colors" | ||
| > | ||
| <HiOutlineCollection className="h-8 w-8 mr-3" /> | ||
| <span>{t('Manage Unclaimed Nodes')}</span> | ||
| </Link> | ||
| <Link | ||
| href="/admin/nodes" | ||
| className="bg-purple-600 hover:bg-purple-700 text-white rounded-lg p-4 flex items-center transition-colors" | ||
| > | ||
| <HiOutlineCollection className="h-8 w-8 mr-3" /> | ||
| <span>{t('Manage All Nodes')}</span> | ||
| </Link> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| const WrappedAdminDashboard = withAdmin(AdminDashboard) | ||
|
|
||
| export default function Page() { | ||
| return <WrappedAdminDashboard /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/admin/preempted-comfy-node-names' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/admin/search-ranking' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import React from 'react' | ||
| import SignIn from '@/components/AuthUI/AuthUI' | ||
|
|
||
| export default function SignInPage() { | ||
| return <SignIn /> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import React from 'react' | ||
| import Logout from '@/components/AuthUI/Logout' | ||
|
|
||
| export default function LogoutPage() { | ||
| return <Logout /> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import React from 'react' | ||
| import SignIn from '@/components/AuthUI/AuthUI' | ||
|
|
||
| export default function SignUpPage() { | ||
| return <SignIn /> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import i18next from 'i18next' | ||
snomiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import { Metadata } from 'next' | ||
| import { Providers } from './providers' | ||
| import '../styles/globals.css' | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: 'ComfyUI Registry', | ||
| description: 'Discover and install ComfyUI custom nodes.', | ||
| icons: { | ||
| icon: '/favicon.ico', | ||
| }, | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' | ||
|
|
||
| export default function RootLayout({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode | ||
| }) { | ||
| // Default to 'en', will be handled by i18n middleware/client-side detection | ||
| const locale = 'en' | ||
| const dir = i18next.dir(locale) | ||
|
|
||
| return ( | ||
| <html lang={locale} dir={dir}> | ||
| <body> | ||
| <Providers>{children}</Providers> | ||
| </body> | ||
| </html> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/nodes/claim' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/nodes/[nodeId]' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||||||||
| import Registry from '@/components/registry/Registry' | ||||||||||||||||
|
|
||||||||||||||||
| export default function NodeList() { | ||||||||||||||||
| return <Registry /> | ||||||||||||||||
|
||||||||||||||||
| return <Registry /> | |
| return ( | |
| <> | |
| <h1>Node List</h1> | |
| <Registry /> | |
| </> | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import Registry from '@/components/registry/Registry' | ||
|
|
||
| export default function Home() { | ||
| return <Registry /> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| 'use client' | ||
|
|
||
| import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister' | ||
| import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
| import { persistQueryClient } from '@tanstack/react-query-persist-client' | ||
| import { AxiosResponse } from 'axios' | ||
| import { getAuth } from 'firebase/auth' | ||
| import { ThemeModeScript } from 'flowbite-react' | ||
| import { useEffect, useState } from 'react' | ||
| import { ToastContainer } from 'react-toastify' | ||
| import 'react-toastify/dist/ReactToastify.css' | ||
| import { DIE } from 'phpdie' | ||
| import { AXIOS_INSTANCE } from '@/src/api/mutator/axios-instance' | ||
| import app from '@/src/firebase' | ||
| import FlowBiteThemeProvider from '../components/flowbite-theme' | ||
| import Layout from '../components/layout' | ||
|
|
||
| // Add an interceptor to attach the Firebase JWT token to every request | ||
| AXIOS_INSTANCE.interceptors.request.use(async (config) => { | ||
| const auth = getAuth(app) | ||
| const user = auth.currentUser | ||
| if (user) { | ||
| const token = await user.getIdToken() | ||
| sessionStorage.setItem('idToken', token) | ||
| config.headers.Authorization = `Bearer ${token}` | ||
| } else { | ||
| const cachedIdtoken = sessionStorage.getItem('idToken') ?? '' | ||
| if (cachedIdtoken) config.headers.Authorization = `Bearer ${cachedIdtoken}` | ||
| } | ||
| return config | ||
| }) | ||
|
|
||
| const createQueryClient = () => | ||
| new QueryClient({ | ||
| defaultOptions: { | ||
| queries: { | ||
| retry: (failureCount, error: any) => { | ||
| // Don't retry on 404s | ||
| if (error?.response?.status === 404) return false | ||
|
|
||
| // Retry up to 3 times for other errors | ||
| return failureCount < 3 | ||
| }, | ||
| staleTime: 0, // set to 0 to always query fresh data when page refreshed, and render staled data while requesting (swr) | ||
| gcTime: 86400e3, | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| export function Providers({ children }: { children: React.ReactNode }) { | ||
| const [queryClient] = useState(() => createQueryClient()) | ||
|
|
||
| useEffect(() => { | ||
| // General localStorage cache invalidation for all endpoints | ||
| // this interceptors will user always have latest data after edit. | ||
snomiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const responseInterceptor = AXIOS_INSTANCE.interceptors.response.use( | ||
| function onSuccess(response: AxiosResponse) { | ||
| const req = response.config | ||
| if (!req.url) return response | ||
|
|
||
| const baseURL = | ||
| req.baseURL ?? | ||
| globalThis.location.origin ?? | ||
| DIE('Remember to fill window.location when testing axios') | ||
| const pathname = new URL(req.url, baseURL).pathname | ||
|
|
||
| const isCreateMethod = ['POST'].includes( | ||
| req.method!.toUpperCase() ?? '' | ||
| ) | ||
| const isEditMethod = ['PUT', 'PATCH', 'DELETE'].includes( | ||
| req.method!.toUpperCase() ?? '' | ||
| ) | ||
|
|
||
| if (isCreateMethod) { | ||
| queryClient.invalidateQueries({ queryKey: [pathname] }) | ||
| } | ||
| if (isEditMethod) { | ||
| queryClient.invalidateQueries({ queryKey: [pathname] }) | ||
| queryClient.invalidateQueries({ | ||
| queryKey: [pathname.split('/').slice(0, -1).join('/')], | ||
| }) | ||
| } | ||
| return response | ||
| }, | ||
| (error) => { | ||
| return Promise.reject(error) | ||
| } | ||
| ) | ||
|
|
||
| // Persist query client | ||
| const [unsubscribe] = persistQueryClient({ | ||
| queryClient: queryClient as any, | ||
| persister: createSyncStoragePersister({ | ||
| storage: window.localStorage, | ||
| key: 'comfy-registry-cache', | ||
| }), | ||
| // Only persist queries with these query keys | ||
| dehydrateOptions: { | ||
| shouldDehydrateQuery: ({ queryKey, state }) => { | ||
| // Don't persist pending queries as they can't be properly restored | ||
| if (state.status === 'pending') return false | ||
|
|
||
| // Persist all queries in localStorage, share across tabs | ||
| return true | ||
| }, | ||
| }, | ||
| maxAge: 86400e3, // 1 day in milliseconds | ||
| buster: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA ?? 'v1', | ||
| }) | ||
|
|
||
| return () => { | ||
| AXIOS_INSTANCE.interceptors.response.eject(responseInterceptor) | ||
| unsubscribe() | ||
| } | ||
| }, [queryClient]) | ||
|
|
||
| return ( | ||
| <QueryClientProvider client={queryClient}> | ||
| <ThemeModeScript /> | ||
| <FlowBiteThemeProvider> | ||
| <Layout>{children}</Layout> | ||
| <ToastContainer /> | ||
| </FlowBiteThemeProvider> | ||
| </QueryClientProvider> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/publishers/claim-my-node' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import Component from '@/components/pages/publishers/[nodeId]' | ||
|
|
||
| export default function Page() { | ||
| return <Component /> | ||
| } | ||
|
|
||
| export const dynamic = 'force-dynamic' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.