Web Inspector: Search: there should be some default content when there is no search string
https://bugs.webkit.org/show_bug.cgi?id=204631

Reviewed by Timothy Hatcher.

It's very odd to switch to the Search Tab and find it completely empty, especially if you've
never used it before.

Add basic "No Search String" and "No Search Results" text with a clickable help navigation
item that reveals and focuses the sidebar search input.

* UserInterface/Views/SearchSidebarPanel.js:
(WI.SearchSidebarPanel.prototype.showDefaultContentView): Added.
(WI.SearchSidebarPanel.prototype.performSearch):
(WI.SearchSidebarPanel.prototype._handleDefaultContentViewSearchNavigationItemClicked): Added.

* Localizations/en.lproj/localizedStrings.js:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@253165 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog
index b60f1a3..1a4a2231 100644
--- a/Source/WebInspectorUI/ChangeLog
+++ b/Source/WebInspectorUI/ChangeLog
@@ -1,5 +1,25 @@
 2019-12-05  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Search: there should be some default content when there is no search string
+        https://bugs.webkit.org/show_bug.cgi?id=204631
+
+        Reviewed by Timothy Hatcher.
+
+        It's very odd to switch to the Search Tab and find it completely empty, especially if you've
+        never used it before.
+
+        Add basic "No Search String" and "No Search Results" text with a clickable help navigation
+        item that reveals and focuses the sidebar search input.
+
+        * UserInterface/Views/SearchSidebarPanel.js:
+        (WI.SearchSidebarPanel.prototype.showDefaultContentView): Added.
+        (WI.SearchSidebarPanel.prototype.performSearch):
+        (WI.SearchSidebarPanel.prototype._handleDefaultContentViewSearchNavigationItemClicked): Added.
+
+        * Localizations/en.lproj/localizedStrings.js:
+
+2019-12-05  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: move the "Add Breakpoint" context menu to be next to the blackboxing context menu item
         https://bugs.webkit.org/show_bug.cgi?id=204833
 
diff --git a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
index d3ca407..f9dcdbd 100644
--- a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
+++ b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
@@ -784,6 +784,8 @@
 localizedStrings["No request, served from the memory cache."] = "No request, served from the memory cache.";
 localizedStrings["No response cookies."] = "No response cookies.";
 localizedStrings["No response headers"] = "No response headers";
+localizedStrings["No search results"] = "No search results";
+localizedStrings["No search string"] = "No search string";
 localizedStrings["Node"] = "Node";
 /* A submenu item of 'Break On' that breaks (pauses) before DOM node is removed */
 localizedStrings["Node Removed"] = "Node Removed";
@@ -857,6 +859,7 @@
 localizedStrings["Preserve Log"] = "Preserve Log";
 localizedStrings["Press %s to import a test or result file"] = "Press %s to import a test or result file";
 localizedStrings["Press %s to load a recording from file."] = "Press %s to load a recording from file.";
+localizedStrings["Press %s to see recent searches"] = "Press %s to see recent searches";
 localizedStrings["Press %s to start running the audit"] = "Press %s to start running the audit";
 localizedStrings["Press %s to stop editing"] = "Press %s to stop editing";
 localizedStrings["Pressed"] = "Pressed";
diff --git a/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js b/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js
index fe82031..c2ae1da 100644
--- a/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js
+++ b/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js
@@ -61,6 +61,22 @@
 
     // Public
 
+    showDefaultContentView()
+    {
+        let contentView = new WI.ContentView;
+
+        let contentPlaceholder = WI.createMessageTextView(this._searchQuerySetting.value ? WI.UIString("No search results") : WI.UIString("No search string"));
+        contentView.element.appendChild(contentPlaceholder);
+
+        let searchNavigationItem = new WI.ButtonNavigationItem("search", WI.UIString("Search Resource Content"), "Images/Search.svg", 15, 15);
+        searchNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleDefaultContentViewSearchNavigationItemClicked, this);
+
+        let importHelpElement = WI.createNavigationItemHelp(WI.UIString("Press %s to see recent searches"), searchNavigationItem);
+        contentPlaceholder.appendChild(importHelpElement);
+
+        this.contentBrowser.showContentView(contentView);
+    }
+
     closed()
     {
         super.closed();
@@ -97,8 +113,10 @@
         if (this._changedBanner)
             this._changedBanner.remove();
 
-        if (!searchQuery.length)
+        if (!searchQuery.length) {
+            this.showDefaultContentView();
             return;
+        }
 
         let createSearchingPlaceholder = () => {
             let searchingPlaceholder = WI.createMessageTextView("");
@@ -133,8 +151,12 @@
 
             --promiseCount;
             console.assert(promiseCount >= 0);
-            if (promiseCount === 0)
+            if (promiseCount === 0) {
                 this.updateEmptyContentPlaceholder(WI.UIString("No Search Results"));
+
+                if (!this.contentTreeOutline.children.length)
+                    this.showDefaultContentView();
+            }
         };
 
         let isCaseSensitive = !!this._searchInputSettings.caseSensitive.value;
@@ -445,4 +467,9 @@
 
         this.element.appendChild(this._changedBanner);
     }
+
+    _handleDefaultContentViewSearchNavigationItemClicked(event)
+    {
+        this.focusSearchField();
+    }
 };