Skip to content

Conversation

snomiao
Copy link
Member

@snomiao snomiao commented Aug 9, 2025

pending API for fetching:
/categories/[categoryName]/nodes
/categories node categories

Summary

Implements the admin category dashboard as requested in issue #57.

Changes Made

  • Added Category Management link to AdminTreeNavigation
  • Created comprehensive admin category dashboard at /admin/category
  • Displays all node categories with their respective node counts
  • Added proper breadcrumb navigation and admin layout
  • Updated admin index page to include category management quick action
  • Integrated seamlessly with existing admin dashboard structure

Features

  • Shows categorized view of all nodes with counts
  • Sortable by node count (highest first)
  • Responsive layout with proper admin navigation
  • Handles empty states gracefully
  • Uses existing design patterns and components

Test plan

  • Verify admin authentication is required
  • Check category dashboard loads correctly at /admin/category
  • Confirm categories display with accurate node counts
  • Test navigation between admin sections works properly
  • Validate responsive design on different screen sizes

🤖 Generated with Claude Code

snomiao and others added 2 commits May 7, 2025 16:54
- Add Category Management to AdminTreeNavigation
- Create comprehensive category dashboard at /admin/category
- Display node categories with counts in organized layout
- Add breadcrumb navigation and proper admin layout
- Integrate with existing admin dashboard structure

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings August 9, 2025 10:42
@snomiao snomiao linked an issue Aug 9, 2025 that may be closed by this pull request
3 tasks
Copy link

vercel bot commented Aug 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
registry-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 10, 2025 9:23am

Copilot

This comment was marked as outdated.

Copy link

github-actions bot commented Aug 9, 2025

🎨 Chromatic Visual Testing Results

Resource URL
🔍 Build Results Chromatic Build
📚 Storybook View Storybook

Check the visual changes and approve or request changes as needed.

… pagination

- Renamed admin category page from category.tsx to categories.tsx for consistency
- Implemented server-side pagination using useListAllNodes with page/limit parameters
- Updated navigation links in AdminTreeNavigation and admin index page
- Added CustomPagination component with URL state management
- Removed client-side pagination in favor of API-level pagination

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link

🎨 Chromatic Visual Testing Results

Resource URL
🔍 Build Results Chromatic Build
📚 Storybook View Storybook

Check the visual changes and approve or request changes as needed.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements an admin category dashboard that allows administrators to view and manage node categories. The feature adds a new admin page at /admin/categories that displays all node categories with their respective node counts in a sortable format.

Key Changes

  • Added Category Management navigation link and quick action button in the admin interface
  • Created a comprehensive category dashboard displaying node categories with counts
  • Added internationalization support for the new feature across multiple languages

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

File Description
pages/admin/index.tsx Added Category Management quick action button to admin dashboard
pages/admin/categories.tsx Created new category management page with node category overview
components/admin/AdminTreeNavigation.tsx Added Category Management link to admin navigation tree
locales/*/common.json Added translations for category management features across all supported languages

@@ -72,6 +71,13 @@ function AdminDashboard() {
<HiOutlineCollection className="h-8 w-8 mr-3" />
<span>{t('Manage All Nodes')}</span>
</Link>
<Link
href="/admin/categories"
Copy link
Preview

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The href path '/admin/categories' is inconsistent with the file path 'pages/admin/categories.tsx'. This will result in a 404 error when users click the link.

Suggested change
href="/admin/categories"
href="/admin/Categories"

Copilot uses AI. Check for mistakes.

Comment on lines +31 to +44
const categoriesData = useMemo(() => {
if (!nodesData?.nodes) return []

const categoryMap = new Map<string, number>()
nodesData.nodes.forEach((node) => {
const category = node.category || 'Uncategorized'
categoryMap.set(category, (categoryMap.get(category) || 0) + 1)
})

return Array.from(categoryMap.entries())
.map(([category, count]) => ({ category, count }))
.sort((a, b) => b.count - a.count)
}, [nodesData?.nodes])

Copy link
Preview

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The category calculation processes all nodes on every page, which is inefficient. Consider fetching category data directly from the API or implementing server-side aggregation to avoid processing large datasets on the client.

Suggested change
const categoriesData = useMemo(() => {
if (!nodesData?.nodes) return []
const categoryMap = new Map<string, number>()
nodesData.nodes.forEach((node) => {
const category = node.category || 'Uncategorized'
categoryMap.set(category, (categoryMap.get(category) || 0) + 1)
})
return Array.from(categoryMap.entries())
.map(([category, count]) => ({ category, count }))
.sort((a, b) => b.count - a.count)
}, [nodesData?.nodes])
// Fetch pre-aggregated category data from the API
const { data: categoriesData } = useListCategoriesWithCounts()

Copilot uses AI. Check for mistakes.

.sort((a, b) => b.count - a.count)
}, [nodesData?.nodes])

const totalPages = Math.ceil((nodesData?.total || 0) / limit)
Copy link
Preview

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pagination logic is incorrect. The totalPages calculation is based on total nodes, but the displayed data is categories. This will show incorrect pagination when the number of categories differs from the number of nodes.

Copilot uses AI. Check for mistakes.

Replace manual URL query handling with reusable usePage hook for cleaner pagination management.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link

🎨 Chromatic Visual Testing Results

Resource URL
🔍 Build Results Chromatic Build
📚 Storybook View Storybook

Check the visual changes and approve or request changes as needed.

@snomiao snomiao marked this pull request as draft August 12, 2025 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat req: admin category dashboard /admin/category/
1 participant