From be0743f189a421f6e9a9c5065d5d8d50b1fd7e2f Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 15 Mar 2018 11:37:28 -0600 Subject: [PATCH] just use node propType --- CHANGELOG.md | 3 ++- .../__snapshots__/basic_table.test.js.snap | 8 ++------ src/components/basic_table/basic_table.js | 15 ++++----------- src/components/basic_table/in_memory_table.js | 3 +-- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 976df3ac7346..2c852a5e2e21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # [`master`](https://github.com/elastic/eui/tree/master) - `EuiInMemoryTable` pass items to BasicTable when message is provided ([#517](https://github.com/elastic/eui/pull/517)). -- `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) diff --git a/src/components/basic_table/__snapshots__/basic_table.test.js.snap b/src/components/basic_table/__snapshots__/basic_table.test.js.snap index cebc873ac5a1..2fd6065636d4 100644 --- a/src/components/basic_table/__snapshots__/basic_table.test.js.snap +++ b/src/components/basic_table/__snapshots__/basic_table.test.js.snap @@ -23,9 +23,7 @@ exports[`EuiBasicTable basic - empty - custom message 1`] = ` colSpan={1} textOnly={true} > -
- where my items at? -
+ where my items at? @@ -95,9 +93,7 @@ exports[`EuiBasicTable basic - empty 1`] = ` colSpan={1} textOnly={true} > -
- No items found -
+ No items found diff --git a/src/components/basic_table/basic_table.js b/src/components/basic_table/basic_table.js index cb19ae86a2f9..da079c7114d8 100644 --- a/src/components/basic_table/basic_table.js +++ b/src/components/basic_table/basic_table.js @@ -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 }); @@ -135,7 +133,7 @@ const BasicTablePropTypes = { onChange: PropTypes.func, error: PropTypes.string, loading: PropTypes.bool, - noItemsMessage: NoItemsMessageType, + noItemsMessage: PropTypes.node, className: PropTypes.string }; @@ -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 = (
{ this.props.noItemsMessage }
); - } else { - message = this.props.noItemsMessage; - } + const { columns, selection, noItemsMessage } = this.props; + const colSpan = columns.length + (selection ? 1 : 0); return ( - {message} + {noItemsMessage} diff --git a/src/components/basic_table/in_memory_table.js b/src/components/basic_table/in_memory_table.js index ec115c0c679f..ecb4c3272f5d 100644 --- a/src/components/basic_table/in_memory_table.js +++ b/src/components/basic_table/in_memory_table.js @@ -4,7 +4,6 @@ import { EuiBasicTable, ColumnType, SelectionType, - NoItemsMessageType } from './basic_table'; import { defaults as paginationBarDefaults @@ -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,