Bug 1497934 - When about:policies#active is empty, show a message. r=felipe,flod
authorIvan Yung <ivankhyung@gmail.com>
Mon, 18 Feb 2019 19:16:16 -0300
changeset 459827 2c2e488c86cedcdc12ece404440669a992e2ce14
parent 459826 10bef0ce2b5bb28bb918969d35bc8ca47071b97e
child 459828 10030bd8ac3dd4d0333aae3a44ecfbbe5bb75bec
push id35575
push usercbrindusan@mozilla.com
push dateTue, 19 Feb 2019 04:40:03 +0000
treeherdermozilla-central@ee6e77950205 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe, flod
bugs1497934
milestone67.0a1
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
Bug 1497934 - When about:policies#active is empty, show a message. r=felipe,flod
browser/components/enterprisepolicies/content/aboutPolicies.css
browser/components/enterprisepolicies/content/aboutPolicies.js
browser/components/enterprisepolicies/content/aboutPolicies.xhtml
browser/locales/en-US/browser/aboutPolicies.ftl
--- a/browser/components/enterprisepolicies/content/aboutPolicies.css
+++ b/browser/components/enterprisepolicies/content/aboutPolicies.css
@@ -142,8 +142,29 @@ tbody.collapsible td {
   padding-bottom: 1rem;
 }
 
 .schema {
   font-family: monospace;
   white-space: pre;
   direction: ltr;
 }
+
+/*
+ * The Active tab has two messages: one for when the policy service
+ * is inactive and another for when the there are no specified
+ * policies. The three classes below control which message to display
+ * or to show the policy table.
+ */
+.no-specified-policies > table,
+.inactive-service > table {
+  display: none;
+}
+
+:not(.no-specified-policies) > .no-specified-policies-message,
+:not(.inactive-service) > .inactive-service-message {
+  display: none;
+}
+
+.no-specified-policies-message,
+.inactive-service-message {
+  padding: 1rem;
+}
--- a/browser/components/enterprisepolicies/content/aboutPolicies.js
+++ b/browser/components/enterprisepolicies/content/aboutPolicies.js
@@ -86,16 +86,25 @@ function generateActivePolicies(data) {
       let row = document.createElement("tr");
       row.appendChild(col(policyName));
       row.appendChild(col(JSON.stringify(data[policyName])));
       row.classList.add(color_class, "last_row");
       new_cont.appendChild(row);
     }
   }
 
+  if (policy_count < 1) {
+    let current_tab = document.querySelector(".active");
+    if (Services.policies.status == Services.policies.ACTIVE) {
+      current_tab.classList.add("no-specified-policies");
+    } else {
+      current_tab.classList.add("inactive-service");
+    }
+  }
+
   addMissingColumns();
 }
 
 /*
  * This is a helper recursive function that iterates levels of each
  * policy and formats the content to be displayed accordingly.
  */
 
@@ -201,17 +210,16 @@ function generateErrors() {
   for (let err of consoleEvents) {
     if (prefixes.includes(err.prefix)) {
       flag = true;
       let row = document.createElement("tr");
       row.appendChild(col(err.arguments[0]));
       new_cont.appendChild(row);
     }
   }
-
   if (!flag) {
     let errors_tab = document.getElementById("category-errors");
     errors_tab.style.display = "none";
   }
 }
 
 function generateDocumentation() {
   let new_cont = document.getElementById("documentationContent");
--- a/browser/components/enterprisepolicies/content/aboutPolicies.xhtml
+++ b/browser/components/enterprisepolicies/content/aboutPolicies.xhtml
@@ -32,16 +32,18 @@
             </div>
         </div>
         <div class="main-content">
             <div class="header">
                 <div id="sectionTitle" class="header-name" data-l10n-id="active-policies-tab"/>
             </div>
 
             <div id="active" class="tab active">
+                <h3 class="inactive-service-message" data-l10n-id="inactive-message"></h3>
+                <h3 class="no-specified-policies-message" data-l10n-id="no-specified-policies-message"></h3>
                 <table>
                     <thead>
                         <tr>
                             <th data-l10n-id="policy-name"/>
                             <th data-l10n-id="policy-value"/>
                         </tr>
                     </thead>
                     <tbody id="activeContent" />
--- a/browser/locales/en-US/browser/aboutPolicies.ftl
+++ b/browser/locales/en-US/browser/aboutPolicies.ftl
@@ -4,11 +4,14 @@
 
 about-policies-title = Enterprise Policies
 
 # 'Active' is used to describe the policies that are currently active
 active-policies-tab = Active
 errors-tab = Errors
 documentation-tab = Documentation
 
+no-specified-policies-message = The Enterprise Policies service is active but there are no policies enabled.
+inactive-message = The Enterprise Policies service is inactive.
+
 policy-name = Policy Name
 policy-value = Policy Value
 policy-errors = Policy Errors