⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244039 in webkit


Ignore:
Timestamp:
Apr 8, 2019, 1:46:34 PM (7 years ago)
Author:
Devin Rousso
Message:

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:
Location:
trunk/Source/WebInspectorUI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r243964 r244039  
     12019-04-08  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: REGRESSION: Audit: default audits aren't added when an existing audit is present
     4        https://bugs.webkit.org/show_bug.cgi?id=196663
     5        <rdar://problem/49660757>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        Rather than have a button that allows the user to re-add the default audits, prevent them
     10        from being deletable in the first place. "Deleting" a default audit will instead mark it as
     11        disabled (and beep if it is already disabled).
     12
     13        * UserInterface/Controllers/AuditManager.js:
     14        (WI.AuditManager.prototype.loadStoredTests):
     15        (WI.AuditManager.prototype.removeTest):
     16        (WI.AuditManager.prototype._addDefaultTests): Added.
     17        (WI.AuditManager.prototype.addDefaultTestsIfNeeded): Deleted.
     18
     19        * UserInterface/Views/AuditNavigationSidebarPanel.js:
     20        (WI.AuditNavigationSidebarPanel.prototype._addTest):
     21        (WI.AuditNavigationSidebarPanel.prototype._updateStartStopButtonNavigationItemState):
     22        (WI.AuditNavigationSidebarPanel.prototype._updateNoAuditsPlaceholder):
     23        (WI.AuditNavigationSidebarPanel.prototype._handleAuditTestRemoved):
     24        * UserInterface/Views/AuditNavigationSidebarPanel.css:
     25        (.sidebar > .panel.navigation.audit.has-results > .content > .message-text-view.no-enabled-audits): Added.
     26        (.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view): Deleted.
     27        (.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view > .message): Deleted.
     28        (.sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view > button): Deleted.
     29
     30        * Localizations/en.lproj/localizedStrings.js:
     31
    1322019-04-06  Nikita Vasilyev  <nvasilyev@apple.com>
    233
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r243717 r244039  
    8585localizedStrings["Add Action"] = "Add Action";
    8686localizedStrings["Add Breakpoint"] = "Add Breakpoint";
    87 localizedStrings["Add Default Audits"] = "Add Default Audits";
    8887localizedStrings["Add New"] = "Add New";
    8988localizedStrings["Add New Class"] = "Add New Class";
     
    673672localizedStrings["No Associated Data"] = "No Associated Data";
    674673localizedStrings["No Attributes"] = "No Attributes";
    675 localizedStrings["No Audits"] = "No Audits";
    676674localizedStrings["No Box Model Information"] = "No Box Model Information";
    677675localizedStrings["No CSS Changes"] = "No CSS Changes";
     
    681679localizedStrings["No Child Layers"] = "No Child Layers";
    682680localizedStrings["No Data Bindings"] = "No Data Bindings";
     681localizedStrings["No Enabled Audits"] = "No Enabled Audits";
    683682localizedStrings["No Entries"] = "No Entries";
    684683localizedStrings["No Event Listeners"] = "No Event Listeners";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js

    r243425 r244039  
    245245            return;
    246246
     247        this._addDefaultTests();
     248
    247249        WI.objectStores.audits.getAll().then(async (tests) => {
    248250            for (let payload of tests) {
     
    256258                this._addTest(test);
    257259            }
    258 
    259             this.addDefaultTestsIfNeeded();
    260260        });
    261261    }
     
    263263    removeTest(test)
    264264    {
     265        if (test.__default) {
     266            if (test.disabled) {
     267                InspectorFrontendHost.beep();
     268                return;
     269            }
     270
     271            test.disabled = true;
     272
     273            let disabledTests = this._disabledDefaultTestsSetting.value.slice();
     274            disabledTests.push(test.name);
     275            this._disabledDefaultTestsSetting.value = disabledTests;
     276
     277            return;
     278        }
     279
    265280        this._tests.remove(test);
    266281
    267282        this.dispatchEventToListeners(WI.AuditManager.Event.TestRemoved, {test});
    268283
    269         if (!test.__default)
    270             WI.objectStores.audits.deleteObject(test);
     284        WI.objectStores.audits.deleteObject(test);
    271285    }
    272286
     
    328342    }
    329343
    330     addDefaultTestsIfNeeded()
    331     {
    332         if (this._tests.length)
    333             return;
    334 
     344    _addDefaultTests()
     345    {
    335346        const testMenuRoleForRequiredChidren = function() {
    336347            const relationships = {
  • trunk/Source/WebInspectorUI/UserInterface/Views/AuditNavigationSidebarPanel.css

    r242395 r244039  
    5454}
    5555
    56 .sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view {
     56.sidebar > .panel.navigation.audit.has-results > .content > .message-text-view.no-enabled-audits {
    5757    position: initial;
    5858    border-bottom: 1px solid var(--border-color);
    59 }
    60 
    61 .sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view > .message {
    62     display: none;
    63 }
    64 
    65 .sidebar > .panel.navigation.audit.has-results:not(.has-tests) > .content > .message-text-view > button {
    66     margin: 8px 0 7px;
    6759}
    6860
  • trunk/Source/WebInspectorUI/UserInterface/Views/AuditNavigationSidebarPanel.js

    r242395 r244039  
    159159    _addTest(test)
    160160    {
    161         this.element.classList.add("has-tests");
    162 
    163161        let treeElement = new WI.AuditTreeElement(test);
    164162
     
    171169        this._updateStartStopButtonNavigationItemState();
    172170        this._updateEditButtonNavigationItemState();
    173 
    174         this.hideEmptyContentPlaceholder();
     171        this._updateNoAuditsPlaceholder();
    175172    }
    176173
     
    205202    {
    206203        this._startStopButtonNavigationItem.toggled = WI.auditManager.runningState === WI.AuditManager.RunningState.Active || WI.auditManager.runningState === WI.AuditManager.RunningState.Stopping;
    207         this._startStopButtonNavigationItem.enabled = WI.auditManager.tests.length && (WI.auditManager.runningState === WI.AuditManager.RunningState.Inactive || WI.auditManager.runningState === WI.AuditManager.RunningState.Active);
     204        this._startStopButtonNavigationItem.enabled = WI.auditManager.tests.some((test) => !test.disabled) && (WI.auditManager.runningState === WI.AuditManager.RunningState.Inactive || WI.auditManager.runningState === WI.AuditManager.RunningState.Active);
    208205    }
    209206
     
    217214    _updateNoAuditsPlaceholder()
    218215    {
    219         if (WI.auditManager.editing || WI.auditManager.tests.some((test) => !test.disabled))
    220             return;
    221 
    222         let contentPlaceholder = WI.createMessageTextView(WI.UIString("No Audits"));
    223 
    224         let defaultButtonElement = contentPlaceholder.appendChild(document.createElement("button"));
    225         defaultButtonElement.textContent = WI.UIString("Add Default Audits");
    226         defaultButtonElement.addEventListener("click", () => {
    227             WI.auditManager.addDefaultTestsIfNeeded();
    228         });
    229 
    230         contentPlaceholder = this.showEmptyContentPlaceholder(contentPlaceholder);
     216        if (WI.auditManager.editing || WI.auditManager.tests.some((test) => !test.disabled)) {
     217            if (!this.hasActiveFilters)
     218                this.hideEmptyContentPlaceholder();
     219            return;
     220        }
     221
     222        let contentPlaceholder = this.showEmptyContentPlaceholder(WI.UIString("No Enabled Audits"));
     223        contentPlaceholder.classList.add("no-enabled-audits");
    231224
    232225        if (WI.auditManager.results.length) {
    233             console.assert(this.contentTreeOutline.children[0] === this._resultsFolderTreeElement);
    234 
    235226            // Move the placeholder to be the first element in the content area, where it will
    236             // be styled such that only the button is visible.
     227            // be styled so that it doesn't obstruct the results elements.
    237228            this.contentView.element.insertBefore(contentPlaceholder, this.contentView.element.firstChild);
    238229        }
    239 
    240         this._updateEditButtonNavigationItemState();
    241230    }
    242231
     
    280269        this.contentTreeOutline.removeChild(treeElement);
    281270
    282         this.element.classList.toggle("has-tests", !!WI.auditManager.tests.length);
    283 
    284         this._updateStartStopButtonNavigationItemState();
     271        this._updateStartStopButtonNavigationItemState();
     272        this._updateEditButtonNavigationItemState();
    285273        this._updateNoAuditsPlaceholder();
    286274    }
Note: See TracChangeset for help on using the changeset viewer.