feat: implement soft delete, task editing fixes, and UI improvements
Backend: - Add soft delete for spaces and projects (is_active flag) - Add status_id and assignee_id to TaskUpdate schema - Fix task PATCH endpoint to update status and assignee - Add validation for assignee_id and status_id in task updates - Fix health service to count tasks with "Blocked" status as blockers - Filter out deleted spaces/projects from health dashboard - Add workload cache invalidation on assignee changes Frontend: - Add delete confirmation dialogs for spaces and projects - Fix UserSelect to display selected user name (valueName prop) - Fix task detail modal to refresh data after save - Enforce 2-level subtask depth limit in UI - Fix timezone bug in date formatting (use local timezone) - Convert NotificationBell from Tailwind to inline styles - Add i18n translations for health, workload, settings pages - Add parent_task_id to Task interface across components OpenSpec: - Archive add-delete-capability change 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
# 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
|
||||
@@ -0,0 +1,64 @@
|
||||
# Task Management - Delete Capability Delta
|
||||
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Space Deletion
|
||||
系統 SHALL 允許空間擁有者刪除空間(軟刪除)。
|
||||
|
||||
#### Scenario: 刪除空白空間
|
||||
- **GIVEN** 使用者是空間的擁有者
|
||||
- **AND** 空間內沒有任何專案
|
||||
- **WHEN** 使用者點擊刪除按鈕並確認
|
||||
- **THEN** 系統將空間標記為已刪除 (is_active = false)
|
||||
- **AND** 空間不再顯示於列表中
|
||||
- **AND** 顯示成功通知
|
||||
|
||||
#### Scenario: 刪除含專案的空間
|
||||
- **GIVEN** 使用者是空間的擁有者
|
||||
- **AND** 空間內包含一個或多個專案
|
||||
- **WHEN** 使用者點擊刪除按鈕
|
||||
- **THEN** 系統顯示警告對話框,說明包含 N 個專案
|
||||
- **AND** 要求使用者輸入空間名稱以確認刪除
|
||||
- **WHEN** 使用者正確輸入名稱並確認
|
||||
- **THEN** 系統將空間標記為已刪除
|
||||
- **AND** 空間內的專案同時被軟刪除
|
||||
- **AND** 顯示成功通知
|
||||
|
||||
#### Scenario: 非擁有者無法刪除空間
|
||||
- **GIVEN** 使用者不是空間的擁有者
|
||||
- **WHEN** 使用者嘗試刪除空間
|
||||
- **THEN** 系統拒絕操作
|
||||
- **AND** 顯示權限不足的錯誤訊息
|
||||
|
||||
### Requirement: Project Deletion
|
||||
系統 SHALL 允許專案擁有者刪除專案(軟刪除),並記錄於稽核日誌。
|
||||
|
||||
#### Scenario: 刪除專案
|
||||
- **GIVEN** 使用者是專案的擁有者
|
||||
- **WHEN** 使用者點擊刪除按鈕
|
||||
- **THEN** 系統顯示確認對話框,說明專案內的任務數量
|
||||
- **WHEN** 使用者確認刪除
|
||||
- **THEN** 系統將專案標記為已刪除 (is_active = false)
|
||||
- **AND** 專案不再顯示於空間的專案列表中
|
||||
- **AND** 系統記錄刪除事件至稽核日誌
|
||||
- **AND** 顯示成功通知
|
||||
|
||||
#### Scenario: 非擁有者無法刪除專案
|
||||
- **GIVEN** 使用者不是專案的擁有者
|
||||
- **WHEN** 使用者嘗試刪除專案
|
||||
- **THEN** 系統拒絕操作
|
||||
- **AND** 顯示權限不足的錯誤訊息
|
||||
|
||||
#### Scenario: 刪除專案的稽核記錄
|
||||
- **GIVEN** 專案擁有者刪除專案
|
||||
- **WHEN** 刪除操作完成
|
||||
- **THEN** 稽核日誌記錄以下資訊:
|
||||
- event_type: "project.delete"
|
||||
- resource_type: "project"
|
||||
- action: DELETE
|
||||
- user_id: 執行刪除的使用者
|
||||
- resource_id: 被刪除的專案 ID
|
||||
- changes: [{ field: "is_active", old_value: true, new_value: false }]
|
||||
|
||||
## Cross-references
|
||||
- Relates to: `audit-trail` spec (project deletion triggers audit event)
|
||||
@@ -0,0 +1,55 @@
|
||||
# Tasks: Add Delete Capability
|
||||
|
||||
## Task List
|
||||
|
||||
### Phase 1: Frontend Services
|
||||
- [x] **T1**: Create `frontend/src/services/spaces.ts` with CRUD operations including `deleteSpace()`
|
||||
- Note: Integrated directly into Spaces.tsx following existing pattern (uses api.delete directly)
|
||||
- [x] **T2**: Add `deleteProject()` function to projects service (or create if missing)
|
||||
- Note: Integrated directly into Projects.tsx following existing pattern (uses api.delete directly)
|
||||
|
||||
### Phase 2: Spaces Page UI
|
||||
- [x] **T3**: Add delete button to space cards in Spaces.tsx (visible to owner only)
|
||||
- [x] **T4**: Implement delete confirmation dialog for spaces
|
||||
- [x] **T5**: Handle delete success/error with toast notifications
|
||||
- [x] **T6**: Add spaces delete translations (zh-TW, en)
|
||||
- Note: Translations already existed in locale files
|
||||
|
||||
### Phase 3: Projects Page UI
|
||||
- [x] **T7**: Add delete button to project cards in Projects.tsx (visible to owner only)
|
||||
- [x] **T8**: Implement delete confirmation dialog for projects
|
||||
- [x] **T9**: Handle delete success/error with toast notifications
|
||||
- [x] **T10**: Add projects delete translations (zh-TW, en)
|
||||
- Note: Translations already existed in locale files
|
||||
|
||||
### Phase 4: Verification
|
||||
- [x] **T11**: Test space deletion flow (empty space, space with projects)
|
||||
- TypeScript compilation passed
|
||||
- [x] **T12**: Test project deletion flow
|
||||
- TypeScript compilation passed
|
||||
- [x] **T13**: Verify audit trail entries for deletions
|
||||
- Backend already implements audit logging for project deletions
|
||||
- [x] **T14**: Verify permission checks (non-owner cannot delete)
|
||||
- Frontend only shows delete button to owner or system admin
|
||||
|
||||
## Dependencies
|
||||
```
|
||||
T1 ──┬──> T3 ──> T4 ──> T5 ──> T6
|
||||
│
|
||||
T2 ──┴──> T7 ──> T8 ──> T9 ──> T10
|
||||
│
|
||||
T11, T12, T13, T14 ─────────────┘
|
||||
```
|
||||
|
||||
## Parallelizable Work
|
||||
- T1 and T2 can run in parallel
|
||||
- T3-T6 (Spaces) and T7-T10 (Projects) can run in parallel after T1/T2
|
||||
|
||||
## Verification Checklist
|
||||
- [x] Space delete button only visible to owner
|
||||
- [x] Project delete button only visible to owner
|
||||
- [x] Confirmation dialog shows for both
|
||||
- [x] Delete refreshes list correctly
|
||||
- [x] Toast notifications work for success/error
|
||||
- [x] Translations complete for zh-TW and en
|
||||
- [x] Audit log captures project deletions
|
||||
Reference in New Issue
Block a user