feat: add delete post to Agent Plaza (admin + author)#136
feat: add delete post to Agent Plaza (admin + author)#136yaojin3616 merged 4 commits intodataelement:mainfrom
Conversation
Backend:
- Add DELETE /api/plaza/posts/{post_id} endpoint
- platform_admin and org_admin can delete any post
- Post author can delete their own post
- Returns 403 if neither condition is met
- Cascade delete handled by existing SQLAlchemy relationship
Frontend:
- Add deletePost mutation with proper Bearer token auth
- Show 🗑 delete button on posts visible to admins or the post author
- Confirm dialog before deletion to prevent accidental deletes
- Button styled with red hover state, unobtrusive by default
- Invalidates plaza-posts and plaza-stats queries on success
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
wisdomqin
left a comment
There was a problem hiding this comment.
Thanks for this contribution! The feature logic and permission model are solid. A few things to address before merging:
Backend
- Add audit logging — Delete is a destructive action. Consider adding a
logger.infoline recording who deleted which post, especially for admin deletions. Example:logger.info(f"Plaza post {post_id} deleted by user {current_user.id} (admin={is_admin})")
Frontend
-
Replace emoji with SVG icon — The
🗑emoji is inconsistent with the rest of the UI which uses SVG icons (Icons.heart,Icons.comment). Please add a trash icon to the Icons object and use it here. -
Replace
window.confirmwith a styled dialog — The native browser confirm dialog breaks the visual consistency of the app (we follow a Linear-style dark theme). Please use a custom confirmation modal or at minimum a styled dialog component. -
Move inline hover logic to CSS — The
onMouseEnter/onMouseLeavepattern for hover effects is fragile. Use a CSS class with:hoverpseudo-selector instead:.delete-btn { opacity: 0.6; color: var(--text-muted); } .delete-btn:hover { opacity: 1; color: #ef4444; }
-
Add i18n support — The project uses
react-i18next. Hardcoded strings like"Delete this post?"and"Delete post"should use translation keys (e.g.t('plaza.deleteConfirm')).
Please address these items and I'll be happy to approve. The backend logic itself looks great!
- Backend: add audit logging for post deletion - Frontend: replace emoji with SVG icon - Frontend: replace window.confirm with styled ConfirmModal - Frontend: move inline hover to CSS class - Frontend: add i18n support for delete modal - Frontend: add i18n translations (en/zh)
Summary
Agent Plaza currently has no way to remove posts. This adds a delete feature with proper permission checks.
Changes
Backend —
backend/app/api/plaza.pyDELETE /api/plaza/posts/{post_id}endpointplatform_adminandorg_admincan delete any post403if neither condition is metPlazaPostrelationshipFrontend —
frontend/src/pages/Plaza.tsxdeletePostmutation using authenticatedfetchwith Bearer tokenplaza-postsandplaza-statsqueries on success so counts update immediatelyTest plan
🤖 Generated with Claude Code