Web Inspector: REGRESSION: Audit: default audits aren't added when an existing audit...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Apr 2019 20:46:34 +0000 (20:46 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Apr 2019 20:46:34 +0000 (20:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196663
<rdar://problem/49660757>

Reviewed by Timothy Hatcher.

Rather than have a button that allows the user to re-add the default audits, prevent them
from being deletable in the first place. "Deleting" a default audit will instead mark it as
disabled (and beep if it is already disabled).

* UserInterface/Controllers/AuditManager.js:
(WI.AuditManager.prototype.loadStoredTests):
(WI.AuditManager.prototype.removeTest):
(WI.AuditManager.prototype._addDefaultTests): Added.
(WI.AuditManager.prototype.addDefaultTestsIfNeeded): Deleted.

* UserInterface/Views/AuditNavigationSidebarPanel.js:
(WI.AuditNavigationSidebarPanel.prototype._addTest):
(WI.AuditNavigationSidebarPanel.prototype._updateStartStopButtonNavigationItemState):
(WI.AuditNavigationSidebarPanel.prototype._updateNoAuditsPlaceholder):
(WI.AuditNavigationSidebarPanel.prototype._handleAuditTestRemoved):
* UserInterface/Views/AuditNavigationSidebarPanel.css:
(.sidebar > .panel.navigation.audit.has-results > .content > .message-text-view.no-enabled-audits): Added.
(.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view): Deleted.
(.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view > .message): Deleted.
(.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view > button): Deleted.

* Localizations/en.lproj/localizedStrings.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244039 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js
Source/WebInspectorUI/UserInterface/Views/AuditNavigationSidebarPanel.css
Source/WebInspectorUI/UserInterface/Views/AuditNavigationSidebarPanel.js

index 47b1c60..c65feee 100644 (file)
@@ -1,3 +1,34 @@
+2019-04-08  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: REGRESSION: Audit: default audits aren't added when an existing audit is present
+        https://bugs.webkit.org/show_bug.cgi?id=196663
+        <rdar://problem/49660757>
+
+        Reviewed by Timothy Hatcher.
+
+        Rather than have a button that allows the user to re-add the default audits, prevent them
+        from being deletable in the first place. "Deleting" a default audit will instead mark it as
+        disabled (and beep if it is already disabled).
+
+        * UserInterface/Controllers/AuditManager.js:
+        (WI.AuditManager.prototype.loadStoredTests):
+        (WI.AuditManager.prototype.removeTest):
+        (WI.AuditManager.prototype._addDefaultTests): Added.
+        (WI.AuditManager.prototype.addDefaultTestsIfNeeded): Deleted.
+
+        * UserInterface/Views/AuditNavigationSidebarPanel.js:
+        (WI.AuditNavigationSidebarPanel.prototype._addTest):
+        (WI.AuditNavigationSidebarPanel.prototype._updateStartStopButtonNavigationItemState):
+        (WI.AuditNavigationSidebarPanel.prototype._updateNoAuditsPlaceholder):
+        (WI.AuditNavigationSidebarPanel.prototype._handleAuditTestRemoved):
+        * UserInterface/Views/AuditNavigationSidebarPanel.css:
+        (.sidebar > .panel.navigation.audit.has-results > .content > .message-text-view.no-enabled-audits): Added.
+        (.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view): Deleted.
+        (.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view > .message): Deleted.
+        (.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view > button): Deleted.
+
+        * Localizations/en.lproj/localizedStrings.js:
+
 2019-04-06  Nikita Vasilyev  <nvasilyev@apple.com>
 
         REGRESSION(r237196): Web Inspector: Computed panel shouldn't update when it isn't visible
index edfdce7..b6f9bfd 100644 (file)
@@ -84,7 +84,6 @@ localizedStrings["Activity Viewer"] = "Activity Viewer";
 localizedStrings["Add"] = "Add";
 localizedStrings["Add Action"] = "Add Action";
 localizedStrings["Add Breakpoint"] = "Add Breakpoint";
