From aa3537fc76b37e2f50ca205097f9c910c9fb79dc Mon Sep 17 00:00:00 2001 From: cchaos Date: Tue, 22 Jan 2019 17:34:27 -0500 Subject: [PATCH] Fixes #1036 --- .../__snapshots__/basic_table.test.js.snap | 787 +++++++++++++++--- .../in_memory_table.test.js.snap | 33 +- src/components/basic_table/basic_table.js | 80 +- 3 files changed, 752 insertions(+), 148 deletions(-) diff --git a/src/components/basic_table/__snapshots__/basic_table.test.js.snap b/src/components/basic_table/__snapshots__/basic_table.test.js.snap index a4a18ced71dc..686c0f68f5d3 100644 --- a/src/components/basic_table/__snapshots__/basic_table.test.js.snap +++ b/src/components/basic_table/__snapshots__/basic_table.test.js.snap @@ -5,7 +5,26 @@ exports[`EuiBasicTable cellProps renders cells with custom props from a callback className="euiBasicTable" >
- + + + + + + @@ -119,7 +138,26 @@ exports[`EuiBasicTable cellProps renders rows with custom props from an object 1 className="euiBasicTable" >
- + + + + + + @@ -235,7 +273,26 @@ exports[`EuiBasicTable empty is rendered 1`] = ` data-test-subj="test subject string" >
- + + + + + + @@ -292,7 +349,26 @@ exports[`EuiBasicTable empty renders a node as a custom message 1`] = ` className="euiBasicTable" >
- + + + + + + @@ -357,7 +433,26 @@ exports[`EuiBasicTable empty renders a string as a custom message 1`] = ` className="euiBasicTable" >
- + + + + + + @@ -414,7 +509,26 @@ exports[`EuiBasicTable footers do not render without a column footer definition className="euiBasicTable" >
- + + + + + + @@ -624,19 +738,51 @@ exports[`EuiBasicTable footers render with pagination, selection, sorting, and f >
- + + + + + + + + @@ -957,7 +1104,26 @@ exports[`EuiBasicTable itemIdToExpandedRowMap renders an expanded row 1`] = ` className="euiBasicTable" >
- + + + + + + @@ -1082,7 +1248,26 @@ exports[`EuiBasicTable rowProps renders rows with custom props from a callback 1 className="euiBasicTable" >
- + + + + + + @@ -1202,7 +1387,26 @@ exports[`EuiBasicTable rowProps renders rows with custom props from an object 1` className="euiBasicTable" >
- + + + + + + @@ -1322,7 +1526,26 @@ exports[`EuiBasicTable with pagination - 2nd page 1`] = ` className="euiBasicTable" >
- + + + + + + @@ -1417,7 +1640,26 @@ exports[`EuiBasicTable with pagination 1`] = ` className="euiBasicTable" >
- + + + + + + @@ -1533,7 +1775,26 @@ exports[`EuiBasicTable with pagination and error 1`] = ` className="euiBasicTable" >
- + + + + + + @@ -1596,7 +1857,39 @@ exports[`EuiBasicTable with pagination and selection 1`] = ` className="euiBasicTable" >
- + + + + + + + + @@ -1625,6 +1918,7 @@ exports[`EuiBasicTable with pagination and selection 1`] = ` disabled={false} id="_selection_column-checkbox" indeterminate={false} + label={null} onChange={[Function]} type="inList" /> @@ -1777,7 +2071,26 @@ exports[`EuiBasicTable with pagination, hiding the per page options 1`] = ` className="euiBasicTable" >
- + + + + + + @@ -1895,19 +2208,51 @@ exports[`EuiBasicTable with pagination, selection and sorting 1`] = ` >
- + + + + + + + + @@ -2093,19 +2439,51 @@ exports[`EuiBasicTable with pagination, selection, sorting and a single record a >
- + + + + + + + + @@ -2405,19 +2784,51 @@ exports[`EuiBasicTable with pagination, selection, sorting and column dataType 1 >
- + + + + + + + + @@ -2603,19 +3015,51 @@ exports[`EuiBasicTable with pagination, selection, sorting and column renderer 1 >
- + + + + + + + + @@ -2801,19 +3246,51 @@ exports[`EuiBasicTable with pagination, selection, sorting and multiple record a >
- + + + + + + + + @@ -3131,19 +3609,51 @@ exports[`EuiBasicTable with pagination, selection, sorting, column renderer and >
- + + + + + + + + @@ -3328,7 +3839,26 @@ exports[`EuiBasicTable with sortable columns and sorting disabled 1`] = ` className="euiBasicTable" >
- + + + + + + @@ -3434,19 +3964,38 @@ exports[`EuiBasicTable with sorting 1`] = ` >
- + + + + + +
+ > + +
+ +
+ + +
+ +
+ +
{this.renderTableMobileSort()}) : undefined; + const mobileHeader = responsive ? ( + + + {this.renderSelectAll(true)} + + {this.renderTableMobileSort()} + + + + ) : undefined; const caption = this.renderTableCaption(); const head = this.renderTableHead(); const body = this.renderTableBody(); @@ -422,42 +432,56 @@ export class EuiBasicTable extends Component { ); } - renderTableHead() { + renderSelectAll = isMobile => { + const { items, selection } = this.props; - const { items, columns, selection } = this.props; + if (!selection) { + return; + } - const headers = []; + const selectableItems = items.filter(item => ( + !selection.selectable || selection.selectable(item) + )); - if (selection) { - const selectableItems = items.filter(item => ( - !selection.selectable || selection.selectable(item) - )); + const checked = this.state.selection && + selectableItems.length > 0 && + this.state.selection.length === selectableItems.length; + + const disabled = selectableItems.length === 0; + + const onChange = (event) => { + if (event.target.checked) { + this.changeSelection(selectableItems); + } else { + this.changeSelection([]); + } + }; + + return ( + + ); + } - const checked = this.state.selection && - selectableItems.length > 0 && - this.state.selection.length === selectableItems.length; + renderTableHead() { - const disabled = selectableItems.length === 0; + const { columns, selection } = this.props; - const onChange = (event) => { - if (event.target.checked) { - this.changeSelection(selectableItems); - } else { - this.changeSelection([]); - } - }; + const headers = []; + if (selection) { headers.push( - + {this.renderSelectAll()} ); }