From 991b00f163db196684815dfc5b9b33bb0475327c Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 7 Feb 2020 15:14:52 -0800 Subject: [PATCH] Expand deepLinkPayload format for Network tab Summary: In order to select IDs in a different manner, I am introducing functionality to the Network plugin to allow it to accept more than just IDs that it has assigned, and add the ability to select this plugin with a default search term. I hope to use this to allow for selecting rows by request name. Reviewed By: mweststrate Differential Revision: D19702494 fbshipit-source-id: 58ea397fa30eb7d80e9640a4c92905de22bb27d4 --- src/plugins/network/index.tsx | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/plugins/network/index.tsx b/src/plugins/network/index.tsx index f8e84349a..8d6b8046c 100644 --- a/src/plugins/network/index.tsx +++ b/src/plugins/network/index.tsx @@ -39,6 +39,7 @@ type PersistedState = { type State = { selectedIds: Array; + searchTerm: string; }; const COLUMN_SIZE = { @@ -166,10 +167,27 @@ export default class extends FlipperPlugin { } }; - state = { - selectedIds: this.props.deepLinkPayload ? [this.props.deepLinkPayload] : [], + parseDeepLinkPayload = (deepLinkPayload: string | null) => { + const searchTermDelim = 'searchTerm='; + if (deepLinkPayload === null) { + return { + selectedIds: [], + searchTerm: '', + }; + } else if (deepLinkPayload.startsWith(searchTermDelim)) { + return { + selectedIds: [], + searchTerm: deepLinkPayload.slice(searchTermDelim.length), + }; + } + return { + selectedIds: [deepLinkPayload], + searchTerm: '', + }; }; + state = this.parseDeepLinkPayload(this.props.deepLinkPayload); + onRowHighlighted = (selectedIds: Array) => this.setState({selectedIds}); @@ -229,6 +247,7 @@ export default class extends FlipperPlugin { highlightedRows={ this.state.selectedIds ? new Set(this.state.selectedIds) : null } + searchTerm={this.state.searchTerm} /> {this.renderSidebar()} @@ -243,6 +262,7 @@ type NetworkTableProps = { copyRequestCurlCommand: () => void; onRowHighlighted: (keys: TableHighlightedRows) => void; highlightedRows: Set | null | undefined; + searchTerm: string; }; type NetworkTableState = { @@ -481,6 +501,7 @@ class NetworkTable extends PureComponent { allowBodySearch={true} zebra={false} actions={} + defaultSearchTerm={this.props.searchTerm} /> );