|
| 1 | +# AlertSidebar Integration in Incident Alerts |
| 2 | + |
| 3 | +## Overview |
| 4 | +This implementation replaces the `ViewAlertModal` component with the `AlertSidebar` component in the incident alerts page to provide a consistent user experience across the application. |
| 5 | + |
| 6 | +## Changes Made |
| 7 | + |
| 8 | +### 1. Component Integration (`incident-alerts.tsx`) |
| 9 | +- **Removed**: `ViewAlertModal` import and usage |
| 10 | +- **Added**: `AlertSidebar` component from `@/features/alerts/alert-detail-sidebar` |
| 11 | +- **Updated State Management**: |
| 12 | + - Replaced `viewAlertModal` state with `selectedAlert` and `isSidebarOpen` |
| 13 | + - Added `isIncidentSelectorOpen` state for AlertSidebar compatibility |
| 14 | + |
| 15 | +### 2. User Interactions |
| 16 | +The AlertSidebar can be opened in two ways: |
| 17 | +1. **Row Click**: Clicking on any alert row in the table |
| 18 | +2. **View Button**: Clicking the "View Details" button in the action tray |
| 19 | + |
| 20 | +### 3. Key Features |
| 21 | +- **Consistent UI**: Uses the same sidebar component as the main alerts table |
| 22 | +- **Alert Details**: Shows alert name, severity, description, source, and other metadata |
| 23 | +- **Alert Timeline**: Displays audit history and state changes |
| 24 | +- **Related Services**: Shows topology map of related services |
| 25 | +- **Actions**: Supports workflow execution, status changes, and incident association |
| 26 | + |
| 27 | +### 4. Code Comments |
| 28 | +Added explanatory comments in the implementation: |
| 29 | +- Component replacement rationale |
| 30 | +- State management explanations |
| 31 | +- Handler function descriptions |
| 32 | +- Optional prop documentation |
| 33 | + |
| 34 | +## Testing |
| 35 | + |
| 36 | +### Test Coverage (`incident-alerts-sidebar.test.tsx`) |
| 37 | +Created comprehensive tests covering: |
| 38 | +1. **Rendering**: Verifies alerts are displayed correctly |
| 39 | +2. **Opening Sidebar**: Tests both row click and button click methods |
| 40 | +3. **Closing Sidebar**: Ensures proper cleanup |
| 41 | +4. **Alert Switching**: Tests switching between different alerts |
| 42 | +5. **Empty State**: Handles no alerts scenario |
| 43 | +6. **Loading State**: Covers data fetching states |
| 44 | + |
| 45 | +### Running Tests |
| 46 | +```bash |
| 47 | +cd keep-ui |
| 48 | +npm test -- --testPathPattern="incident-alerts-sidebar.test.tsx" |
| 49 | +``` |
| 50 | + |
| 51 | +## Benefits |
| 52 | +1. **Consistency**: Same sidebar experience across all alert views |
| 53 | +2. **Feature Parity**: All alert actions available in incident context |
| 54 | +3. **Maintainability**: Single component to maintain instead of multiple modals |
| 55 | +4. **User Experience**: Familiar interaction patterns for users |
| 56 | + |
| 57 | +## Future Considerations |
| 58 | +- The sidebar supports additional features like workflow execution and status changes |
| 59 | +- These features can be enabled by passing the appropriate handlers as props |
| 60 | +- The component is designed to be extensible for future requirements |
0 commit comments