Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/web/ui/src/features/component/ComponentList.tsx
5304 views
1
import React from 'react';
2
import { NavLink } from 'react-router-dom';
3
4
import { HealthLabel } from '../component/HealthLabel';
5
import { ComponentInfo } from '../component/types';
6
7
import Table from './Table';
8
9
import styles from './ComponentList.module.css';
10
11
interface ComponentListProps {
12
components: ComponentInfo[];
13
parent?: string;
14
}
15
16
const TABLEHEADERS = ['Health', 'ID'];
17
18
const ComponentList = ({ components }: ComponentListProps) => {
19
const tableStyles = { width: '100px' };
20
21
/**
22
* Custom renderer for table data
23
*/
24
const renderTableData = () => {
25
return components.map(({ health, id }) => (
26
<tr key={id} style={{ lineHeight: '2' }}>
27
<td>
28
<HealthLabel health={health.state} />
29
</td>
30
<td>
31
<span>{id}</span>
32
<NavLink to={'/component/' + id} className={styles.viewButton}>
33
View
34
</NavLink>
35
</td>
36
</tr>
37
));
38
};
39
40
return (
41
<div className={styles.list}>
42
<Table tableHeaders={TABLEHEADERS} renderTableData={renderTableData} style={tableStyles} />
43
</div>
44
);
45
};
46
47
export default ComponentList;
48
49