-localizedStrings["Add Default Audits"] = "Add Default Audits";
 localizedStrings["Add New"] = "Add New";
 localizedStrings["Add New Class"] = "Add New Class";
 localizedStrings["Add New Probe Expression"] = "Add New Probe Expression";
@@ -672,7 +671,6 @@ localizedStrings["No Accessibility Information"] = "No Accessibility Information
 localizedStrings["No Application Cache information available"] = "No Application Cache information available";
 localizedStrings["No Associated Data"] = "No Associated Data";
 localizedStrings["No Attributes"] = "No Attributes";
-localizedStrings["No Audits"] = "No Audits";
 localizedStrings["No Box Model Information"] = "No Box Model Information";
 localizedStrings["No CSS Changes"] = "No CSS Changes";
 localizedStrings["No Canvas Contexts"] = "No Canvas Contexts";
@@ -680,6 +678,7 @@ localizedStrings["No Canvas Selected"] = "No Canvas Selected";
 localizedStrings["No Chart Available"] = "No Chart Available";
 localizedStrings["No Child Layers"] = "No Child Layers";
 localizedStrings["No Data Bindings"] = "No Data Bindings";
+localizedStrings["No Enabled Audits"] = "No Enabled Audits";
 localizedStrings["No Entries"] = "No Entries";
 localizedStrings["No Event Listeners"] = "No Event Listeners";
 localizedStrings["No Filter Results"] = "No Filter Results";
index c208122..b5d223f 100644 (file)
@@ -244,6 +244,8 @@ WI.AuditManager = class AuditManager extends WI.Object
         if (this._tests.length)
             return;
 
+        this._addDefaultTests();
+
         WI.objectStores.audits.getAll().then(async (tests) => {
             for (let payload of tests) {
                 let test = await WI.AuditTestGroup.fromPayload(payload) || await WI.AuditTestCase.fromPayload(payload);
@@ -255,19 +257,31 @@ WI.AuditManager = class AuditManager extends WI.Object
 
                 this._addTest(test);
             }
-
-            this.addDefaultTestsIfNeeded();
         });
     }
 
     removeTest(test)
     {
+        if (test.__default) {
+            if (test.disabled) {
+                InspectorFrontendHost.beep();
+                return;
+            }
+
+            test.disabled = true;
+
+            let disabledTests = this._disabledDefaultTestsSetting.value.slice();
+            disabledTests.push(test.name);
+            this._disabledDefaultTestsSetting.value = disabledTests;
+
+            return;
+        }
+
         this._tests.remove(test);
 
         this.dispatchEventToListeners(WI.AuditManager.Event.TestRemoved, {test});
 
-        if (!test.__default)
-            WI.objectStores.audits.deleteObject(test);
+        WI.objectStores.audits.deleteObject(test);
     }
 
     // Private
@@ -327,11 +341,8 @@ WI.AuditManager = class AuditManager extends WI.Object
         }
     }
 
