From 3584c3dfd8a37fecbe30a7b6ecea4ab5e539cf94 Mon Sep 17 00:00:00 2001 From: Stephen Stone Date: Thu, 13 Feb 2020 09:12:36 -0500 Subject: [PATCH] feat(table): toolbar only renders with children (#902) * feat(table): toolbar only renders with children * feat(table): added secondarytitle and tooltip conditionals * feat(tabletoolbar): add conditionals to render --- src/components/Table/Table.jsx | 112 +- src/components/Table/Table.story.jsx | 36 +- .../Table/__snapshots__/Table.story.storyshot | 5333 ++--------------- .../__snapshots__/TableCard.story.storyshot | 150 +- 4 files changed, 712 insertions(+), 4919 deletions(-) diff --git a/src/components/Table/Table.jsx b/src/components/Table/Table.jsx index 243c659d71..2ee5f1e030 100644 --- a/src/components/Table/Table.jsx +++ b/src/components/Table/Table.jsx @@ -362,57 +362,67 @@ const Table = props => { return ( - + {/* If there is no items being rendered in the toolbar, don't render the toolbar */ + options.hasFilter || + options.hasSearch || + options.hasRowActions || + options.hasRowCountInHeader || + options.hasColumnSelection || + actions.toolbar.onDownloadCSV || + secondaryTitle || + tooltip ? ( + + ) : null}
-//

This is text

-// -//
-// ); + /** This would be loaded from your fetch */ export const initialState = { columns: tableColumns.map((i, idx) => ({ @@ -447,6 +442,7 @@ storiesOf('Watson IoT|Table', module) ( - - - - ), - { - centered: { disable: true }, - }) .add( 'Stateful Example with every third row unselectable', () => ( ({ ...eachRow, isSelectable: index % 3 !== 0, @@ -521,6 +497,7 @@ storiesOf('Watson IoT|Table', module) ( ( ( diff --git a/src/components/Table/__snapshots__/Table.story.storyshot b/src/components/Table/__snapshots__/Table.story.storyshot index 5c3924800f..81433a5c3b 100644 --- a/src/components/Table/__snapshots__/Table.story.storyshot +++ b/src/components/Table/__snapshots__/Table.story.storyshot @@ -2044,8 +2044,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -2064,7 +2064,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -2791,42 +2791,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -20621,6 +20585,11 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table

+
@@ -36452,6 +36421,11 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table

+
@@ -58817,7 +58791,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
`; -exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table Stateful Example with Secondary Title 1`] = ` +exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table Stateful Example with every third row unselectable 1`] = `
-
-
-
- -
-
-

- - 0 item selected - -

-
+ Cancel +
-
-
-
+ 0 item selected + +

+
+
+ +
+
+
+ + + + +
- - - - - +
+ + +
+ +
- - -
- + - - -
- - -
- - - - - + - + - - + - + - + - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
+ Date
-
+ + - + + + + + - - + + + + + - + + + + + - + + + + + - + + + +
+ - - - - -   - -
- -
- - -
-
-
- - - toyota toyota toyota 0 - - - - - - 1973-03-03T09:46:40.000Z - - - - - - option-A - - - - - - AAAAAAAAAA - - - - - - - - - - - - 0 - - - - - - true - - - -
- -
-
- -
- - -
-
-
- - - helping whiteboard as 1 - - - - - - 1973-03-14T23:33:20.000Z - - - - - - option-B - - - - - - OewGc0QsMs - - - - - - - - - - - - 1 - - - - - - false - - - -
- - -
-
- -
- - -
-
-
- - - whiteboard can eat 2 - - - - - - 1973-04-18T16:53:20.000Z - - - - - - option-C - - - - - - c8iM4qgaYa - - - - - - - - - - - - 4 - - - - - - true - - - -
- - -
-
- -
- - -
-
-
- - - as eat scott 3 - - - - - - 1973-06-15T13:46:40.000Z - - - - - - option-A - - - - - - qcUSWgwIkI - - - - - - - - - - - - 9 - - - - - - false - - - -
- - -
-
- -
- - -
-
-
- - - can pinocchio whiteboard 4 - - - - - - 1973-09-04T14:13:20.000Z - - - - - - option-B - - - - - - 46GYyWC0w0 - - - - - - - - - - - - 16 - - - - - - true - - - -
- -
-
- -
- - -
-
-
- - - bottle toyota bottle 5 - - - - - - 1973-12-17T18:13:20.000Z - - - - - - option-C - - - - - - Ia2eQMSi8i - - - - - - - - - - - - 25 - - - - - - false - - - -
- - -
-
- -
- - -
-
-
- - - eat whiteboard pinocchio 6 - - - - - - 1974-04-24T01:46:40.000Z - - - - - - option-A - - - - - - W4oksCiQKQ - - - - - - - - - - - - 36 - - - - - - true - - - -
- - -
-
- -
- - -
-
-
- - - chocolate can helping 7 - - - - - - 1974-09-21T12:53:20.000Z - - - - - - option-B - - - - - - kYaqK2y8W8 - - - - - - - - - - - - 49 - - - - - - false - - - -
- - -
-
- -
- - -
-
-
- - - pinocchio eat can 8 - - - - - - 1975-03-14T03:33:20.000Z - - - - - - option-C - - - - - - y2MwmsEqiq - - - - - - - - - - - - 64 - - - - - - true - - - -
- -
-
- -
- - -
-
-
- - - scott pinocchio chocolate 9 - - - - - - 1975-09-26T21:46:40.000Z - - - - - - option-A - - - - - - CW82EiUYuY - - - - - - - - - - - - 81 - - - - - - false - - - -
- - -
-
-
-
-
- -
-
-
-
- - - - -
-
-
-
- - 1–10 of 100 items - -
-
-
-
- -
-
- - - - -
-
-
-
- - 1 of 10 pages - - - -
-
- - - - - - - -`; - -exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table Stateful Example with every third row unselectable 1`] = ` -
-
-
-
-
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
-
- - - - - - - - - - - - - - - -
- -
- - -
-
-
- - - - - Date - - - - - - - - - - - - -
- -
- -
@@ -80233,6 +76700,11 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table

