feat: Add mobile responsive layout, open room access, and admin room management

Mobile Responsive Layout:
- Add useMediaQuery, useIsMobile, useIsTablet, useIsDesktop hooks for device detection
- Create MobileHeader component with hamburger menu and action drawer
- Create BottomToolbar for mobile navigation (Files, Members)
- Create SlidePanel component for full-screen mobile sidebars
- Update RoomDetail.tsx with mobile/desktop conditional rendering
- Update RoomList.tsx with single-column grid and touch-friendly buttons
- Add CSS custom properties for safe areas and touch targets (min 44px)
- Add mobile viewport meta tags for notched devices

Open Room Access:
- All authenticated users can view all rooms (not just their own)
- Users can join active rooms they're not members of
- Add is_member field to room responses
- Update room list API to return all rooms by default

Admin Room Management:
- Add permanent delete functionality for system admins
- Add delete confirmation dialog with room title verification
- Broadcast room deletion via WebSocket to connected users
- Add users search API for adding members

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-05 09:12:10 +08:00
parent 1e44a63a8e
commit 1d5d4d447d
48 changed files with 3505 additions and 401 deletions

View File

@@ -0,0 +1,89 @@
# Tasks: Add Admin Room Management
## Phase 1: Backend - Hide Archived Rooms
### 1.1 Modify room listing to exclude archived for non-admin
- [x] Update `room_service.list_user_rooms()` to filter out ARCHIVED status for non-admin
- [x] Ensure admin users can still see all statuses
- [x] Handle case where non-admin explicitly requests `status=archived` (return empty)
- [x] Write unit tests for filtered listing behavior
### 1.2 Update room count queries
- [x] Ensure total count excludes archived for non-admin
- [x] Verify pagination works correctly with filtered results
## Phase 2: Backend - Permanent Deletion
### 2.1 Fix room_files foreign key constraint
- [x] Add `ondelete="CASCADE"` to room_files.room_id foreign key
- [x] Create database migration or rebuild schema
### 2.2 Create permanent delete service method
- [x] Add `permanent_delete_room()` method to room_service
- [x] Implement cascading delete for all related tables
- [x] Add MinIO file cleanup logic
- [x] Handle WebSocket broadcast for room deletion event
### 2.3 Create permanent delete endpoint
- [x] Add `DELETE /api/rooms/{room_id}/permanent` endpoint
- [x] Implement admin-only authorization check
- [x] Return appropriate error responses (403 for non-admin, 404 for not found)
- [x] Write integration tests
## Phase 3: Frontend - Status Filter Changes
### 3.1 Add admin detection to frontend
- [x] Create utility to check if current user is admin
- [x] Store admin status in auth store or derive from username
### 3.2 Update room list status filter
- [x] Conditionally render filter options based on admin status
- [x] Remove "All Status" and "Archived" for non-admin users
- [x] Keep default filter as "Active"
- [x] Test filter behavior for both user types
## Phase 4: Frontend - Permanent Delete UI
### 4.1 Add delete button to room detail
- [x] Create "Delete Room Permanently" button (admin only)
- [x] Style with warning/danger color scheme
- [x] Position in room settings or header actions
### 4.2 Implement confirmation dialog
- [x] Create confirmation modal with warning text
- [x] List what will be deleted (members, messages, files, reports)
- [x] Add optional room name confirmation input
- [x] Implement cancel and confirm buttons
### 4.3 Handle deletion flow
- [x] Call DELETE `/api/rooms/{room_id}/permanent` on confirm
- [x] Show loading state during deletion
- [x] Navigate to room list on success
- [x] Display error toast on failure
### 4.4 Handle WebSocket room deletion event
- [x] Listen for room_deleted event in WebSocket handler
- [x] Display notification to affected users
- [x] Navigate users away from deleted room
## Phase 5: Testing & Validation
### 5.1 Backend tests
- [x] Test non-admin cannot see archived rooms
- [x] Test admin can see all rooms including archived
- [x] Test permanent delete endpoint authorization
- [x] Test cascading delete removes all related data
- [x] Test MinIO cleanup on permanent delete
### 5.2 Frontend tests
- [x] Test status filter options for admin vs non-admin
- [x] Test delete button visibility
- [x] Test confirmation dialog flow
- [x] Test WebSocket room deletion handling
## Validation Checklist
- [x] Run `openspec validate add-admin-room-management --strict`
- [x] All existing tests pass
- [x] New tests cover all scenarios
- [x] Manual testing of full admin flow
- [x] Manual testing of non-admin restrictions