Skip to content

Commit

Permalink
Pass itemIdToExpandedRowMap prop from EuiInMemoryTable to EuiBasicTab…
Browse files Browse the repository at this point in the history
…le (#759)

* Pass itemIdToExpandedRowMap prop from EuiInMemoryTable to EuiBasicTable, fixes #690

* Updated unit test to cover case, updated changelog
  • Loading branch information
chandlerprall committed May 2, 2018
1 parent cf9475c commit fdd9714
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@

- Fixed `EuiTableRowCell` from overwriting its child element's `className` [#709](https://github.com/elastic/eui/pull/709)
- Allow `EuiContextMenuPanel`s to update when their `children` changes ([#710](https://github.com/elastic/eui/pull/710))
- `EuiInMemoryTable` now passes `itemIdToExpandedRowMap` prop to `EuiBasicTable` ([#759](https://github.com/elastic/eui/pull/759))

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

Expand Down
Expand Up @@ -96,6 +96,46 @@ exports[`EuiInMemoryTable with items 1`] = `
/>
`;

exports[`EuiInMemoryTable with items and expanded item 1`] = `
<EuiBasicTable
columns={
Array [
Object {
"description": "description",
"field": "name",
"name": "Name",
},
]
}
itemIdToExpandedRowMap={
Object {
"1": <div>
expanded row content
</div>,
}
}
items={
Array [
Object {
"id": "1",
"name": "name1",
},
Object {
"id": "2",
"name": "name2",
},
Object {
"id": "3",
"name": "name3",
},
]
}
noItemsMessage="No items found"
onChange={[Function]}
responsive={true}
/>
`;

exports[`EuiInMemoryTable with items and message - expecting to show the items 1`] = `
<EuiBasicTable
columns={
Expand Down
2 changes: 2 additions & 0 deletions src/components/basic_table/in_memory_table.js
Expand Up @@ -259,6 +259,7 @@ export class EuiInMemoryTable extends Component {
compressed,
pagination: hasPagination,
sorting: hasSorting,
itemIdToExpandedRowMap,
} = this.props;

const {
Expand Down Expand Up @@ -305,6 +306,7 @@ export class EuiInMemoryTable extends Component {
loading={loading}
noItemsMessage={message}
compressed={compressed}
itemIdToExpandedRowMap={itemIdToExpandedRowMap}
/>
);

Expand Down
27 changes: 27 additions & 0 deletions src/components/basic_table/in_memory_table.test.js
Expand Up @@ -93,6 +93,33 @@ describe('EuiInMemoryTable', () => {
expect(component).toMatchSnapshot();
});

test('with items and expanded item', () => {

const props = {
...requiredProps,
items: [
{ id: '1', name: 'name1' },
{ id: '2', name: 'name2' },
{ id: '3', name: 'name3' }
],
columns: [
{
field: 'name',
name: 'Name',
description: 'description'
}
],
itemIdToExpandedRowMap: {
'1': <div>expanded row content</div>
}
};
const component = shallow(
<EuiInMemoryTable {...props} />
);

expect(component).toMatchSnapshot();
});

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

const props = {
Expand Down

0 comments on commit fdd9714

Please sign in to comment.