diff --git a/browser/components/newtab/content-src/asrouter/asrouter-content.jsx b/browser/components/newtab/content-src/asrouter/asrouter-content.jsx index aa6bdbec6251..3db3b643b74a 100644 --- a/browser/components/newtab/content-src/asrouter/asrouter-content.jsx +++ b/browser/components/newtab/content-src/asrouter/asrouter-content.jsx @@ -3,17 +3,18 @@ import {actionCreators as ac} from "common/Actions.jsm"; import {OUTGOING_MESSAGE_NAME as AS_GENERAL_OUTGOING_MESSAGE_NAME} from "content-src/lib/init-store"; import {ImpressionsWrapper} from "./components/ImpressionsWrapper/ImpressionsWrapper"; import {MessageContext} from "fluent"; -import {NewsletterSnippet} from "./templates/NewsletterSnippet/NewsletterSnippet"; import {OnboardingMessage} from "./templates/OnboardingMessage/OnboardingMessage"; import React from "react"; import ReactDOM from "react-dom"; import {safeURI} from "./template-utils"; import {SimpleSnippet} from "./templates/SimpleSnippet/SimpleSnippet"; +import {SubmitFormSnippet} from "./templates/SubmitFormSnippet/SubmitFormSnippet"; // Key names matching schema name of templates const SnippetComponents = { simple_snippet: SimpleSnippet, - newsletter_snippet: NewsletterSnippet, + newsletter_snippet: props => , + fxa_signup_snippet: props => , }; const INCOMING_MESSAGE_NAME = "ASRouter:parent-to-child"; @@ -266,12 +267,12 @@ export class ASRouterUISurface extends React.PureComponent { // This helps with testing document={this.props.document}> } diff --git a/browser/components/newtab/content-src/asrouter/docs/targeting-attributes.md b/browser/components/newtab/content-src/asrouter/docs/targeting-attributes.md index 6ec0245f9897..3560be41a133 100644 --- a/browser/components/newtab/content-src/asrouter/docs/targeting-attributes.md +++ b/browser/components/newtab/content-src/asrouter/docs/targeting-attributes.md @@ -26,6 +26,7 @@ Please note that some targeting attributes require stricter controls on the tele * [sync](#sync) * [topFrecentSites](#topfrecentsites) * [totalBookmarksCount](#totalbookmarkscount) +* [xpinstallEnabled](#xpinstallEnabled) ## Detailed usage @@ -374,4 +375,12 @@ Total number of bookmarks. declare const totalBookmarksCount: number; ``` +### `xpinstallEnabled` +Pref used by system administrators to disallow add-ons from installed altogether. + +#### Definition + +```ts +declare const xpinstallEnabled: boolean; +``` diff --git a/browser/components/newtab/content-src/asrouter/templates/NewsletterSnippet/NewsletterSnippet.jsx b/browser/components/newtab/content-src/asrouter/templates/SubmitFormSnippet/SubmitFormSnippet.jsx similarity index 71% rename from browser/components/newtab/content-src/asrouter/templates/NewsletterSnippet/NewsletterSnippet.jsx rename to browser/components/newtab/content-src/asrouter/templates/SubmitFormSnippet/SubmitFormSnippet.jsx index 7c1dbafe0d87..29e0965c5b10 100644 --- a/browser/components/newtab/content-src/asrouter/templates/NewsletterSnippet/NewsletterSnippet.jsx +++ b/browser/components/newtab/content-src/asrouter/templates/SubmitFormSnippet/SubmitFormSnippet.jsx @@ -2,7 +2,7 @@ import React from "react"; import {SimpleSnippet} from "../SimpleSnippet/SimpleSnippet"; import {SnippetBase} from "../../components/SnippetBase/SnippetBase"; -export class NewsletterSnippet extends React.PureComponent { +export class SubmitFormSnippet extends React.PureComponent { constructor(props) { super(props); this.expandSnippet = this.expandSnippet.bind(this); @@ -11,21 +11,33 @@ export class NewsletterSnippet extends React.PureComponent { expanded: false, signupSubmitted: false, signupSuccess: false, + disableForm: false, }; } async handleSubmit(event) { let json; + + if (this.state.disableForm) { + return; + } + + event.preventDefault(); + this.setState({disableForm: true}); + this.props.sendUserActionTelemetry({event: "CLICK_BUTTON", value: "conversion-subscribe-activation", id: "NEWTAB_FOOTER_BAR_CONTENT"}); + + if (this.props.form_method.toUpperCase() === "GET") { + this.refs.form.submit(); + return; + } + const fetchConfig = { - body: new FormData(this.refs.newsletterForm), + body: new FormData(this.refs.form), method: "POST", }; - event.preventDefault(); - this.props.sendUserActionTelemetry({event: "CLICK_BUTTON", value: "conversion-subscribe-activation", id: "NEWTAB_FOOTER_BAR_CONTENT"}); - try { - const fetchRequest = new Request(this.refs.newsletterForm.action, fetchConfig); + const fetchRequest = new Request(this.refs.form.action, fetchConfig); const response = await fetch(fetchRequest); json = await response.json(); } catch (err) { @@ -39,6 +51,8 @@ export class NewsletterSnippet extends React.PureComponent { this.setState({signupSuccess: false, signupSubmitted: true}); this.props.sendUserActionTelemetry({event: "CLICK_BUTTON", value: "subscribe-error", id: "NEWTAB_FOOTER_BAR_CONTENT"}); } + + this.setState({disableForm: false}); } expandSnippet() { @@ -60,7 +74,7 @@ export class NewsletterSnippet extends React.PureComponent { } renderFormPrivacyNotice() { - return (