Skip to content

Commit

Permalink
just use node propType
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Mar 15, 2018
1 parent 89de180 commit cf4fc7c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# [`master`](https://github.com/elastic/eui/tree/master)

- `EuiBasicTable` `noItemsMessage` Allow typeof Node ([#516](https://github.com/elastic/eui/pull/516))
- Change `EuiBasicTable` `noItemsMessage` and `EuiInMemoryTable` `messgae` propType to node
instead of just string ([#516](https://github.com/elastic/eui/pull/516))

# [`0.0.27`](https://github.com/elastic/eui/tree/v0.0.27)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ exports[`EuiBasicTable basic - empty - custom message 1`] = `
colSpan={1}
textOnly={true}
>
<div>
where my items at?
</div>
where my items at?
</EuiTableRowCell>
</EuiTableRow>
</EuiTableBody>
Expand Down Expand Up @@ -95,9 +93,7 @@ exports[`EuiBasicTable basic - empty 1`] = `
colSpan={1}
textOnly={true}
>
<div>
No items found
</div>
No items found
</EuiTableRowCell>
</EuiTableRow>
</EuiTableBody>
Expand Down
15 changes: 4 additions & 11 deletions src/components/basic_table/basic_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ export const SelectionType = PropTypes.shape({
selectableMessage: PropTypes.func // (selectable, item) => boolean;
});

export const NoItemsMessageType = PropTypes.oneOfType([PropTypes.string, PropTypes.node]);

const SortingType = PropTypes.shape({
sort: PropertySortType
});
Expand All @@ -135,7 +133,7 @@ const BasicTablePropTypes = {
onChange: PropTypes.func,
error: PropTypes.string,
loading: PropTypes.bool,
noItemsMessage: NoItemsMessageType,
noItemsMessage: PropTypes.node,
className: PropTypes.string
};

Expand Down Expand Up @@ -422,18 +420,13 @@ export class EuiBasicTable extends Component {
}

renderEmptyBody() {
const colSpan = this.props.columns.length + (this.props.selection ? 1 : 0);
let message;
if (typeof this.props.noItemsMessage === 'string') {
message = (<div>{ this.props.noItemsMessage }</div>);
} else {
message = this.props.noItemsMessage;
}
const { columns, selection, noItemsMessage } = this.props;
const colSpan = columns.length + (selection ? 1 : 0);
return (
<EuiTableBody>
<EuiTableRow>
<EuiTableRowCell align="center" colSpan={colSpan}>
{message}
{noItemsMessage}
</EuiTableRowCell>
</EuiTableRow>
</EuiTableBody>
Expand Down
3 changes: 1 addition & 2 deletions src/components/basic_table/in_memory_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
EuiBasicTable,
ColumnType,
SelectionType,
NoItemsMessageType
} from './basic_table';
import {
defaults as paginationBarDefaults
Expand All @@ -23,7 +22,7 @@ const InMemoryTablePropTypes = {
columns: PropTypes.arrayOf(ColumnType).isRequired,
items: PropTypes.array,
loading: PropTypes.bool,
message: NoItemsMessageType,
message: PropTypes.node,
error: PropTypes.string,
search: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
defaultQuery: QueryType,
Expand Down

0 comments on commit cf4fc7c

Please sign in to comment.