Add 'Copy message' context menu item for EventSource messages.

This CL adds a "Copy message" context menu item for EventSource messages in the DevTools network panel. This context menu item copies the data from the selected EventSource message.

Bug: 1111375
Change-Id: I1b531badfbc2417612a2500482bd8cd772bcfb4e
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2329393
Reviewed-by: Jan Scheffler <janscheffler@chromium.org>
Commit-Queue: Jan Scheffler <janscheffler@chromium.org>
This commit is contained in:
Ted Janeczko
2020-07-31 17:45:10 +00:00
committed by Commit Bot
parent 86ae5bdefd
commit 0850835a02
@@ -7,6 +7,7 @@
import * as Common from '../common/common.js';
import * as DataGrid from '../data_grid/data_grid.js';
import * as Host from '../host/host.js';
import * as SDK from '../sdk/sdk.js';
import * as UI from '../ui/ui.js';
@@ -33,6 +34,7 @@ export class EventSourceMessagesView extends UI.Widget.VBox {
this._dataGrid = new DataGrid.SortableDataGrid.SortableDataGrid({displayName: ls`Event Source`, columns});
this._dataGrid.setStriped(true);
this._dataGrid.setStickToBottom(true);
this._dataGrid.setRowContextMenuCallback(this._onRowContextMenu.bind(this));
this._dataGrid.markColumnAsSortedBy('time', DataGrid.DataGrid.Order.Ascending);
this._sortItems();
this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, this._sortItems, this);
@@ -80,6 +82,17 @@ export class EventSourceMessagesView extends UI.Widget.VBox {
}
this._dataGrid.sortNodes(comparator, !this._dataGrid.isSortOrderAscending());
}
/**
* @param {!UI.ContextMenu.ContextMenu} contextMenu
* @param {!DataGrid.DataGrid.DataGridNode<!EventSourceMessageNode>} node
*/
_onRowContextMenu(contextMenu, node) {
contextMenu.clipboardSection().appendItem(
Common.UIString.UIString('Copy message'),
Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText.bind(
Host.InspectorFrontendHost.InspectorFrontendHostInstance, node.data.data));
}
}
/**