diff --git a/frontend/src/metabase/pulse/components/PulseCardPreview.jsx b/frontend/src/metabase/pulse/components/PulseCardPreview.jsx index 1ccbf48d936a779ca700f917905fff83f251353e..3db924022146e883bd9e8233665e394ba8b571a2 100644 --- a/frontend/src/metabase/pulse/components/PulseCardPreview.jsx +++ b/frontend/src/metabase/pulse/components/PulseCardPreview.jsx @@ -67,7 +67,12 @@ export default class PulseCardPreview extends Component { cardPreview && cardPreview.pulse_card_type == null; return ( - <div className="flex relative flex-full"> + <div + className="flex relative flex-full" + style={{ + maxWidth: 379, + }} + > <div className="absolute p2 text-grey-2" style={{ diff --git a/frontend/src/metabase/pulse/components/PulseEditCards.jsx b/frontend/src/metabase/pulse/components/PulseEditCards.jsx index b6f721492135ff52351885d1572f7b5f1a075ac1..df98dfd4a23f3e9cb6d2a2174712d9f3e76a8d8e 100644 --- a/frontend/src/metabase/pulse/components/PulseEditCards.jsx +++ b/frontend/src/metabase/pulse/components/PulseEditCards.jsx @@ -11,6 +11,17 @@ import MetabaseAnalytics from "metabase/lib/analytics"; const SOFT_LIMIT = 10; const HARD_LIMIT = 25; +const TABLE_MAX_ROWS = 20; +const TABLE_MAX_COLS = 10; + +function isAutoAttached(cardPreview) { + return ( + cardPreview && + cardPreview.pulse_card_type === "table" && + (cardPreview.row_count > TABLE_MAX_ROWS || + cardPreview.col_cound > TABLE_MAX_COLS) + ); +} export default class PulseEditCards extends Component { constructor(props) { @@ -69,9 +80,10 @@ export default class PulseEditCards extends Component { const showSoftLimitWarning = index === SOFT_LIMIT; let notices = []; const hasAttachment = - this.props.attachmentsEnabled && - card && - (card.include_csv || card.include_xls); + isAutoAttached(cardPreview) || + (this.props.attachmentsEnabled && + card && + (card.include_csv || card.include_xls)); if (hasAttachment) { notices.push({ head: t`Attachment`, @@ -85,6 +97,13 @@ export default class PulseEditCards extends Component { }); } if (cardPreview) { + if (isAutoAttached(cardPreview)) { + notices.push({ + type: "warning", + head: t`Heads up`, + body: t`We'll show the first 10 columns and 20 rows of this table in your Pulse. If you email this, we'll add a file attachment with all columns and up to 2,000 rows.`, + }); + } if (cardPreview.pulse_card_type == null && !hasAttachment) { notices.push({ type: "warning", @@ -164,7 +183,10 @@ export default class PulseEditCards extends Component { onChange={this.setCard.bind(this, index)} onRemove={this.removeCard.bind(this, index)} fetchPulseCardPreview={this.props.fetchPulseCardPreview} - attachmentsEnabled={this.props.attachmentsEnabled} + attachmentsEnabled={ + this.props.attachmentsEnabled && + !isAutoAttached(cardPreviews[card.id]) + } trackPulseEvent={this.trackPulseEvent} /> ) : ( diff --git a/frontend/test/pulse/pulse.integ.spec.js b/frontend/test/pulse/pulse.integ.spec.js index b6255cf420b49c45a4d03792c54acae85e0d803a..756e0b2e4ee9cc7f97f6b705a08e12ed1f2b96f7 100644 --- a/frontend/test/pulse/pulse.integ.spec.js +++ b/frontend/test/pulse/pulse.integ.spec.js @@ -133,8 +133,8 @@ describe("Pulse", () => { // NOTE: check text content since enzyme doesn't doesn't seem to work well with dangerouslySetInnerHTML expect(previews.at(0).text()).toBe("count12,805"); expect(previews.at(0).find(".Icon-attachment").length).toBe(1); - expect(previews.at(1).text()).toBe( - "tableThis question will be added as a file attachment", + expect(previews.at(1).text()).toEqual( + expect.stringContaining("Showing 20 of 12,805 rows"), ); expect(previews.at(1).find(".Icon-attachment").length).toBe(0); @@ -144,8 +144,8 @@ describe("Pulse", () => { previews = app.find(PulseCardPreview); expect(previews.at(0).text()).toBe("count12,805"); expect(previews.at(0).find(".Icon-attachment").length).toBe(0); - expect(previews.at(1).text()).toBe( - "tableThis question won't be included in your Pulse", + expect(previews.at(1).text()).toEqual( + expect.stringContaining("Showing 20 of 12,805 rows"), ); expect(previews.at(1).find(".Icon-attachment").length).toBe(0);