Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stacey-gammon committed Feb 13, 2017
1 parent f0187af commit 8c2d47f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 15 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
extends: '@elastic/kibana'
rules:
no-unused-vars: off
plugins:
['react']
extends:
['@elastic/kibana',
'plugin:react/recommended']
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
"eslint": "3.11.1",
"eslint-plugin-babel": "4.0.0",
"eslint-plugin-mocha": "4.7.0",
"eslint-plugin-react": "6.9.0",
"event-stream": "3.3.2",
"expect.js": "0.3.1",
"faker": "1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import { DeleteButton } from 'ui_framework/components/button/delete_button';

export function CreateOrDeleteButton({ showCreate, doDelete }) {
if (showCreate) {
return <CreateButtonLink href = "#/visualize/new"
tooltip = "Create new visualization" />;
return <CreateButtonLink
href = "#/visualize/new"
tooltip = "Create new visualization"
/>;
} else {
return <DeleteButton onClick={() => doDelete() }
tooltip="Delete selected visualizations" />;
return <DeleteButton
onClick={() => doDelete() }
tooltip="Delete selected visualizations"
/>;
}
}

Expand Down
7 changes: 5 additions & 2 deletions ui_framework/components/button/create_button_link.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';

import classnames from 'classnames';
import { KuiButtonLink } from './kui_button_link';
import { CreateIcon } from '../icon/create_icon';
import { CreateIcon } from '../icon';

export function CreateButtonLink(props) {
return <KuiButtonLink className="kuiButton--primary" {...props}>
const { className, ...rest } = props;
const classes = classnames('kuiButton--primary', className);
return <KuiButtonLink className={classes} {...rest}>
<CreateIcon />
</KuiButtonLink>;
}
Expand Down
17 changes: 9 additions & 8 deletions ui_framework/components/button/kui_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ import classnames from 'classnames';

import { KuiTooltip } from '../tooltip/kui_tooltip';

export function KuiButton({ className, onClick, tooltip, children}) {
export function KuiButton({ className, onClick, tooltip, children }) {
const classes = classnames('kuiButton', className);
const button = <button
className={ classes }
aria-label={ tooltip }
onClick={ onClick }
>
{ children }
</button>;
className={ classes }
aria-label={ tooltip }
onClick={ onClick }
>
{ children }
</button>;

return tooltip ? <KuiTooltip text={ tooltip }>{ button } </KuiTooltip> : button;
}

KuiButton.propTypes = {
tooltip: React.PropTypes.string,
className: React.PropTypes.string,
onClick: React.PropTypes.func
onClick: React.PropTypes.func,
children: React.PropTypes.array
};
6 changes: 6 additions & 0 deletions ui_framework/components/icon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import { KuiIcon } from './kui_icon';

export const DeleteIcon = () => <KuiIcon className="fa-trash"/>;
export const CreateIcon = () => <KuiIcon className="fa-plus"/>;

0 comments on commit 8c2d47f

Please sign in to comment.