Search with both name and id of the component in layout inspector and handle deeplinkpayload

Summary:
deepLinkPayload is passed as initialQuery to Search component and in componentDidMount we perform search if initially query is defined.

This does not handle the case if node is not present in the layout inspector tree.

Reviewed By: danielbuechele

Differential Revision: D15874343

fbshipit-source-id: c604baea16838f07e8f8bfc0f1e67c5e830dfe97
This commit is contained in:
Sidharth Guglani
2019-06-19 09:04:58 -07:00
committed by Facebook Github Bot
parent 8bc26378f0
commit 5a6d978536
3 changed files with 19 additions and 2 deletions

View File

@@ -396,7 +396,7 @@ public class DebugComponentDescriptor extends NodeDescriptor<DebugComponent> {
@Override @Override
public boolean matches(String query, DebugComponent node) throws Exception { public boolean matches(String query, DebugComponent node) throws Exception {
NodeDescriptor descriptor = descriptorForClass(Object.class); NodeDescriptor descriptor = descriptorForClass(Object.class);
return descriptor.matches(query, node); return descriptor.matches(query, node) || getId(node).equals(query);
} }
private static void applyLayoutOverride( private static void applyLayoutOverride(

View File

@@ -33,6 +33,7 @@ type Props = {
onSearchResults: (searchResults: ElementSearchResultSet) => void, onSearchResults: (searchResults: ElementSearchResultSet) => void,
setPersistedState: (state: $Shape<PersistedState>) => void, setPersistedState: (state: $Shape<PersistedState>) => void,
persistedState: PersistedState, persistedState: PersistedState,
initialQuery: ?string,
}; };
type State = { type State = {
@@ -67,6 +68,16 @@ export default class Search extends Component<Props, State> {
} }
}; };
componentDidMount() {
if (this.props.initialQuery) {
const queryString = this.props.initialQuery
? this.props.initialQuery
: '';
clearTimeout(this.timer);
this.timer = setTimeout(() => this.performSearch(queryString), 200);
}
}
performSearch(query: string) { performSearch(query: string) {
this.setState({ this.setState({
outstandingSearchQuery: query, outstandingSearchQuery: query,

View File

@@ -94,7 +94,12 @@ export default class Layout extends FlipperPlugin<State, void, PersistedState> {
} }
}); });
this.setState({init: true}); this.setState({
init: true,
selectedElement: this.props.deepLinkPayload
? this.props.deepLinkPayload
: null,
});
} }
onToggleTargetMode = () => { onToggleTargetMode = () => {
@@ -201,6 +206,7 @@ export default class Layout extends FlipperPlugin<State, void, PersistedState> {
this.setState({searchResults}) this.setState({searchResults})
} }
inAXMode={this.state.inAXMode} inAXMode={this.state.inAXMode}
initialQuery={this.props.deepLinkPayload}
/> />
</Toolbar> </Toolbar>