Spaces:
Paused
Paused
Download frontend/apps/internal/src/components/RuleModal.tsx from 3SCError404/nexus: direct link, hf CLI and curl.
- Browser
- Download file 5.52 kB
-
https://huggingface.co/spaces/3SCError404/nexus/resolve/main/frontend/apps/internal/src/components/RuleModal.tsx
- Command line
-
hf download hf://spaces/3SCError404/nexus/frontend/apps/internal/src/components/RuleModal.tsx
-
curl -L -o RuleModal.tsx https://huggingface.co/spaces/3SCError404/nexus/resolve/main/frontend/apps/internal/src/components/RuleModal.tsx
5.52 kB
| import React, { useState, useEffect } from 'react'; | |
| import { Shield, Zap, Clock, Activity, Send } from 'lucide-react'; | |
| import styles from './RuleModal.module.css'; | |
| import type { EscalationRule } from '@nexus/shared'; | |
| interface RuleModalProps { | |
| rule?: EscalationRule | null; | |
| onClose: () => void; | |
| onSave: (data: any) => void; | |
| loading?: boolean; | |
| } | |
| export const RuleModal: React.FC<RuleModalProps> = ({ rule, onClose, onSave, loading }) => { | |
| const [formData, setFormData] = useState({ | |
| name: '', | |
| priority_level: 'P0', | |
| threshold_minutes: 30, | |
| action: 'NOTIFY_LEAD', | |
| is_active: true | |
| }); | |
| useEffect(() => { | |
| if (rule) { | |
| setFormData({ | |
| name: rule.name, | |
| priority_level: rule.priority_level, | |
| threshold_minutes: rule.threshold_minutes, | |
| action: rule.action, | |
| is_active: rule.is_active | |
| }); | |
| } | |
| }, [rule]); | |
| const handleSubmit = (e: React.FormEvent) => { | |
| e.preventDefault(); | |
| onSave(formData); | |
| }; | |
| return ( | |
| <div className={styles.overlay} onClick={onClose}> | |
| <div className={styles.modal} onClick={e => e.stopPropagation()}> | |
| <div className={styles.header}> | |
| <div className={styles.headerBadge}>LOGIC CONFIGURATOR</div> | |
| <h3>{rule ? 'Edit Escalation Protocol' : 'Initialize New Protocol'}</h3> | |
| <p>Define automated hierarchy and conditional triggers.</p> | |
| </div> | |
| <form onSubmit={handleSubmit} className={styles.form}> | |
| <div className={styles.section}> | |
| <div className={styles.sectionHeader}> | |
| <Shield size={14} /> <span>1. PROTOCOL IDENTITY</span> | |
| </div> | |
| <div className={styles.field}> | |
| <input | |
| type="text" | |
| placeholder="Enter Protocol Identifier (e.g. Critical P0 Alert)" | |
| value={formData.name} | |
| onChange={e => setFormData({ ...formData, name: e.target.value })} | |
| required | |
| /> | |
| </div> | |
| </div> | |
| <div className={styles.segmentGrid}> | |
| <div className={styles.section}> | |
| <div className={styles.sectionHeader}> | |
| <Zap size={14} /> <span>2. TARGET TIER</span> | |
| </div> | |
| <div className={styles.field}> | |
| <select | |
| value={formData.priority_level} | |
| onChange={e => setFormData({ ...formData, priority_level: e.target.value })} | |
| > | |
| <option value="P0">P0 - CRITICAL</option> | |
| <option value="P1">P1 - HIGH</option> | |
| <option value="P2">P2 - MEDIUM</option> | |
| <option value="P3">P3 - LOW</option> | |
| </select> | |
| </div> | |
| </div> | |
| <div className={styles.section}> | |
| <div className={styles.sectionHeader}> | |
| <Clock size={14} /> <span>3. THRESHOLD</span> | |
| </div> | |
| <div className={styles.thresholdWrapper}> | |
| <input | |
| type="number" | |
| value={formData.threshold_minutes} | |
| onChange={e => setFormData({ ...formData, threshold_minutes: parseInt(e.target.value) })} | |
| min="1" | |
| required | |
| /> | |
| <span>MINUTES</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div className={styles.section}> | |
| <div className={styles.sectionHeader}> | |
| <Activity size={14} /> <span>4. TRIGGERED ACTION</span> | |
| </div> | |
| <div className={styles.field}> | |
| <select | |
| value={formData.action} | |
| onChange={e => setFormData({ ...formData, action: e.target.value })} | |
| > | |
| <option value="NOTIFY_LEAD">NOTIFY MISSION LEAD</option> | |
| <option value="REASSIGN">AUTOSCALE & REASSIGN</option> | |
| <option value="MARK_ESCALATED">SET ESCALATION FLAG</option> | |
| </select> | |
| </div> | |
| </div> | |
| <div className={styles.logicPreview}> | |
| <div className={styles.previewLabel}>LOGIC PREVIEW</div> | |
| <div className={styles.previewContent}> | |
| IF RESOLUTION > <span>{formData.threshold_minutes} MINS</span> ➔ <strong>{formData.action.replace('_', ' ')}</strong> | |
| </div> | |
| </div> | |
| <div className={styles.footer}> | |
| <div className={styles.toggleField}> | |
| <label className={styles.switch}> | |
| <input | |
| type="checkbox" | |
| checked={formData.is_active} | |
| onChange={e => setFormData({ ...formData, is_active: e.target.checked })} | |
| /> | |
| <span className={styles.slider} /> | |
| </label> | |
| <span>ACTIVATE IMMEDIATELY</span> | |
| </div> | |
| <div className={styles.btnGroup}> | |
| <button type="button" className={styles.cancelBtn} onClick={onClose}>CANCEL</button> | |
| <button type="submit" className={styles.saveBtn} disabled={loading}> | |
| <Send size={14} /> | |
| {loading ? 'DEPLOYING...' : rule ? 'UPDATE PROTOCOL' : 'DEPLOY PROTOCOL'} | |
| </button> | |
| </div> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| ); | |
| }; | |