Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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 Oct 26, 2025
4839d40
fix: Remove conflicting pages directory files after app router migration
snomiao Oct 26, 2025
f62cc98
Merge remote-tracking branch 'origin/main' into sno-migrate-app-router
snomiao Oct 26, 2025
ee5b56d
fix: Complete app router migration by moving page components and addi…
snomiao Oct 26, 2025
74c8799
format: Apply prettier --fix changes
snomiao Oct 26, 2025
b18a36e
fix: Address Copilot review comments - fix comment and import paths
snomiao Oct 26, 2025
b72ee1d
Merge branch 'main' into sno-migrate-app-router
snomiao Oct 29, 2025
4135388
fix: Use @ alias for imports in app/providers.tsx
snomiao Oct 29, 2025
472d1d5
fix: Remove unused i18next import from app/layout.tsx
snomiao Oct 29, 2025
f3c206d
format: Apply prettier --fix changes
snomiao Oct 29, 2025
1b284e9
Merge branch 'main' into sno-migrate-app-router
snomiao Oct 30, 2025
955e548
docs: Add TODO comment for singletonRouter migration
snomiao Oct 30, 2025
14b2fbd
refactor: Migrate node pages to proper App Router structure
snomiao Oct 30, 2025
4d5f37f
refactor: Migrate publisher pages to proper App Router structure
snomiao Oct 30, 2025
3962362
feat: Add App Router version of useRouterQuery hook
snomiao Oct 30, 2025
e6778e1
refactor: Remove migrated page components from components/pages
snomiao Oct 30, 2025
bec08b9
refactor: Move components/pages into app directory
snomiao Nov 4, 2025
3172d3b
fix: Address Copilot review comments and fix build errors
snomiao Nov 10, 2025
d6fee20
chore: Resolve merge conflicts with main
snomiao Nov 10, 2025
63ca204
format: Apply prettier --fix changes
snomiao Nov 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ See [docs/chromatic-setup.md](docs/chromatic-setup.md) for more details on our C
#### Update PR Branches

We provide a GitHub Actions workflow to automatically update open PR branches with the latest changes from `main`. This is useful for:

- Keeping long-running PRs up-to-date
- Reducing merge conflicts
- Repository maintenance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use client'
import { Breadcrumb } from 'flowbite-react'
import { useRouter } from 'next/router'
import { useRouter } from 'next/navigation'
import { HiHome } from 'react-icons/hi'
import withAdmin from '@/components/common/HOC/authAdmin'
import { AdminCreateNodeFormModal } from '@/components/nodes/AdminCreateNodeFormModal'
import { useNextTranslation } from '@/src/hooks/i18n'

export default withAdmin(AddUnclaimedNodePage)

function AddUnclaimedNodePage() {
const { t } = useNextTranslation()
const router = useRouter()
Expand Down Expand Up @@ -53,3 +52,9 @@ function AddUnclaimedNodePage() {
</div>
)
}

// TODO: Re-enable withAdmin after migrating HOC to App Router
// const Wrapped = withAdmin(AddUnclaimedNodePage)
export default AddUnclaimedNodePage

