Skip to content
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

Merged
merged 4 commits into from
Mar 15, 2018

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Mar 15, 2018

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.

Copy link
Contributor

@cjcenizal cjcenizal left a 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,
Copy link
Contributor

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))
Copy link
Contributor

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);
Copy link
Contributor

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>);
Copy link
Contributor

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}.

@nreese
Copy link
Contributor Author

nreese commented Mar 15, 2018

@cjcenizal I updated the "In-Memory Table - Selection" to provide an example of passing a message of type node

screen shot 2018-03-15 at 1 48 38 pm

@nreese nreese merged commit 574ebe8 into elastic:master Mar 15, 2018
@snide snide added the bug label Mar 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants