Skip to content

Commit 4124c31

Browse files
committed
add kabob menu to linode card, factor out menu items from list view
1 parent 55a0fda commit 4124c31

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

src/components/ActionMenu.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('ActionMenu', () => {
1414
const result = mount(<ActionMenu actions={[action, action, action]} />);
1515
expect(result.find('WithStyles(ActionMenu)')).toHaveLength(1);
1616

17-
result.find('Button').simulate('click');
17+
result.find('IconButton').simulate('click');
1818
expect(result.find('WithStyles(MenuItem)')).toHaveLength(3);
1919
});
2020
});

src/components/ActionMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as React from 'react';
33
import {
44
withStyles, WithStyles, StyleRulesCallback, Theme,
55
} from 'material-ui';
6-
import Button from 'material-ui/Button';
6+
import IconButton from 'material-ui/IconButton';
77
import Menu, { MenuItem } from 'material-ui/Menu';
88
import MoreHoriz from 'material-ui-icons/MoreHoriz';
99

@@ -51,13 +51,13 @@ class ActionMenu extends React.Component<PropsWithStyles, State> {
5151
return actions.length === 1
5252
? actions.map((a, idx) => <a href="#" key={idx} onClick={e => a.onClick(e)}>{a.title}</a>)
5353
: (<div>
54-
<Button
54+
<IconButton
5555
aria-owns={anchorEl ? 'action-menu' : undefined}
5656
aria-haspopup="true"
5757
onClick={this.handleClick}
5858
>
5959
<MoreHoriz color="primary" />
60-
</Button >
60+
</IconButton >
6161
<Menu
6262
id="action-menu"
6363
anchorEl={anchorEl}

src/features/linodes/ListLinodes/LinodeCard.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ import Button from 'material-ui/Button';
1414
import Card, { CardHeader, CardContent, CardActions } from 'material-ui/Card';
1515
import Divider from 'material-ui/Divider';
1616
import Grid from 'material-ui/Grid';
17-
import IconButton from 'material-ui/IconButton';
1817
import Typography from 'material-ui/Typography';
1918
import ContentCopyIcon from 'material-ui-icons/ContentCopy';
2019

21-
import MoreHoriz from 'material-ui-icons/MoreHoriz';
2220
import CallToAction from 'material-ui-icons/CallToAction';
2321
import Replay from 'material-ui-icons/Replay';
2422

23+
import ActionMenu from 'src/components/ActionMenu';
2524
import Tag from 'src/components/Tag';
2625
import RegionIndicator from './RegionIndicator';
2726
import { typeLabelLong } from './presentation';
27+
import { actions } from './menuActions';
2828

2929
import Arch from 'src/assets/distros/Arch.png';
3030
import CentOS from 'src/assets/distros/CentOS.png';
@@ -116,9 +116,7 @@ class LinodeCard extends React.Component<Props & WithStyles<CSSClasses> > {
116116
<CardHeader
117117
title={linode.label}
118118
action={
119-
<IconButton>
120-
<MoreHoriz color="primary"/>
121-
</IconButton>
119+
<ActionMenu actions={actions} />
122120
}
123121
/>
124122
{<Divider />}

src/features/linodes/ListLinodes/LinodeRow.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import TableRow from 'material-ui/Table/TableRow';
1616
import TableCell from 'material-ui/Table/TableCell';
1717
import ContentCopyIcon from 'material-ui-icons/ContentCopy';
1818

19-
import ActionMenu, { Action } from 'src/components/ActionMenu';
19+
import ActionMenu from 'src/components/ActionMenu';
2020
import Tag from 'src/components/Tag';
2121
import RegionIndicator from './RegionIndicator';
2222
import { displayLabel } from './presentation';
23+
import { actions } from './menuActions';
2324

2425
type CSSClasses = 'inlineItems';
2526

@@ -45,16 +46,6 @@ interface Props {
4546
type PropsWithStyles = Props & WithStyles<CSSClasses>;
4647

4748
class LinodeRow extends React.Component<PropsWithStyles> {
48-
actions: Action[] = [
49-
{ title: 'Launch Console', onClick: (e) => { e.preventDefault(); } },
50-
{ title: 'Reboot', onClick: (e) => { e.preventDefault(); } },
51-
{ title: 'View Graphs', onClick: (e) => { e.preventDefault(); } },
52-
{ title: 'Resize', onClick: (e) => { e.preventDefault(); } },
53-
{ title: 'View Backups', onClick: (e) => { e.preventDefault(); } },
54-
{ title: 'Power On', onClick: (e) => { e.preventDefault(); } },
55-
{ title: 'Settings', onClick: (e) => { e.preventDefault(); } },
56-
];
57-
5849
render() {
5950
const { classes, linode, type, image } = this.props;
6051
const label = displayLabel(type.memory, image.label);
@@ -109,7 +100,7 @@ class LinodeRow extends React.Component<PropsWithStyles> {
109100
<RegionIndicator region={linode.region} />
110101
</TableCell>
111102
<TableCell>
112-
<ActionMenu actions={this.actions} />
103+
<ActionMenu actions={actions} />
113104
</TableCell>
114105
</TableRow >
115106
);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Action } from 'src/components/ActionMenu';
2+
3+
export const actions: Action[] = [
4+
{ title: 'Launch Console', onClick: (e) => { e.preventDefault(); } },
5+
{ title: 'Reboot', onClick: (e) => { e.preventDefault(); } },
6+
{ title: 'View Graphs', onClick: (e) => { e.preventDefault(); } },
7+
{ title: 'Resize', onClick: (e) => { e.preventDefault(); } },
8+
{ title: 'View Backups', onClick: (e) => { e.preventDefault(); } },
9+
{ title: 'Power On', onClick: (e) => { e.preventDefault(); } },
10+
{ title: 'Settings', onClick: (e) => { e.preventDefault(); } },
11+
];

0 commit comments

Comments
 (0)