-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResourceList.jsx
More file actions
70 lines (65 loc) · 1.93 KB
/
ResourceList.jsx
File metadata and controls
70 lines (65 loc) · 1.93 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';
const CustomTableCell = withStyles(theme => ({
head: {
backgroundColor: theme.palette.primary.dark,
color: theme.palette.primary.contrastText
}
}))(TableCell);
const styles = theme => ({
root: {
margin: theme.spacing.unit * 3,
overflowX: 'auto'
},
row: {
'&:nth-of-type(odd)': {
backgroundColor: theme.palette.background.default
}
}
});
const ResourceList = (props) => {
const { classes, list, resource } = props;
return (
<Paper className={classes.root}>
<Table>
<TableHead>
<TableRow>
<CustomTableCell>{`${resource} name`}</CustomTableCell>
<CustomTableCell numeric>ID</CustomTableCell>
<CustomTableCell>Type</CustomTableCell>
</TableRow>
</TableHead>
<TableBody>
{list.map(instance => (
<TableRow className={classes.row} key={instance.id}>
<TableCell component="th" scope="row">
{instance.name}
</TableCell>
<TableCell numeric>{instance.id}</TableCell>
<TableCell>{instance.type}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Paper>
);
};
ResourceList.propTypes = {
classes: PropTypes.shape({
root: PropTypes.string,
table: PropTypes.string
}).isRequired,
list: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.number,
name: PropTypes.string
})).isRequired,
resource: PropTypes.string.isRequired
};
export default withStyles(styles)(ResourceList);