Skip to content

Commit

Permalink
[EuiInMemoryTable] pass items to BasicTable when message is provided (#…
Browse files Browse the repository at this point in the history
…517)

* pass items to BasicTable even when message provided

* update docs to show why change is needed

* change log
  • Loading branch information
nreese authored Mar 15, 2018
1 parent 192868b commit d925587
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `0.0.27`.
- `EuiInMemoryTable` pass items to BasicTable when message is provided ([#517](https://github.com/elastic/eui/pull/517)).

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

Expand Down
8 changes: 5 additions & 3 deletions src-docs/src/views/tables/in_memory/in_memory_selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ const random = new Random();

const store = createDataStore();

const noItemsFoundMsg = 'No users match search criteria';

export class Table extends Component {
constructor(props) {
super(props);
this.state = {
loading: false,
users: [],
message: 'No users',
message: 'No users, click "Load Users" to load some',
selection: []
};
}
Expand All @@ -61,7 +63,7 @@ export class Table extends Component {
setTimeout(() => {
this.setState({
loading: false,
message: undefined,
message: noItemsFoundMsg,
error: undefined,
users: store.users
});
Expand All @@ -80,7 +82,7 @@ export class Table extends Component {
loading: false,
error: 'ouch!... again... ',
users: undefined,
message: undefined
message: noItemsFoundMsg
});
}, random.number({ min: 0, max: 3000 }));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exports[`EuiInMemoryTable with items 1`] = `
/>
`;

exports[`EuiInMemoryTable with items and message - expecting to show the message and not the items 1`] = `
exports[`EuiInMemoryTable with items and message - expecting to show the items 1`] = `
<EuiBasicTable
columns={
Array [
Expand All @@ -60,7 +60,22 @@ exports[`EuiInMemoryTable with items and message - expecting to show the message
},
]
}
items={Array []}
items={
Array [
Object {
"id": "1",
"name": "name1",
},
Object {
"id": "2",
"name": "name2",
},
Object {
"id": "3",
"name": "name3",
},
]
}
noItemsMessage="show me!"
onChange={[Function]}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/basic_table/in_memory_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class EuiInMemoryTable extends Component {

const table = (
<EuiBasicTable
items={message ? [] : items} // If message is configured, we force showing it instead of the items
items={items}
columns={columns}
pagination={pagination}
sorting={sorting}
Expand Down
2 changes: 1 addition & 1 deletion src/components/basic_table/in_memory_table.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('EuiInMemoryTable', () => {
expect(component).toMatchSnapshot();
});

test('with items and message - expecting to show the message and not the items', () => {
test('with items and message - expecting to show the items', () => {

const props = {
...requiredProps,
Expand Down

0 comments on commit d925587

Please sign in to comment.