Backed out changeset 75c75ac98d86 (bug 1592324) for causing bc failures CLOSED TREE
authorCiure Andrei <aciure@mozilla.com>
Wed, 25 Mar 2020 19:02:06 +0200
changeset 520402 5366f10ff74911beb52cbaaf96b118981ce02b11
parent 520401 4695dbc761d726d1465b453df60482f77aa6b710
child 520403 cdf202c2682eccdb9781145451cb707ec157db9d
push id37249
push userdvarga@mozilla.com
push dateWed, 25 Mar 2020 21:39:06 +0000
treeherdermozilla-central@b3c3f7d0f044 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1592324
milestone76.0a1
backs out75c75ac98d86580240839fbe3516dd60053312be
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 75c75ac98d86 (bug 1592324) for causing bc failures CLOSED TREE
toolkit/mozapps/extensions/content/aboutaddons.css
toolkit/mozapps/extensions/content/aboutaddons.html
toolkit/mozapps/extensions/content/aboutaddons.js
--- a/toolkit/mozapps/extensions/content/aboutaddons.css
+++ b/toolkit/mozapps/extensions/content/aboutaddons.css
@@ -348,20 +348,16 @@ recommended-addon-card .addon-descriptio
 .view-footer-item {
   margin-top: 30px;
 }
 
 .privacy-policy-link {
   font-size: small;
 }
 
-.theme-recommendation {
-  text-align: start;
-}
-
 addon-details {
   color: var(--in-content-deemphasized-text);
 }
 
 .addon-detail-description {
   margin: 16px 0;
 }
 
--- a/toolkit/mozapps/extensions/content/aboutaddons.html
+++ b/toolkit/mozapps/extensions/content/aboutaddons.html
@@ -311,32 +311,29 @@
       <recommended-addon-list></recommended-addon-list>
       <footer is="recommended-footer" class="view-footer"></footer>
     </template>
 
     <template name="recommended-extensions-section">
       <h2 data-l10n-id="recommended-extensions-heading" class="header-name recommended-heading"></h2>
       <taar-notice></taar-notice>
       <recommended-addon-list type="extension" hide-installed></recommended-addon-list>
-      <footer is="recommended-footer" class="view-footer"></footer>
-    </template>
-
-    <template name="recommended-themes-footer">
-      <p data-l10n-id="recommended-theme-1" class="theme-recommendation">
-          <a data-l10n-name="link" target="_blank"></a>
-      </p>
-      <div class="amo-link-container view-footer-item">
-        <button class="primary" action="open-amo" data-l10n-id="find-more-addons"></button>
-      </div>
+      <footer is="recommended-footer" class="view-footer hide-amo-link"></footer>
     </template>
 
     <template name="recommended-themes-section">
       <h2 data-l10n-id="recommended-themes-heading" class="header-name recommended-heading"></h2>
       <recommended-addon-list type="theme" hide-installed></recommended-addon-list>
-      <footer is="recommended-themes-footer" class="view-footer"></footer>
+      <footer>
+        <div>
+          <p data-l10n-id="recommended-theme-1" class="theme-recommendation">
+            <a data-l10n-name="link" target="_blank"></a>
+          </p>
+        </div>
+      </footer>
     </template>
 
     <template id="shortcut-view">
       <div class="error-message">
         <img class="error-message-icon" src="chrome://global/skin/arrow/panelarrow-vertical.svg">
         <div class="error-message-label"></div>
       </div>
       <message-bar-stack id="duplicate-warning-messages" reverse max-message-bar-count="5">
--- a/toolkit/mozapps/extensions/content/aboutaddons.js
+++ b/toolkit/mozapps/extensions/content/aboutaddons.js
@@ -3768,54 +3768,37 @@ class RecommendedFooter extends HTMLElem
       this.addEventListener("click", this);
     }
   }
 
   handleEvent(event) {
     let action = event.target.getAttribute("action");
     switch (action) {
       case "open-amo":
-        openAmoInTab(this);
+        // The element is a button but opens a URL, so record as link.
+        AMTelemetry.recordLinkEvent({
+          object: "aboutAddons",
+          value: "discomore",
+          extra: {
+            view: "discover",
+          },
+        });
+        let amoUrl = Services.urlFormatter.formatURLPref(
+          "extensions.getAddons.link.url"
+        );
+        amoUrl = formatAmoUrl("find-more-link-bottom", amoUrl);
+        windowRoot.ownerGlobal.openTrustedLinkIn(amoUrl, "tab");
         break;
     }
   }
 }
 customElements.define("recommended-footer", RecommendedFooter, {
   extends: "footer",
 });
 
