Skip to content
Snippets Groups Projects
Commit b1450b2a authored by Tom Robinson's avatar Tom Robinson Committed by Ryan Senior
Browse files

Frontend changes to support larger pulse/alert tables

parent 9735916e
No related branches found
No related tags found
No related merge requests found
......@@ -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={{
......
......@@ -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}
/>
) : (
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment