Web Inspector: Network Tab - Add HAR Export button
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Nov 2017 23:32:49 +0000 (23:32 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Nov 2017 23:32:49 +0000 (23:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179570
<rdar://problem/35484918>

Reviewed by Matt Baker.

* Localizations/en.lproj/localizedStrings.js:
New strings.

* UserInterface/Images/Export.svg: Added.
* UserInterface/Images/Import.svg: Added.
Add symmetric import/export buttons.

* UserInterface/Base/Main.js:
(WI.contentLoaded):
Expose the save keyboard shortcut so we can show its display name in a tooltip.

* UserInterface/Views/NetworkTableContentView.js:
(WI.NetworkTableContentView):
(WI.NetworkTableContentView.prototype.get navigationItems):
(WI.NetworkTableContentView.prototype.reset):
(WI.NetworkTableContentView.prototype.layout):
(WI.NetworkTableContentView.prototype._updateExportButton):
Include the export button and enable/disable it when appropriate.

(WI.NetworkTableContentView.prototype.closed):
Add a missing event listener removal.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Images/Export.svg [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Images/Import.svg [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js

index 6c35463..a781586 100644 (file)
@@ -1,3 +1,33 @@
+2017-11-17  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Network Tab - Add HAR Export button
+        https://bugs.webkit.org/show_bug.cgi?id=179570
+        <rdar://problem/35484918>
+
+        Reviewed by Matt Baker.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        New strings.
+
+        * UserInterface/Images/Export.svg: Added.
+        * UserInterface/Images/Import.svg: Added.
+        Add symmetric import/export buttons.
+
+        * UserInterface/Base/Main.js:
+        (WI.contentLoaded):
+        Expose the save keyboard shortcut so we can show its display name in a tooltip.
+
+        * UserInterface/Views/NetworkTableContentView.js:
+        (WI.NetworkTableContentView):
+        (WI.NetworkTableContentView.prototype.get navigationItems):
+        (WI.NetworkTableContentView.prototype.reset):
+        (WI.NetworkTableContentView.prototype.layout):
+        (WI.NetworkTableContentView.prototype._updateExportButton):
+        Include the export button and enable/disable it when appropriate.
+
+        (WI.NetworkTableContentView.prototype.closed):
+        Add a missing event listener removal.
+
 2017-11-17  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: Disabled ImageAndText-style buttons should have gray text
index bba8391..42203a3 100644 (file)
@@ -459,6 +459,7 @@ localizedStrings["Group by Event"] = "Group by Event";
 localizedStrings["Group by Node"] = "Group by Node";
 localizedStrings["Grouping Method"] = "Grouping Method";
 localizedStrings["Grow"] = "Grow";
+localizedStrings["HAR Export (%s)"] = "HAR Export (%s)";
 localizedStrings["HTML"] = "HTML";
 localizedStrings["HTML Attributes"] = "HTML Attributes";
 localizedStrings["HTTP"] = "HTTP";
index f1d5182..40bc9a6 100644 (file)
@@ -303,7 +303,7 @@ WI.contentLoaded = function()
 
     this.searchKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl | WI.KeyboardShortcut.Modifier.Shift, "F", this._focusSearchField.bind(this));
     this._findKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl, "F", this._find.bind(this));
-    this._saveKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl, "S", this._save.bind(this));
+    this.saveKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl, "S", this._save.bind(this));
     this._saveAsKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.Shift | WI.KeyboardShortcut.Modifier.CommandOrControl, "S", this._saveAs.bind(this));
 
     this.openResourceKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl | WI.KeyboardShortcut.Modifier.Shift, "O", this._showOpenResourceDialog.bind(this));