+
@@ -83868,8 +80340,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -83888,7 +80360,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -84179,6 +80651,11 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table

+
@@ -87225,8 +83702,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -87245,7 +83722,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -87567,42 +84044,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -104215,8 +100656,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -104235,7 +100676,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -107016,8 +103457,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -107036,7 +103477,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -107394,6 +103835,11 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table

+
@@ -107963,8 +104409,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -107983,7 +104429,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -110376,8 +106822,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -110396,7 +106842,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -112662,8 +109108,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -112682,7 +109128,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -113010,42 +109456,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -129346,8 +125756,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -129366,7 +125776,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -143849,42 +140259,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -145465,8 +141839,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -145485,7 +141859,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -223758,42 +220132,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -225375,8 +221713,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -225395,7 +221733,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -225716,42 +222054,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -226165,6 +222467,11 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table

+
@@ -227938,8 +224245,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -227958,7 +224265,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -228279,42 +224586,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -232285,8 +228556,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -232305,7 +228576,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -232626,42 +228897,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -232929,42 +229164,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -233851,42 +230050,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -248106,42 +244269,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -260522,42 +256649,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -278102,42 +274193,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -292367,42 +288422,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -306616,42 +302635,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -345085,42 +341068,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -375306,42 +371253,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 1 item selected - -

-
-
-
-
@@ -389488,42 +385399,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 1 item selected - -

-
-
-
-
@@ -392868,8 +388743,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -392888,7 +388763,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -393209,42 +389084,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
@@ -395215,8 +391054,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -395235,7 +391074,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -395556,42 +391395,6 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table
-
-
-
- -
-
-

- - 0 item selected - -

-
-
-
-
diff --git a/src/components/TableCard/__snapshots__/TableCard.story.storyshot b/src/components/TableCard/__snapshots__/TableCard.story.storyshot index 8bbdf285b0..85e0c89f3e 100644 --- a/src/components/TableCard/__snapshots__/TableCard.story.storyshot +++ b/src/components/TableCard/__snapshots__/TableCard.story.storyshot @@ -1171,8 +1171,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -1191,7 +1191,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -2936,8 +2936,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -2956,7 +2956,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -6021,8 +6021,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -6041,7 +6041,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -7403,8 +7403,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -7423,7 +7423,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -8785,8 +8785,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -8805,7 +8805,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -10388,8 +10388,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -10408,7 +10408,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -11991,8 +11991,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -12011,7 +12011,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -13373,8 +13373,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -13393,7 +13393,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -15348,8 +15348,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -15368,7 +15368,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -17094,8 +17094,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -17114,7 +17114,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -18799,8 +18799,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -18819,7 +18819,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -21240,8 +21240,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -21260,7 +21260,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -22643,8 +22643,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -22663,7 +22663,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -25440,8 +25440,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -25460,7 +25460,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -27786,8 +27786,8 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table > @@ -27806,7 +27806,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT|Table >