-    addDefaultTestsIfNeeded()
+    _addDefaultTests()
     {
-        if (this._tests.length)
-            return;
-
         const testMenuRoleForRequiredChidren = function() {
             const relationships = {
                 menu: ["menuitem", "menuitemcheckbox", "menuitemradio"],
index dd8b716..56bfd76 100644 (file)
     bottom: var(--navigation-bar-height);
 }
 
-.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view {
+.sidebar > .panel.navigation.audit.has-results > .content > .message-text-view.no-enabled-audits {
     position: initial;
     border-bottom: 1px solid var(--border-color);
 }
 
-.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view > .message {
-    display: none;
-}
-
-.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view > button {
-    margin: 8px 0 7px;
-}
-
 .finish-editing-audits-placeholder.message-text-view .navigation-item-help .navigation-bar {
     padding: 0;
     vertical-align: 0.5px;
index 496b519..b5c196d 100644 (file)
@@ -158,8 +158,6 @@ WI.AuditNavigationSidebarPanel = class AuditNavigationSidebarPanel extends WI.Na
 
     _addTest(test)
     {
-        this.element.classList.add("has-tests");
-
         let treeElement = new WI.AuditTreeElement(test);
 
         if (this._resultsFolderTreeElement) {
@@ -170,8 +168,7 @@ WI.AuditNavigationSidebarPanel = class AuditNavigationSidebarPanel extends WI.Na
 
         this._updateStartStopButtonNavigationItemState();
         this._updateEditButtonNavigationItemState();
-
-        this.hideEmptyContentPlaceholder();
+        this._updateNoAuditsPlaceholder();
     }
 
     _addResult(result, index)
@@ -204,7 +201,7 @@ WI.AuditNavigationSidebarPanel = class AuditNavigationSidebarPanel extends WI.Na
     _updateStartStopButtonNavigationItemState()
     {
         this._startStopButtonNavigationItem.toggled = WI.auditManager.runningState === WI.AuditManager.RunningState.Active || WI.auditManager.runningState === WI.AuditManager.RunningState.Stopping;
-        this._startStopButtonNavigationItem.enabled = WI.auditManager.tests.length && (WI.auditManager.runningState === WI.AuditManager.RunningState.Inactive || WI.auditManager.runningState === WI.AuditManager.RunningState.Active);
+        this._startStopButtonNavigationItem.enabled = WI.auditManager.tests.some((test) => !test.disabled) && (WI.auditManager.runningState === WI.AuditManager.RunningState.Inactive || WI.auditManager.runningState === WI.AuditManager.RunningState.Active);
     }
 
      _updateEditButtonNavigationItemState()
@@ -216,28 +213,20 @@ WI.AuditNavigationSidebarPanel = class AuditNavigationSidebarPanel extends WI.Na
 
     _updateNoAuditsPlaceholder()
     {
-        if (WI.auditManager.editing || WI.auditManager.tests.some((test) => !test.disabled))
+        if (WI.auditManager.editing || WI.auditManager.tests.some((test) => !test.disabled)) {
+            if (!this.hasActiveFilters)
+                this.hideEmptyContentPlaceholder();
             return;
+        }
 
-        let contentPlaceholder = WI.createMessageTextView(WI.UIString("No Audits"));
-
-        let defaultButtonElement = contentPlaceholder.appendChild(document.createElement("button"));
-        defaultButtonElement.textContent = WI.UIString("Add Default Audits");
-        defaultButtonElement.addEventListener("click", () => {
-            WI.auditManager.addDefaultTestsIfNeeded();
-        });
-
-        contentPlaceholder = this.showEmptyContentPlaceholder(contentPlaceholder);
+        let contentPlaceholder = this.showEmptyContentPlaceholder(WI.UIString("No Enabled Audits"));
+        contentPlaceholder.classList.add("no-enabled-audits");
 
         if (WI.auditManager.results.length) {
-            console.assert(this.contentTreeOutline.children[0] === this._resultsFolderTreeElement);
-
             // Move the placeholder to be the first element in the content area, where it will
-            // be styled such that only the button is visible.
+            // be styled so that it doesn't obstruct the results elements.
             this.contentView.element.insertBefore(contentPlaceholder, this.contentView.element.firstChild);
         }
-
-        this._updateEditButtonNavigationItemState();
     }
 
     _handleAuditManagerEditingChanged(event)
@@ -279,9 +268,8 @@ WI.AuditNavigationSidebarPanel = class AuditNavigationSidebarPanel extends WI.Na
         let treeElement = this.treeElementForRepresentedObject(test);
         this.contentTreeOutline.removeChild(treeElement);
 
-        this.element.classList.toggle("has-tests", !!WI.auditManager.tests.length);
-
         this._updateStartStopButtonNavigationItemState();
+        this._updateEditButtonNavigationItemState();
         this._updateNoAuditsPlaceholder();
     }