({
graphs,
loading = false,
onRefresh,
onToggle,
onDelete,
}: GraphPanelProps)
| 68 | } |
| 69 | |
| 70 | export default function GraphPanel({ |
| 71 | graphs, |
| 72 | loading = false, |
| 73 | onRefresh, |
| 74 | onToggle, |
| 75 | onDelete, |
| 76 | }: GraphPanelProps) { |
| 77 | return ( |
| 78 | <div style={{height: '100%', minHeight: 0, display: 'flex', flexDirection: 'column'}}> |
| 79 | {/* 头部 */} |
| 80 | <div style={{padding: '12px 0', borderBottom: '1px solid #f0f0f0'}}> |
| 81 | <div style={{display: 'flex', justifyContent: 'space-between', alignItems: 'center'}}> |
| 82 | <Text strong>自动化规则</Text> |
| 83 | <Button |
| 84 | icon={<SyncOutlined/>} |
| 85 | size="small" |
| 86 | onClick={onRefresh} |
| 87 | loading={loading} |
| 88 | > |
| 89 | 刷新 |
| 90 | </Button> |
| 91 | </div> |
| 92 | {graphs.length > 0 && ( |
| 93 | <div style={{marginTop: 8}}> |
| 94 | <Tag color="success">启用: {graphs.filter(g => g.enable).length}</Tag> |
| 95 | <Tag color="default">禁用: {graphs.filter(g => !g.enable).length}</Tag> |
| 96 | </div> |
| 97 | )} |
| 98 | </div> |
| 99 | |
| 100 | {/* Graph 列表 */} |
| 101 | <div style={{flex: 1, minHeight: 0, overflow: 'auto'}}> |
| 102 | {loading ? ( |
| 103 | <div style={{textAlign: 'center', padding: 40}}> |
| 104 | <Spin/> |
| 105 | </div> |
| 106 | ) : graphs.length === 0 ? ( |
| 107 | <div style={{padding: 24}}> |
| 108 | <Empty |
| 109 | description="暂无自动化规则" |
| 110 | image={Empty.PRESENTED_IMAGE_SIMPLE} |
| 111 | /> |
| 112 | </div> |
| 113 | ) : ( |
| 114 | graphs.map(graph => ( |
| 115 | <div |
| 116 | key={graph.id} |
| 117 | style={{ |
| 118 | padding: '12px 0', |
| 119 | borderBottom: '1px solid #f5f5f5', |
| 120 | }} |
| 121 | > |
| 122 | <div style={{display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start'}}> |
| 123 | <div style={{flex: 1, minWidth: 0}}> |
| 124 | <div style={{ |
| 125 | display: 'flex', |
| 126 | alignItems: 'center', |
| 127 | marginBottom: 6, |
nothing calls this directly
no test coverage detected