Skip to content

Commit 85b186a

Browse files
author
Robert Stires
committed
Add LinodesGridView.
1 parent 3d08480 commit 85b186a

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as React from 'react';
2+
3+
import Grid from 'material-ui/Grid';
4+
5+
import LinodeCard from './LinodeCard';
6+
7+
interface Props {
8+
linodes: Linode.Linode[];
9+
images: Linode.Image[];
10+
types: Linode.LinodeType[];
11+
}
12+
13+
const LinodesGridView: React.StatelessComponent<Props> = (props) => {
14+
const { linodes, images, types } = props;
15+
16+
return (
17+
<Grid container>
18+
{linodes.map(linode =>
19+
<LinodeCard
20+
key={linode.id}
21+
linode={linode}
22+
image={images.find(image => linode.image === image.id)}
23+
type={types.find(type => linode.type === type.id)}
24+
/>,
25+
)}
26+
</Grid>
27+
);
28+
};
29+
30+
export default LinodesGridView;

src/features/linodes/ListLinodes/index.tsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import {
1414
StyleRulesCallback,
1515
} from 'material-ui/styles';
1616
import Button from 'material-ui/Button';
17-
import Grid from 'material-ui/Grid';
17+
1818

1919
import LinodesListView from './LinodesListView';
20+
import LinodesGridView from './LinodesGridView';
2021
import ViewList from 'material-ui-icons/ViewList';
2122
import ViewModule from 'material-ui-icons/ViewModule';
2223

2324
import WithDocumentation from 'src/components/WithDocumentation';
24-
import LinodeCard from './LinodeCard';
25+
2526
import ListLinodesEmptyState from './ListLinodesEmptyState';
2627

2728
import './linodes.css';
@@ -106,25 +107,6 @@ class ListLinodes extends React.Component<CombinedProps> {
106107
history.push(`#${style}`);
107108
}
108109

109-
110-
111-
linodeGrid() {
112-
const { linodes, images, types } = this.props;
113-
114-
return (
115-
<Grid container>
116-
{linodes.map(linode =>
117-
<LinodeCard
118-
key={linode.id}
119-
linode={linode}
120-
image={images.find(image => linode.image === image.id)}
121-
type={types.find(type => linode.type === type.id)}
122-
/>,
123-
)}
124-
</Grid>
125-
);
126-
}
127-
128110
toggleBox() {
129111
const { classes, location: { hash } } = this.props;
130112

@@ -163,7 +145,11 @@ class ListLinodes extends React.Component<CombinedProps> {
163145
<React.Fragment>
164146
{this.toggleBox()}
165147
{hash === '#grid'
166-
? this.linodeGrid()
148+
? <LinodesGridView
149+
linodes={this.props.linodes}
150+
images={this.props.images}
151+
types={this.props.types}
152+
/>
167153
: <LinodesListView
168154
linodes={this.props.linodes}
169155
images={this.props.images}

0 commit comments

Comments
 (0)