# Proposal: Add Delete Capability for Spaces and Projects ## Summary Enable users to delete workspaces (spaces) and projects from the frontend UI. The backend already supports soft deletion, but the frontend lacks the necessary UI components and service functions. ## Problem Statement Currently, users cannot delete spaces or projects from the UI even though: 1. Backend DELETE endpoints exist (`DELETE /spaces/{id}`, `DELETE /projects/{id}`) 2. Both implement soft-delete (setting `is_active = False`) 3. Project deletion includes audit logging Users must access the database directly or use API tools to delete items, which is not user-friendly. ## Proposed Solution Add frontend UI components and service functions to enable deletion: 1. **Frontend Services**: Add `deleteSpace()` and `deleteProject()` functions 2. **Spaces Page**: Add delete button with confirmation dialog 3. **Projects Page**: Add delete button with confirmation dialog 4. **Translations**: Add i18n strings for delete UI elements ## Scope ### In Scope - Delete button UI for spaces (owner only) - Delete button UI for projects (owner only) - Confirmation dialogs with clear warning messages - i18n translations (zh-TW, en) - Audit trail (already implemented in backend for projects) ### Out of Scope - Hard delete (permanent removal from database) - Restore/undelete functionality - Cascading delete behavior changes (current soft-delete preserves child items) - Bulk delete operations ## Impact Analysis ### Affected Components | Component | Change Type | Description | |-----------|-------------|-------------| | `frontend/src/services/spaces.ts` | NEW | Add deleteSpace function | | `frontend/src/services/projects.ts` | MODIFY | Add deleteProject function | | `frontend/src/pages/Spaces.tsx` | MODIFY | Add delete button and dialog | | `frontend/src/pages/Projects.tsx` | MODIFY | Add delete button and dialog | | `frontend/public/locales/*/spaces.json` | MODIFY | Add delete translations | | `frontend/public/locales/*/projects.json` | MODIFY | Add delete translations | ### Dependencies - Backend DELETE endpoints (already implemented) - Audit service (already integrated for project deletion) - ToastContext for success/error notifications (already available) ## Risks & Mitigations | Risk | Likelihood | Impact | Mitigation | |------|------------|--------|------------| | Accidental deletion | Medium | High | Require typed confirmation for spaces with projects | | Permission confusion | Low | Medium | Clear "owner only" messaging | ## Success Criteria 1. Space owner can delete empty spaces with confirmation 2. Space owner can delete spaces with projects (with strong warning) 3. Project owner can delete projects with confirmation 4. All deletions are logged in audit trail 5. UI shows appropriate error messages for non-owners