From 1ef05a7fe5cd7864ec250b640b69bccdffb11644 Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Wed, 2 May 2018 10:25:48 -0600 Subject: [PATCH 1/2] Pass itemIdToExpandedRowMap prop from EuiInMemoryTable to EuiBasicTable, fixes #690 --- CHANGELOG.md | 1 + src/components/basic_table/in_memory_table.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f78148178ea..e7b7d1c6726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` ## [`0.0.44`](https://github.com/elastic/eui/tree/v0.0.44) diff --git a/src/components/basic_table/in_memory_table.js b/src/components/basic_table/in_memory_table.js index 7725daa2b02..d06bf0f05da 100644 --- a/src/components/basic_table/in_memory_table.js +++ b/src/components/basic_table/in_memory_table.js @@ -259,6 +259,7 @@ export class EuiInMemoryTable extends Component { compressed, pagination: hasPagination, sorting: hasSorting, + itemIdToExpandedRowMap, } = this.props; const { @@ -305,6 +306,7 @@ export class EuiInMemoryTable extends Component { loading={loading} noItemsMessage={message} compressed={compressed} + itemIdToExpandedRowMap={itemIdToExpandedRowMap} /> ); From 1f21a398e3102cb397a0aaf32a7607f02e4adc6a Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Wed, 2 May 2018 10:35:43 -0600 Subject: [PATCH 2/2] Updated unit test to cover case, updated changelog --- CHANGELOG.md | 2 +- .../in_memory_table.test.js.snap | 40 +++++++++++++++++++ .../basic_table/in_memory_table.test.js | 27 +++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7b7d1c6726..3e56330bc76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +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` +- `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) diff --git a/src/components/basic_table/__snapshots__/in_memory_table.test.js.snap b/src/components/basic_table/__snapshots__/in_memory_table.test.js.snap index a1b126eccda..e628f608a7b 100644 --- a/src/components/basic_table/__snapshots__/in_memory_table.test.js.snap +++ b/src/components/basic_table/__snapshots__/in_memory_table.test.js.snap @@ -96,6 +96,46 @@ exports[`EuiInMemoryTable with items 1`] = ` /> `; +exports[`EuiInMemoryTable with items and expanded item 1`] = ` + + expanded row content + , + } + } + 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`] = ` { 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':
expanded row content
+ } + }; + const component = shallow( + + ); + + expect(component).toMatchSnapshot(); + }); + test('with items and message - expecting to show the items', () => { const props = {