From db5a55a5bb52200b9b2d49c8a52053195c8d47e8 Mon Sep 17 00:00:00 2001 From: Ed Lee Date: Wed, 6 Nov 2019 18:33:45 +0000 Subject: [PATCH] Bug 1594125 - Allow showing remote triplets with different header r=k88hudson Differential Revision: https://phabricator.services.mozilla.com/D51907 --HG-- extra : moz-landing-system : lando --- .../asrouter/templates/FirstRun/FirstRun.jsx | 11 +++++++++++ .../asrouter/templates/FirstRun/Triplets.jsx | 3 ++- .../newtab/data/content/activity-stream.bundle.js | 12 ++++++++++-- browser/components/newtab/lib/ASRouter.jsm | 1 - .../newtab/test/unit/asrouter/ASRouter.test.js | 5 ----- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/browser/components/newtab/content-src/asrouter/templates/FirstRun/FirstRun.jsx b/browser/components/newtab/content-src/asrouter/templates/FirstRun/FirstRun.jsx index d49abcb4d6a1..1503f816878d 100644 --- a/browser/components/newtab/content-src/asrouter/templates/FirstRun/FirstRun.jsx +++ b/browser/components/newtab/content-src/asrouter/templates/FirstRun/FirstRun.jsx @@ -22,12 +22,18 @@ export const helpers = { const hasInterrupt = interruptCleared === true ? false : Boolean(message.content); const hasTriplets = Boolean(message.bundle && message.bundle.length); + // Allow 1) falsy to not render a header 2) default welcome 3) custom header + const tripletsHeaderId = + message.tripletsHeaderId === undefined + ? "onboarding-welcome-header" + : message.tripletsHeaderId; const UTMTerm = message.utm_term || ""; return { hasTriplets, hasInterrupt, interrupt: hasInterrupt ? message : null, triplets: hasTriplets ? message.bundle : null, + tripletsHeaderId, UTMTerm, }; }, @@ -55,6 +61,7 @@ export class FirstRun extends React.PureComponent { interrupt: undefined, triplets: undefined, + tripletsHeaderId: "", isInterruptVisible: false, isTripletsContainerVisible: false, @@ -87,6 +94,7 @@ export class FirstRun extends React.PureComponent { hasInterrupt, interrupt, triplets, + tripletsHeaderId, UTMTerm, } = helpers.selectInterruptAndTriplets(message, interruptCleared); @@ -99,6 +107,7 @@ export class FirstRun extends React.PureComponent { interrupt, triplets, + tripletsHeaderId, isInterruptVisible: hasInterrupt, isTripletsContainerVisible: hasTriplets, @@ -172,6 +181,7 @@ export class FirstRun extends React.PureComponent { const { interrupt, triplets, + tripletsHeaderId, isInterruptVisible, isTripletsContainerVisible, isTripletsContentVisible, @@ -201,6 +211,7 @@ export class FirstRun extends React.PureComponent {
-

+ {headerId &&

}
{cards.map(card => ( react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_templates_OnboardingMessage_OnboardingMessage__WEBPACK_IMPORTED_MODULE_1__["OnboardingCard"], _extends({ @@ -14697,12 +14698,14 @@ const helpers = { selectInterruptAndTriplets(message = {}, interruptCleared) { const hasInterrupt = interruptCleared === true ? false : Boolean(message.content); const hasTriplets = Boolean(message.bundle && message.bundle.length); + const tripletsHeaderId = message.tripletsHeaderId === undefined ? "onboarding-welcome-header" : message.tripletsHeaderId; const UTMTerm = message.utm_term || ""; return { hasTriplets, hasInterrupt, interrupt: hasInterrupt ? message : null, triplets: hasTriplets ? message.bundle : null, + tripletsHeaderId, UTMTerm }; }, @@ -14726,6 +14729,7 @@ class FirstRun_FirstRun extends external_React_default.a.PureComponent { hasTriplets: false, interrupt: undefined, triplets: undefined, + tripletsHeaderId: "", isInterruptVisible: false, isTripletsContainerVisible: false, isTripletsContentVisible: false, @@ -14754,6 +14758,7 @@ class FirstRun_FirstRun extends external_React_default.a.PureComponent { hasInterrupt, interrupt, triplets, + tripletsHeaderId, UTMTerm } = helpers.selectInterruptAndTriplets(message, interruptCleared); return { @@ -14763,6 +14768,7 @@ class FirstRun_FirstRun extends external_React_default.a.PureComponent { hasTriplets, interrupt, triplets, + tripletsHeaderId, isInterruptVisible: hasInterrupt, isTripletsContainerVisible: hasTriplets, isTripletsContentVisible: !(hasInterrupt || !hasTriplets), @@ -14844,6 +14850,7 @@ class FirstRun_FirstRun extends external_React_default.a.PureComponent { const { interrupt, triplets, + tripletsHeaderId, isInterruptVisible, isTripletsContainerVisible, isTripletsContentVisible, @@ -14866,6 +14873,7 @@ class FirstRun_FirstRun extends external_React_default.a.PureComponent { }) : null, hasTriplets ? external_React_default.a.createElement(Triplets["Triplets"], { document: props.document, cards: triplets, + headerId: tripletsHeaderId, showCardPanel: isTripletsContainerVisible, showContent: isTripletsContentVisible, hideContainer: this.closeTriplets, diff --git a/browser/components/newtab/lib/ASRouter.jsm b/browser/components/newtab/lib/ASRouter.jsm index b8788df6d1d3..a588a954b78c 100644 --- a/browser/components/newtab/lib/ASRouter.jsm +++ b/browser/components/newtab/lib/ASRouter.jsm @@ -1981,7 +1981,6 @@ class _ASRouter { } else { // On new tab, send cards if they match; othwerise send a snippet message = await this.handleMessageRequest({ - provider: "onboarding", template: "extended_triplets", }); diff --git a/browser/components/newtab/test/unit/asrouter/ASRouter.test.js b/browser/components/newtab/test/unit/asrouter/ASRouter.test.js index f81b283f1545..3c8161b11569 100644 --- a/browser/components/newtab/test/unit/asrouter/ASRouter.test.js +++ b/browser/components/newtab/test/unit/asrouter/ASRouter.test.js @@ -1388,7 +1388,6 @@ describe("ASRouter", () => { ); handleMessageRequestStub .withArgs({ - provider: "onboarding", template: "extended_triplets", }) .resolves({ id: "foo" }); @@ -1409,7 +1408,6 @@ describe("ASRouter", () => { ); handleMessageRequestStub .withArgs({ - provider: "onboarding", template: "extended_triplets", }) .resolves({ id: "foo" }); @@ -1421,7 +1419,6 @@ describe("ASRouter", () => { assert.calledTwice(handleMessageRequestStub); assert.calledWithExactly(handleMessageRequestStub, { - provider: "onboarding", template: "extended_triplets", }); assert.calledWithExactly(handleMessageRequestStub, { @@ -1435,7 +1432,6 @@ describe("ASRouter", () => { ); handleMessageRequestStub .withArgs({ - provider: "onboarding", template: "extended_triplets", }) .resolves(null); @@ -1449,7 +1445,6 @@ describe("ASRouter", () => { assert.notCalled(spy); assert.calledTwice(handleMessageRequestStub); assert.calledWithExactly(handleMessageRequestStub, { - provider: "onboarding", template: "extended_triplets", }); assert.calledWithExactly(handleMessageRequestStub, {