-class RecommendedThemesFooter extends HTMLElement {
-  connectedCallback() {
-    if (this.childElementCount == 0) {
-      this.appendChild(importTemplate("recommended-themes-footer"));
-      let themeRecommendationRow = this.querySelector(".theme-recommendation");
-      let themeRecommendationUrl = Services.prefs.getStringPref(
-        PREF_THEME_RECOMMENDATION_URL
-      );
-      if (themeRecommendationUrl) {
-        themeRecommendationRow.querySelector("a").href = themeRecommendationUrl;
-      }
-      themeRecommendationRow.hidden = !themeRecommendationUrl;
-      this.addEventListener("click", this);
-    }
-  }
-
-  handleEvent(event) {
-    let action = event.target.getAttribute("action");
-    switch (action) {
-      case "open-amo":
-        openAmoInTab(this);
-        break;
-    }
-  }
-}
-customElements.define("recommended-themes-footer", RecommendedThemesFooter, {
-  extends: "footer",
-});
-
 /**
  * This element will handle showing recommendations with a
  * <recommended-addon-list> and a <footer>. The footer will be hidden until
  * the <recommended-addon-list> is done making its request so the footer
  * doesn't move around.
  *
  * Subclass this element to use it and define a `template` property to pull
  * the template from. Expected template:
@@ -3852,26 +3835,62 @@ class RecommendedSection extends HTMLEle
     });
   }
 }
 
 class RecommendedExtensionsSection extends RecommendedSection {
   get template() {
     return "recommended-extensions-section";
   }
+
+  setAmoButtonVisibility() {
+    // Show the AMO button if there are no cards, this is mostly for the case
+    // where the user has no extensions and is offline.
+    let cards = Array.from(this.list.children);
+    let cardVisible = cards.some(card => !card.hidden);
+    this.footer.classList.toggle("hide-amo-link", cardVisible);
+  }
+
+  render() {
+    super.render();
+    let { list } = this;
+    list.cardsReady.then(() => this.setAmoButtonVisibility());
+    list.addEventListener("card-hidden", this);
+    list.addEventListener("card-shown", this);
+  }
+
+  handleEvent(e) {
+    if (e.type == "card-hidden") {
+      this.setAmoButtonVisibility();
+    } else if (e.type == "card-shown") {
+      this.footer.classList.add("hide-amo-link");
+    }
+  }
 }
 customElements.define(
   "recommended-extensions-section",
   RecommendedExtensionsSection
 );
 
 class RecommendedThemesSection extends RecommendedSection {
   get template() {
     return "recommended-themes-section";
   }
+
+  render() {
+    super.render();
+    let themeRecommendationRow = this.querySelector(".theme-recommendation");
+    let themeRecommendationUrl = Services.prefs.getStringPref(
+      PREF_THEME_RECOMMENDATION_URL
+    );
+    if (themeRecommendationUrl) {
+      themeRecommendationRow.querySelector("a").href = themeRecommendationUrl;
+    }
+    themeRecommendationRow.hidden = !themeRecommendationUrl;
+  }
 }
 customElements.define("recommended-themes-section", RecommendedThemesSection);
 
 class DiscoveryPane extends RecommendedSection {
   get template() {
     return "discopane";
   }
 }
@@ -4027,35 +4046,16 @@ let addonPageHeader = null;
  *                     element must define a current-view property.
  * @returns {string} The current view name.
  */
 function getTelemetryViewName(el) {
   return el.closest("[current-view]").getAttribute("current-view");
 }
 
 /**
- * @param {Element} el The button element.
- */
-function openAmoInTab(el) {
-  // The element is a button but opens a URL, so record as link.
-  AMTelemetry.recordLinkEvent({
-    object: "aboutAddons",
-    value: "discomore",
-    extra: {
-      view: getTelemetryViewName(el),
-    },
-  });
-  let amoUrl = Services.urlFormatter.formatURLPref(
-    "extensions.getAddons.link.url"
-  );
-  amoUrl = formatAmoUrl("find-more-link-bottom", amoUrl);
-  windowRoot.ownerGlobal.openTrustedLinkIn(amoUrl, "tab");
-}
-
-/**
  * Helper for saving and restoring the scroll offsets when a previously loaded
  * view is accessed again.
  */
 var ScrollOffsets = {
   _key: null,
   _offsets: new Map(),
   canRestore: true,