Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Altered functionality of `truncate` on `EuiBreadcrumbs` and added `truncate` ability on breadcrumb item ([#1346](https://github.com/elastic/eui/pull/1346))
- Altered `EuiHeader`'s location of `EuiHeaderBreadcrumbs` based on the new `truncate` ability ([#1346](https://github.com/elastic/eui/pull/1346))
- Added support for `href` and `target` props in `EuiBasicTable` actions ([#1347](https://github.com/elastic/eui/pull/1347))

## [`5.4.0`](https://github.com/elastic/eui/tree/v5.4.0)

Expand Down
11 changes: 6 additions & 5 deletions src-docs/src/views/tables/actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,13 @@ export class Table extends Component {
}
}]
: [{
name: 'Delete',
description: 'Delete this user',
icon: 'trash',
color: 'danger',
name: 'Elastic.co',
description: 'Go to elastic.co',
icon: 'editorLink',
color: 'primary',
type: 'icon',
onClick: this.deleteUser
href: 'https://elastic.co',
target: '_blank',
}];
}

Expand Down
4 changes: 3 additions & 1 deletion src/components/basic_table/basic_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ const DefaultItemActionType = PropTypes.shape({
type: PropTypes.oneOf(['icon', 'button']), // default is 'button'
name: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired, // (item) => void,
onClick: PropTypes.func, // (item) => void,
href: PropTypes.string,
target: PropTypes.string,
available: PropTypes.func, // (item) => boolean;
enabled: PropTypes.func, // (item) => boolean;
isPrimary: PropTypes.bool,
Expand Down
14 changes: 10 additions & 4 deletions src/components/basic_table/default_item_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ export class DefaultItemAction extends Component {

render() {
const { action, enabled, item, className } = this.props;
if (!action.onClick) {
throw new Error(`Cannot render item action [${action.name}]. Missing required 'onClick' callback. If you want
to provide a custom action control, make sure to define the 'render' callback`);

if (!action.onClick && !action.href) {
throw new Error(`Cannot render item action [${action.name}]. Missing required 'onClick' callback
or 'href' string. If you want to provide a custom action control, make sure to define the 'render' callback`);
}
const onClick = () => action.onClick(item);

const onClick = action.onClick ? () => action.onClick(item) : undefined;
const color = this.resolveActionColor();
const icon = this.resolveActionIcon();

Expand All @@ -37,6 +39,8 @@ export class DefaultItemAction extends Component {
color={color}
iconType={icon}
onClick={onClick}
href={action.href}
target={action.target}
/>
);
} else {
Expand All @@ -48,6 +52,8 @@ export class DefaultItemAction extends Component {
color={color}
iconType={icon}
onClick={onClick}
href={action.href}
target={action.target}
flush="right"
>
{action.name}
Expand Down