-
Notifications
You must be signed in to change notification settings - Fork 1
/
GeneralInfoPanel.js
41 lines (35 loc) · 1.16 KB
/
GeneralInfoPanel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react';
import PropTypes from 'prop-types';
import styles from './GeneralInfoPanel.module.scss';
import { statusCodesToLabels } from '../constants/status-codes';
import NodeList from './NodeList';
export default function GeneralInfoPanel(props) {
const { nodes } = props;
const statusCodes = Object.keys(statusCodesToLabels);
const nodesByStatusCode = statusCodes.map((statusCode) => {
return Object.values(nodes).filter((node) => Number(node.status) === Number(statusCode));
});
return (
<div className={styles.GeneralInfoPanel}>
<h2>Overview</h2>
{Object.keys(statusCodesToLabels).reverse().map((statusCode) => {
const label = statusCodesToLabels[statusCode];
if (nodesByStatusCode[statusCode].length === 0) {
return null;
}
return (
<NodeList
key={label}
defaultOpen={Number(statusCode) > 0}
title={label}
nodes={nodesByStatusCode[statusCode]}
/>
);
})}
</div>
);
}
GeneralInfoPanel.propTypes = {
nodes: PropTypes.instanceOf(Object).isRequired,
actions: PropTypes.instanceOf(Object).isRequired,
};