Feature/blog cms admin UI#11
Open
vH192Hv wants to merge 10 commits into
Open
Conversation
- Add Post model with title, slug, content, excerpt, coverImage, status, timestamps - Add Tag model with name and slug - Add PostTag join table for many-to-many relationship - Add PostStatus enum (DRAFT, PUBLISHED, ARCHIVED) - Add posts relation to User model Co-Authored-By: Claude <noreply@anthropic.com>
- Add seedBlogPosts function with sample posts and tags - Register seed in main.wasp.ts db.seeds array Co-Authored-By: Claude <noreply@anthropic.com>
- Define getAllPosts, getPost, getPostBySlug, getPublishedPosts queries - Define createPost, updatePost, deletePost actions - Define getAllTags, createTag, deleteTag tag operations - Register blogCmsSpec in main.wasp.ts Co-Authored-By: Claude <noreply@anthropic.com>
- Add isValidSlug, generateSlug with regex format + length checks - Add ALLOWED_TRANSITIONS map and transition validation helpers - File is browser+server safe (no wasp/server imports) Co-Authored-By: Claude <noreply@anthropic.com>
…rmissions) - Post queries: getAllPosts (admin, paginated, filters), getPost (admin, by ID), getPostBySlug (public, PUBLISHED only), getPublishedPosts (public, paginated) - Post mutations: createPost (slug gen/validate, status validation), updatePost (status transitions, tag replacement, publishedAt mgmt), deletePost (by ID with existence check) - Tag operations: getAllTags (with post count), createTag (name/slug uniqueness), deleteTag (cascade removes PostTag entries) - Permission guard: requireAdmin on all mutating + admin-read operations - Slug helpers imported from shared utils.ts - Status transitions validated via isAllowedTransition from utils.ts Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…tion Co-Authored-By: Claude <noreply@anthropic.com>
- Auto-generates slug from title (overridable), imports from shared utils.ts - Content field as Markdown textarea - TagSelector integration for multi-select tags - Status segmented control with valid transitions from getAllowedTransitions() - onCancel/onDelete callbacks for parent-controlled navigation - Delete confirmation dialog - Field-level validation errors Co-Authored-By: Claude <noreply@anthropic.com>
- BlogPostsPage: table view with pagination, search (debounced), status/tag filters - PostEditorPage: create/edit form with tag management, navigation callbacks - Both use DefaultLayout+user prop and Breadcrumb per admin conventions - Imports operations from wasp/client/operations Co-Authored-By: Claude <noreply@anthropic.com>
- Add AdminBlogRoute (/admin/blog) for post list - Add AdminBlogNewRoute (/admin/blog/new) for creating posts - Add AdminBlogEditRoute (/admin/blog/:id/edit) for editing posts - Add Blog nav item with FileText icon in admin sidebar Co-Authored-By: Claude <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
设计方案
页面路由
/admin/blogBlogPostsPage/admin/blog/newPostEditorPage/admin/blog/:id/editPostEditorPage组件架构
关键实现细节
BlogPostsPage:
useDebounce, 300ms),与UsersTable一致wasp/client/operations导入操作函数user: AuthUserprop,传入DefaultLayoutPostEditorPage:
:id区分 create/edit 模式useQuery(getPost, { enabled: isEditing })条件加载handleCreateTag捕获错误并打印日志PostForm:
generateSlug()从utils.ts导入(浏览器安全)getAllowedTransitions()限制状态选项onCancel/onDelete回调 → 父组件控制导航TagSelector:
PostStatusBadge:
bg-*-100,text-*-800)侧边栏导航
在 admin sidebar MENU 区添加 "Blog" 导航项(FileText 图标),位于 Users 和 Settings 之间。
执行方案
PostStatusBadge.tsx组件TagSelector.tsx组件PostForm.tsx共享表单组件BlogPostsPage.tsx列表页PostEditorPage.tsx编辑页admin.wasp.ts注册 3 条路由Sidebar.tsx添加 Blog 导航项文件变更
template/app/src/blog-cms/BlogPostsPage.tsxtemplate/app/src/blog-cms/PostEditorPage.tsxtemplate/app/src/blog-cms/components/PostForm.tsxtemplate/app/src/blog-cms/components/TagSelector.tsxtemplate/app/src/blog-cms/components/PostStatusBadge.tsxtemplate/app/src/admin/admin.wasp.tstemplate/app/src/admin/layout/Sidebar.tsx🔽 依赖 PR2 (operations) — 合并顺序第 3(与 PR4 并行)