-
Notifications
You must be signed in to change notification settings - Fork 8
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
b38e787
4839d40
f62cc98
ee5b56d
74c8799
b18a36e
b72ee1d
4135388
472d1d5
f3c206d
1b284e9
955e548
14b2fbd
4d5f37f
3962362
e6778e1
bec08b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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' |
| 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' |
| 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' |
| 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' |
| 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' |
| 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' | ||||
|
||||
| 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() | ||||
|
||||
| const router = useRouter() |
| 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' |
| 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' |
| 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 /> | ||
| } |
| 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 /> | ||
| } |
| 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 /> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import i18next from 'i18next' | ||
|
||
| 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> | ||
| ) | ||
| } | ||
| 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' |
| 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' |
| 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 /> | |
| </> | |
| ); |
| 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 /> | ||
| } |
| 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. | ||||||
|
||||||
| // this interceptors will user always have latest data after edit. | |
| // This interceptor ensures users always have the latest data after edit. |
| 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' |
| 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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file correctly imports useRouter from 'next/navigation' for App Router, but the component code imported from '@/components/pages/admin/index' still uses 'next/router'. This creates an inconsistency where the wrapper uses the correct import but the actual component doesn't. Consider migrating the admin index component to use 'next/navigation' or importing it here and passing it as a prop.