CR feedback draft
authorthomasmo <thomasmo@mozilla.com>
Thu, 10 Oct 2019 23:09:13 -0500
changeset 2378208 ddbf363eb4b5bf7a39ca9c1acc0c4c8d793fd0bc
parent 2367975 6348ad48cc41e71aa0d73136918a3a49f335f3d3
child 2378209 9736002b5926b1921a374f5edd93b2bd0c1b3d8c
child 2378215 c5e5312311f7672a0777a7a14ae40e1775fc2a28
push id434591
push usertmoore@mozilla.com
push dateSun, 13 Oct 2019 03:18:23 +0000
treeherdertry@98f24ce435f9 [default view] [failures only]
milestone71.0a1
CR feedback
browser/fxr/content/fxrprefs.css
browser/fxr/content/fxrprefs.html
browser/fxr/content/fxrprefs.js
browser/fxr/content/fxrui.js
browser/fxr/content/prefs.css
browser/fxr/content/prefs.html
browser/fxr/content/prefs.js
browser/fxr/jar.mn
--- a/browser/fxr/content/fxrui.js
+++ b/browser/fxr/content/fxrui.js
@@ -1,15 +1,16 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Configuration vars
 let homeURL = "https://www.mozilla.org/en-US/";
+// Bug 1586294 - Localize the privacy policy URL (Services.urlFormatter?)
 let privacyPolicyURL = "https://www.mozilla.org/en-US/privacy/firefox/";
 
 // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser
 let browser = null;
 let settingsUI = null;
 // The following variable map to UI elements whose behavior changes depending
 // on some state from the browser control
 let urlInput = null;
@@ -197,28 +198,28 @@ function openSettings() {
     divContainer.appendChild(browserSettingsUI);
 
     settingsUI = {
       container: divContainer,
       mask: divMask,
       settings: browserSettingsUI,
     };
 
-    browserSettingsUI.loadURI("chrome://fxr/content/fxrprefs.html", {
+    browserSettingsUI.loadURI("chrome://fxr/content/prefs.html", {
       triggeringPrincipal: gSystemPrincipal,
     });
   } else {
     console.log("Settings already loaded");
   }
 }
 
 function closeSettings() {
   console.log("Closing Settings...");
-  document.body.removeChild(settingsUI.mask);
-  document.body.removeChild(settingsUI.container);
-  settingsUI.container.removeChild(settingsUI.settings);
+  settingsUI.mask.remove();
+  settingsUI.container.remove();
+  settingsUI.settings.remove();
   settingsUI = null;
 }
 
 function showPrivacyPolicy() {
   closeSettings();
   browser.loadURI(privacyPolicyURL);
 }
rename from browser/fxr/content/fxrprefs.css
rename to browser/fxr/content/prefs.css
--- a/browser/fxr/content/fxrprefs.css
+++ b/browser/fxr/content/prefs.css
@@ -34,29 +34,29 @@
 }
 
 .button_container {
   border-radius: 22px;
   border-width: 2px;
   border-style: solid;
   padding: 15px;
   display: inline-block;
-}
-.button_enabled {
-    border-color: black;
+  border-color: black;
 }
