-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BasicTable] - allow noItemMessage to be node #516
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just had a few minor comments. Can we also update the docs to demonstrate this type of message?
@@ -133,7 +135,7 @@ const BasicTablePropTypes = { | |||
onChange: PropTypes.func, | |||
error: PropTypes.string, | |||
loading: PropTypes.bool, | |||
noItemsMessage: PropTypes.string, | |||
noItemsMessage: NoItemsMessageType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we set noItemsMessage
to PropyTypes.node
instead of using a common type? I think the duplication is acceptable in this case, and the node
type accepts string
, number
, element
, and array
types (https://reactjs.org/docs/typechecking-with-proptypes.html).
CHANGELOG.md
Outdated
@@ -1,6 +1,6 @@ | |||
# [`master`](https://github.com/elastic/eui/tree/master) | |||
|
|||
No public interface changes since `0.0.27`. | |||
- `EuiBasicTable` `noItemsMessage` Allow typeof Node ([#516](https://github.com/elastic/eui/pull/516)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we specify that this is a propType change?
"Change EuiBasicTable
noItemsMessage
propType to node instead of just string"
@@ -421,11 +423,17 @@ export class EuiBasicTable extends Component { | |||
|
|||
renderEmptyBody() { | |||
const colSpan = this.props.columns.length + (this.props.selection ? 1 : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're touching this.props
so often, it might make sense to destructure props
:
const { columns, selection, noItemsMessage } = this.props;
@@ -421,11 +423,17 @@ 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>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to wrap this in a <div>
. I think we can probably just insert this directly into the JSX on line 436 as {noItemsMessage}
.
@cjcenizal I updated the "In-Memory Table - Selection" to provide an example of passing a message of type |
Kibana needs the ability to pass in html nodes for the
noItemsMessage
property for displaying nice messages that give users calls to action to create items when none exist.