diff --git a/Source/WebInspectorUI/UserInterface/Images/Export.svg b/Source/WebInspectorUI/UserInterface/Images/Export.svg
new file mode 100644 (file)
index 0000000..9ac2558
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright © 2017 Apple Inc. All rights reserved. -->
+<svg xmlns="http://www.w3.org/2000/svg" id="root" viewBox="0 0 15 15">
+    <path fill="none" stroke="currentColor" d="M 7.5 2 v 7.5"/>
+    <path fill="none" stroke="currentColor" d="M 4.5 5 l 3 -3 l 3 3"/>
+    <polyline fill="none" stroke="currentColor" points="12.5 9 12.5 12.5 2.5 12.5 2.5 9"/>
+</svg>
diff --git a/Source/WebInspectorUI/UserInterface/Images/Import.svg b/Source/WebInspectorUI/UserInterface/Images/Import.svg
new file mode 100644 (file)
index 0000000..efa3e3e
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright © 2017 Apple Inc. All rights reserved. -->
+<svg xmlns="http://www.w3.org/2000/svg" id="root" viewBox="0 0 15 15">
+    <path fill="none" stroke="currentColor" d="M 7.5 8.5 V 1"/>
+    <path fill="none" stroke="currentColor" d="M 10.5 5.5 l -3, 3 l -3 -3"/>    
+    <polyline fill="none" stroke="currentColor" points="12.5 9 12.5 12.5 2.5 12.5 2.5 9"/>
+</svg>
index c973314..db18aa4 100644 (file)
@@ -50,7 +50,6 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
 
         // FIXME: Network Timeline.
         // FIXME: Throttling.
-        // FIXME: HAR Export.
 
         const exclusive = true;
         this._typeFilterScopeBarItemAll = new WI.ScopeBarItem("network-type-filter-all", WI.UIString("All"), exclusive);
@@ -89,6 +88,11 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
 
         this._emptyFilterResultsMessageElement = null;
 
+        this._harExportNavigationItem = new WI.ButtonNavigationItem("har-export", WI.UIString("Export"), "Images/Export.svg", 15, 15);
+        this._harExportNavigationItem.buttonStyle = WI.ButtonNavigationItem.Style.ImageAndText;
+        this._harExportNavigationItem.toolTip = WI.UIString("HAR Export (%s)").format(WI.saveKeyboardShortcut.displayName);
+        this._harExportNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => { this._exportHAR(); });
+
         // COMPATIBILITY (iOS 10.3): Network.setDisableResourceCaching did not exist.
         if (window.NetworkAgent && NetworkAgent.setResourceCachingDisabled) {
             let toolTipForDisableResourceCache = WI.UIString("Ignore the resource cache when loading resources");
@@ -101,7 +105,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         }
 
         this._clearNetworkItemsNavigationItem = new WI.ButtonNavigationItem("clear-network-items", WI.UIString("Clear Network Items (%s)").format(WI.clearKeyboardShortcut.displayName), "Images/NavigationItemTrash.svg", 15, 15);
-        this._clearNetworkItemsNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => this.reset());
+        this._clearNetworkItemsNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => { this.reset(); });
 
         WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
         WI.Resource.addEventListener(WI.Resource.Event.LoadingDidFinish, this._resourceLoadingDidFinish, this);
@@ -169,7 +173,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
 
     get navigationItems()
     {
-        let items = [];
+        let items = [this._harExportNavigationItem, new WI.DividerNavigationItem];
         if (this._disableResourceCacheNavigationItem)
             items.push(this._disableResourceCacheNavigationItem);
         items.push(this._clearNetworkItemsNavigationItem);
@@ -227,6 +231,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
 
         WI.Frame.removeEventListener(null, null, this);
         WI.Resource.removeEventListener(null, null, this);
+        WI.resourceCachingDisabledSetting.removeEventListener(null, null, this);
         WI.frameResourceManager.removeEventListener(WI.FrameResourceManager.Event.MainFrameDidChange, this._mainFrameDidChange, this);
         WI.timelineManager.persistentNetworkTimeline.removeEventListener(WI.Timeline.Event.RecordAdded, this._networkTimelineRecordAdded, this);
 
@@ -246,6 +251,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         this._waterfallStartTime = NaN;
         this._waterfallEndTime = NaN;
         this._updateWaterfallTimelineRuler();
+        this._updateExportButton();
 
         if (this._table) {
             this._selectedResource = null;
@@ -779,6 +785,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         this._processPendingEntries();
         this._positionDetailView();
         this._positionEmptyFilterMessage();
+        this._updateExportButton();
     }
 
     handleClearShortcut(event)
@@ -811,6 +818,12 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         }
     }
 
+    _updateExportButton()
+    {
+        let enabled = this._filteredEntries.length > 0;
+        this._harExportNavigationItem.enabled = enabled;
+    }
+
     _processPendingEntries()
     {
         let needsSort = this._pendingUpdates.length > 0;