-.button_enabled:hover {
-  border-color: blue;
+.button_container:hover {
+  border-color: green;
 }
-.button_enabled:active {
-  background-color: blue;
+.button_container:active {
+  background-color: green;
   color: white;
 }
-.button_disabled {
+
+input:disabled ~ .button_container {
   border-color: gray;
+  background-color: inherit;
   color: gray;
 }
 
 .settings_section {
   margin: 15px;
   width: 400px;
   display: inline-block;
 }
rename from browser/fxr/content/fxrprefs.html
rename to browser/fxr/content/prefs.html
--- a/browser/fxr/content/fxrprefs.html
+++ b/browser/fxr/content/prefs.html
@@ -5,48 +5,47 @@
 
 <!--
   This file contains the Settings UI for Firefox Reality on Desktop
 -->
 
 <html>
 <head>
   <title>Firefox Reality Settings</title>
-  <link rel="stylesheet" href="fxrprefs.css" />
-  <script src="fxrprefs.js"></script>
+  <link rel="stylesheet" href="prefs.css" />
+  <script src="prefs.js"></script>
 </head>
 
 <body>
 <div class="settings_container">
   <div class="preview">SETTINGS PREVIEW</div>
   <div class="about_info">
       <div class="fxr_logo_settings"> FXR LOGO?</div>
       <div>Version --fluent--</div>
       <div>Build Date --fluent--</div>
       <div>Firefox Desktop Version --fluent--</div>
   </div>
 
-  <div class="button_container button_enabled settings_section" id="ePrivacyPolicy">
+  <button class="button_container settings_section" id="ePrivacyPolicy">
       View Privacy Policy
-  </div>
+  </button>
 
   <div>
-    <input type="checkbox" class="checkbox_hidden" id="eCrashConfig"  />
-    <label for="eCrashConfig" class="button_container button_enabled settings_section">
-        Send Crash Reports and Interaction Data
-        <span class="checkbox_proxy">&#x2713;</span>
+    <input type="checkbox" class="xcheckbox_hidden" id="eCrashConfig"  />
+    <label for="eCrashConfig" class="button_container settings_section">
+      Send Crash Reports and Interaction Data
     </label>
   </div>
 
-  <div class="button_container button_enabled settings_section" id="eClearSection">
-      Clear all data...
+  <div class="button_container settings_section" id="eClearSection">
+      <span id="eClearText">Clear all data...</span>
       <div class="clear_confirmation" id="eClearPrompt">
           Are you sure you want to clear all data?
           <div>
-            <button id="eClearCancel"  class="button_container button_enabled">Cancel</button>
-            <button id="eClearConfirm" class="button_container button_enabled">Clear</button>
+            <button id="eClearCancel"  class="button_container">Cancel</button>
+            <button id="eClearConfirm" class="button_container">Clear</button>
           </div>
       </div>
   </div>
-  <button class="button_container button_enabled" id="eCloseSettings">&#x2715;</button>
+  <button class="button_container " id="eCloseSettings">&#x2715;</button>
 </div>
 </body>
 </html>
rename from browser/fxr/content/fxrprefs.js
rename to browser/fxr/content/prefs.js
--- a/browser/fxr/content/fxrprefs.js
+++ b/browser/fxr/content/prefs.js
@@ -17,50 +17,55 @@ window.addEventListener(
     initClearAllData();
     initSubmitHealthReport();
     initParentDependencies();
   },
   { once: true }
 );
 
 function initClearAllData() {
-  // Toggle whether to show the confirmation option
-  document.getElementById("eClearSection").addEventListener("click", () => {
+  let eClearSection = document.getElementById("eClearSection");
+
+  function toggleConfirm() {
     document
       .getElementById("eClearPrompt")
       .classList.toggle("clear_confirmation");
-  });
+  }
+
+  // Toggle whether to show the confirmation option
+  eClearSection.addEventListener("click", toggleConfirm);
 
   // When the confirm option is visible, do the work to actually clear the data
   document.getElementById("eClearConfirm").addEventListener("click", () => {
-    console.log("Clearing all user data...");
-    clearAllData();
-    console.log("Cleared all user data");
-  });
-}
-
-function clearAllData() {
-  return new Promise(function(resolve) {
-    Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
+    Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, function(
+      aFailedFlags
+    ) {
+      let eClearText = document.getElementById("eClearText");
+      if (aFailedFlags == 0) {
+        eClearText.textContent = "All user data cleared";
+        eClearSection.removeEventListener("click", toggleConfirm);
+      } else {
+        eClearText.textContent = "Error while clearing user data";
+      }
+    });
   });
 }
 
 // Based on https://searchfox.org/mozilla-central/source/browser/components/preferences/in-content/privacy.js
 function initSubmitHealthReport() {
   let checkbox = document.getElementById("eCrashConfig");
 
   // Telemetry is only sending data if MOZ_TELEMETRY_REPORTING is defined.
   // We still want to display the preferences panel if that's not the case, but
   // we want it to be disabled and unchecked.
   if (
     Services.prefs.prefIsLocked(PREF_UPLOAD_ENABLED) ||
     !AppConstants.MOZ_TELEMETRY_REPORTING
   ) {
-    checkbox.setAttribute("disabled", "true");
-    checkbox.labels[0].classList.replace("button_enabled", "button_disabled");
+    checkbox.disabled = true;
   } else {
     checkbox.addEventListener("change", updateSubmitHealthReport);
 
     checkbox.checked =
       Services.prefs.getBoolPref(PREF_UPLOAD_ENABLED) &&
       AppConstants.MOZ_TELEMETRY_REPORTING;
   }
 }
--- a/browser/fxr/jar.mn
+++ b/browser/fxr/jar.mn
@@ -4,19 +4,19 @@
 
 #if defined(NIGHTLY_BUILD) && defined(XP_WIN) 
 browser.jar:
 %  content fxr %content/browser/fxr/
    content/browser/fxr/fxrui.html       (content/fxrui.html)
    content/browser/fxr/fxrui.css        (content/fxrui.css)
    content/browser/fxr/fxrui_blue.css   (content/fxrui_blue.css)
    content/browser/fxr/fxrui.js         (content/fxrui.js)
-   content/browser/fxr/fxrprefs.html    (content/fxrprefs.html)
-   content/browser/fxr/fxrprefs.css     (content/fxrprefs.css)
-   content/browser/fxr/fxrprefs.js      (content/fxrprefs.js)
+   content/browser/fxr/prefs.html       (content/prefs.html)
+   content/browser/fxr/prefs.css        (content/prefs.css)
+   content/browser/fxr/prefs.js         (content/prefs.js)
    
    content/browser/fxr/assets/icon-backward.svg         (content/assets/icon-backward.svg)
    content/browser/fxr/assets/icon-forward.svg          (content/assets/icon-forward.svg)
    content/browser/fxr/assets/icon-home.svg             (content/assets/icon-home.svg)
    content/browser/fxr/assets/icon-refresh.svg          (content/assets/icon-refresh.svg)
    content/browser/fxr/assets/icon-secure.svg           (content/assets/icon-secure.svg)
    content/browser/fxr/assets/icon-stop-reload.svg      (content/assets/icon-stop-reload.svg)
 #endif