Skip to content

Commit 3d08480

Browse files
author
Robert Stires
committed
Add LinodesListView.
1 parent 7164cab commit 3d08480

File tree

2 files changed

+64
-46
lines changed

2 files changed

+64
-46
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import * as React from 'react';
2+
3+
import Grid from 'material-ui/Grid';
4+
import Paper from 'material-ui/Paper';
5+
import Table from 'material-ui/Table';
6+
import TableBody from 'material-ui/Table/TableBody';
7+
import TableCell from 'material-ui/Table/TableCell';
8+
import TableHead from 'material-ui/Table/TableHead';
9+
import TableRow from 'material-ui/Table/TableRow';
10+
11+
import LinodeRow from './LinodeRow';
12+
13+
interface Props {
14+
linodes: Linode.Linode[];
15+
images: Linode.Image[];
16+
types: Linode.LinodeType[];
17+
}
18+
19+
const LinodesListView: React.StatelessComponent<Props> = (props) => {
20+
const { linodes, images, types } = props;
21+
22+
return (
23+
<Paper elevation={1}>
24+
<Grid container>
25+
<Grid item xs={12}>
26+
<Table>
27+
<TableHead>
28+
<TableRow>
29+
<TableCell>Label</TableCell>
30+
<TableCell>Tags</TableCell>
31+
<TableCell>IP Addresses</TableCell>
32+
<TableCell>Region</TableCell>
33+
<TableCell></TableCell>
34+
</TableRow>
35+
</TableHead>
36+
<TableBody>
37+
{linodes.map(linode =>
38+
<LinodeRow
39+
key={linode.id}
40+
linode={linode}
41+
image={images.find(image => linode.image === image.id)}
42+
type={types.find(type => linode.type === type.id)}
43+
/>,
44+
)}
45+
</TableBody>
46+
</Table>
47+
</Grid>
48+
</Grid>
49+
</Paper>
50+
);
51+
};
52+
export default LinodesListView;

src/features/linodes/ListLinodes/index.tsx

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,19 @@ import {
1515
} from 'material-ui/styles';
1616
import Button from 'material-ui/Button';
1717
import Grid from 'material-ui/Grid';
18-
import Paper from 'material-ui/Paper';
19-
import Table from 'material-ui/Table';
20-
import TableBody from 'material-ui/Table/TableBody';
21-
import TableCell from 'material-ui/Table/TableCell';
22-
import TableHead from 'material-ui/Table/TableHead';
23-
import TableRow from 'material-ui/Table/TableRow';
2418

19+
import LinodesListView from './LinodesListView';
2520
import ViewList from 'material-ui-icons/ViewList';
2621
import ViewModule from 'material-ui-icons/ViewModule';
2722

2823
import WithDocumentation from 'src/components/WithDocumentation';
2924
import LinodeCard from './LinodeCard';
30-
import LinodeRow from './LinodeRow';
3125
import ListLinodesEmptyState from './ListLinodesEmptyState';
3226

3327
import './linodes.css';
3428

35-
type CSSClasses =
36-
'toggleBox'
29+
type CSSClasses =
30+
'toggleBox'
3731
| 'toggleButton'
3832
| 'toggleButtonActive'
3933
| 'toggleButtonLeft'
@@ -112,46 +106,14 @@ class ListLinodes extends React.Component<CombinedProps> {
112106
history.push(`#${style}`);
113107
}
114108

115-
linodeList() {
116-
const { linodes, images, types } = this.props;
117109

118-
return (
119-
<Paper elevation={1}>
120-
<Grid container>
121-
<Grid item xs={12}>
122-
<Table>
123-
<TableHead>
124-
<TableRow>
125-
<TableCell>Label</TableCell>
126-
<TableCell>Tags</TableCell>
127-
<TableCell>IP Addresses</TableCell>
128-
<TableCell>Region</TableCell>
129-
<TableCell></TableCell>
130-
</TableRow>
131-
</TableHead>
132-
<TableBody>
133-
{linodes.map(linode =>
134-
<LinodeRow
135-
key={linode.id}
136-
linode={linode}
137-
image={images.find(image => linode.image === image.id)}
138-
type={types.find(type => linode.type === type.id)}
139-
/>,
140-
)}
141-
</TableBody>
142-
</Table>
143-
</Grid>
144-
</Grid>
145-
</Paper>
146-
);
147-
}
148110

149111
linodeGrid() {
150112
const { linodes, images, types } = this.props;
151113

152114
return (
153115
<Grid container>
154-
{linodes.map(linode =>
116+
{linodes.map(linode =>
155117
<LinodeCard
156118
key={linode.id}
157119
linode={linode}
@@ -165,7 +127,7 @@ class ListLinodes extends React.Component<CombinedProps> {
165127

166128
toggleBox() {
167129
const { classes, location: { hash } } = this.props;
168-
130+
169131
return (
170132
<div className={classes.toggleBox}>
171133
<Button
@@ -176,7 +138,7 @@ class ListLinodes extends React.Component<CombinedProps> {
176138
${classes.toggleButtonLeft}`
177139
}
178140
>
179-
<ViewList className={classes.icon}/>
141+
<ViewList className={classes.icon} />
180142
List
181143
</Button>
182144
<Button
@@ -187,7 +149,7 @@ class ListLinodes extends React.Component<CombinedProps> {
187149
${classes.toggleButtonRight}`
188150
}
189151
>
190-
<ViewModule className={classes.icon}/>
152+
<ViewModule className={classes.icon} />
191153
Grid
192154
</Button>
193155
</div>
@@ -202,7 +164,11 @@ class ListLinodes extends React.Component<CombinedProps> {
202164
{this.toggleBox()}
203165
{hash === '#grid'
204166
? this.linodeGrid()
205-
: this.linodeList()
167+
: <LinodesListView
168+
linodes={this.props.linodes}
169+
images={this.props.images}
170+
types={this.props.types}
171+
/>
206172
}
207173
</React.Fragment>
208174
);

0 commit comments

Comments
 (0)