export const dynamic = 'force-dynamic'
27 changes: 17 additions & 10 deletions pages/admin/claim-nodes.tsx → app/admin/claim-nodes/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client'
import { useQueryClient } from '@tanstack/react-query'
import { Breadcrumb, Button, Spinner } from 'flowbite-react'
import { useRouter } from 'next/router'
import { useRouter, useSearchParams } from 'next/navigation'
import { HiHome, HiPlus } from 'react-icons/hi'
import { CustomPagination } from '@/components/common/CustomPagination'
import withAdmin from '@/components/common/HOC/authAdmin'
Expand All @@ -12,27 +13,26 @@ import {
import { UNCLAIMED_ADMIN_PUBLISHER_ID } from '@/src/constants'
import { useNextTranslation } from '@/src/hooks/i18n'

export default withAdmin(ClaimNodesPage)
function ClaimNodesPage() {
const { t } = useNextTranslation()
const router = useRouter()
const searchParams = useSearchParams()
const queryClient = useQueryClient()
const pageSize = 36

// Get page from URL query params, defaulting to 1
const currentPage = router.query.page
? parseInt(router.query.page as string, 10)
const currentPage = searchParams?.get('page')
? parseInt(searchParams?.get('page')!, 10)
: 1

const handlePageChange = (page: number) => {
// Update URL with new page parameter
router.push(
{ pathname: router.pathname, query: { ...router.query, page } },
undefined,
{ shallow: true }
)
const params = new URLSearchParams(searchParams?.toString())
params.set('page', page.toString())
router.push(`/admin/claim-nodes?${params.toString()}`)
}

// Use the page from router.query for the API call
// Use the page from searchParams for the API call
const { data, isError, isLoading } = useListNodesForPublisherV2(
UNCLAIMED_ADMIN_PUBLISHER_ID,
{ page: currentPage, limit: pageSize }
Expand Down Expand Up @@ -147,3 +147,10 @@ function ClaimNodesPage() {
</div>
)
}

// TODO: Re-enable withAdmin after migrating HOC to App Router
// const Wrapped = withAdmin(ClaimNodesPage)

export default ClaimNodesPage

export const dynamic = 'force-dynamic'
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import { useQueryClient } from '@tanstack/react-query'
import clsx from 'clsx'
import {
Expand All @@ -12,7 +13,7 @@ import {
TextInput,
Tooltip,
} from 'flowbite-react'
import router from 'next/router'
import { useRouter } from 'next/navigation'
import DIE, { DIES } from 'phpdie'
import React, { Suspense, useEffect, useMemo, useState } from 'react'
import { HiHome } from 'react-icons/hi'
Expand Down Expand Up @@ -50,10 +51,9 @@ import { useSearchParameter } from '@/src/hooks/useSearchParameter'
import { NodeVersionStatusToReadable } from '@/src/mapper/nodeversion'

// This page allows admins to update node version compatibility fields
export default withAdmin(NodeVersionCompatibilityAdmin)

function NodeVersionCompatibilityAdmin() {
const { t } = useNextTranslation()
const router = useRouter()
const [_page, setPage] = usePage()

// search
Expand Down Expand Up @@ -636,3 +636,10 @@ function isNodeCompatibilityInfoOutdated(node: Node | null) {
false
)
}

// TODO: Re-enable withAdmin after migrating HOC to App Router
// const Wrapped = withAdmin(NodeVersionCompatibilityAdmin)

export default NodeVersionCompatibilityAdmin

export const dynamic = 'force-dynamic'
92 changes: 47 additions & 45 deletions pages/admin/nodes.tsx → app/admin/nodes/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import { useQueryClient } from '@tanstack/react-query'
import clsx from 'clsx'
import {
Expand All @@ -10,9 +11,9 @@ import {
TextInput,
} from 'flowbite-react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useRouter, useSearchParams } from 'next/navigation'
import { omit } from 'rambda'
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import { HiHome, HiOutlineX, HiPencil } from 'react-icons/hi'
import { MdOpenInNew } from 'react-icons/md'
import { toast } from 'react-toastify'
Expand All @@ -32,6 +33,7 @@ import { useNextTranslation } from '@/src/hooks/i18n'
function NodeList() {
const { t } = useNextTranslation()
const router = useRouter()
const searchParams = useSearchParams()
const [page, setPage] = React.useState<number>(1)
const [editingNode, setEditingNode] = useState<Node | null>(null)
const [editFormData, setEditFormData] = useState({
Expand All @@ -44,10 +46,11 @@ function NodeList() {

// Handle page from URL
React.useEffect(() => {
if (router.query.page) {
setPage(parseInt(router.query.page as string))
const pageParam = searchParams?.get('page')
if (pageParam) {
setPage(parseInt(pageParam))
}
}, [router.query.page])
}, [searchParams])

// Status filter functionality
const statusFlags = {
Expand All @@ -73,7 +76,7 @@ function NodeList() {
const allStatuses = [...Object.values(statusFlags)].sort()

const defaultSelectedStatuses = [
(router.query as any)?.status ?? Object.keys(statusFlags),
searchParams?.get('status') ?? Object.keys(statusFlags),
]
.flat()
.map((status) => statusFlags[status])
Expand All @@ -91,29 +94,28 @@ function NodeList() {
const checkedAll =
allStatuses.join(',').toString() ===
[...statuses].sort().join(',').toString()
const searchParams = checkedAll
? undefined
: ({
status: Object.entries(statusFlags)
.filter(([status, s]) => statuses.includes(s))
.map(([status]) => status),
} as any)
const search = new URLSearchParams({
...(omit('status')(router.query) as object),
...searchParams,
})
.toString()
.replace(/^(?!$)/, '?')
const hash = router.asPath.split('#')[1]
? `#${router.asPath.split('#')[1]}`
: ''
router.push(`${router.pathname}${search}${hash}`)

const params = new URLSearchParams(searchParams?.toString())

if (!checkedAll) {
// Remove existing status params
params.delete('status')
// Add new status params
Object.entries(statusFlags)
.filter(([status, s]) => statuses.includes(s))
.forEach(([status]) => {
params.append('status', status)
})
} else {
params.delete('status')
}

const hash = window.location.hash
router.push(`/admin/nodes?${params.toString()}${hash}`)
}

// Search filter
const queryForNodeId = Array.isArray(router.query.nodeId)
? router.query.nodeId[0]
: router.query.nodeId
const queryForNodeId = searchParams?.get('nodeId')

const getAllNodesQuery = useListAllNodes({
page: page,
Expand Down Expand Up @@ -163,14 +165,9 @@ function NodeList() {

const handlePageChange = (newPage: number) => {
setPage(newPage)
router.push(
{
pathname: router.pathname,
query: { ...router.query, page: newPage },
},
undefined,
{ shallow: true }
)
const params = new URLSearchParams(searchParams?.toString())
params.set('page', newPage.toString())
router.push(`/admin/nodes?${params.toString()}`)
}

const openEditModal = (node: Node) => {
Expand Down Expand Up @@ -305,16 +302,16 @@ function NodeList() {
'filter-node-id'
) as HTMLInputElement
const nodeId = inputElement.value.trim()
const searchParams = new URLSearchParams({
...(omit(['nodeId'])(router.query) as object),
...(nodeId ? { nodeId } : {}),
})
.toString()
.replace(/^(?!$)/, '?')
const hash = router.asPath.split('#')[1]
? `#${router.asPath.split('#')[1]}`
: ''
router.push(router.pathname + searchParams + hash)
const params = new URLSearchParams(searchParams?.toString())

if (nodeId) {
params.set('nodeId', nodeId)
} else {
params.delete('nodeId')
}

const hash = window.location.hash
router.push(`/admin/nodes?${params.toString()}${hash}`)
}}
>
<TextInput
Expand Down Expand Up @@ -656,4 +653,9 @@ function NodeList() {
)
}

export default withAdmin(NodeList)
// TODO: Re-enable withAdmin after migrating HOC to App Router
// const Wrapped = withAdmin(NodeList)

export default NodeList

export const dynamic = 'force-dynamic'
Loading