diff --git a/x-pack/plugins/code/public/components/query_bar/components/query_bar.tsx b/x-pack/plugins/code/public/components/query_bar/components/query_bar.tsx index 386f88243033b..922b6fac4bee8 100644 --- a/x-pack/plugins/code/public/components/query_bar/components/query_bar.tsx +++ b/x-pack/plugins/code/public/components/query_bar/components/query_bar.tsx @@ -109,6 +109,8 @@ export class CodeQueryBar extends Component { public inputRef: HTMLInputElement | null = null; + public optionFlyout: any | null = null; + private componentIsUnmounting = false; public isDirty = () => { @@ -384,6 +386,12 @@ export class CodeQueryBar extends Component { } } + public toggleOptionsFlyout() { + if (this.optionFlyout) { + this.optionFlyout.toggleOptionsFlyout(); + } + } + public render() { const inputRef = (node: HTMLInputElement | null) => { if (node) { @@ -442,6 +450,7 @@ export class CodeQueryBar extends Component { repoSearchResults={this.props.repoSearchResults} searchLoading={this.props.searchLoading} searchOptions={this.props.searchOptions} + ref={element => (this.optionFlyout = element)} /> diff --git a/x-pack/plugins/code/public/components/search_page/empty_placeholder.tsx b/x-pack/plugins/code/public/components/search_page/empty_placeholder.tsx index 5f9417ca56f0d..4655efa79310e 100644 --- a/x-pack/plugins/code/public/components/search_page/empty_placeholder.tsx +++ b/x-pack/plugins/code/public/components/search_page/empty_placeholder.tsx @@ -28,7 +28,16 @@ export const EmptyPlaceholder = (props: any) => { - Modify your search settings + { + if (props.toggleOptionsFlyout) { + props.toggleOptionsFlyout(); + } + }} + > + Modify your search settings + ); diff --git a/x-pack/plugins/code/public/components/search_page/search.tsx b/x-pack/plugins/code/public/components/search_page/search.tsx index ec4374845f669..67f2925fca100 100644 --- a/x-pack/plugins/code/public/components/search_page/search.tsx +++ b/x-pack/plugins/code/public/components/search_page/search.tsx @@ -66,6 +66,9 @@ class SearchPage extends React.PureComponent { public state = { uri: '', }; + + public searchBar: any = null; + public componentDidMount() { chrome.breadcrumbs.push({ text: `Search` }); } @@ -142,7 +145,14 @@ class SearchPage extends React.PureComponent { repositorySearchResults, } = this.props; - let mainComp = ; + let mainComp = ( + { + this.searchBar.toggleOptionsFlyout(); + }} + /> + ); let repoStats: any[] = []; let languageStats: any[] = []; if ( @@ -227,6 +237,7 @@ class SearchPage extends React.PureComponent { repoScope={this.props.searchOptions.repoScope.map(r => r.uri)} query={this.props.query} onSearchScopeChanged={this.props.onSearchScopeChanged} + ref={element => (this.searchBar = element)} /> {mainComp} diff --git a/x-pack/plugins/code/public/components/search_page/search_bar.tsx b/x-pack/plugins/code/public/components/search_page/search_bar.tsx index 0775bf5da0b32..5348a36d2204f 100644 --- a/x-pack/plugins/code/public/components/search_page/search_bar.tsx +++ b/x-pack/plugins/code/public/components/search_page/search_bar.tsx @@ -28,7 +28,7 @@ interface Props { } export class SearchBar extends React.PureComponent { - public queryBar: any | null = null; + public queryBar: any = null; public onSearchChanged = (query: string) => { // Update the url and push to history as well. @@ -45,6 +45,12 @@ export class SearchBar extends React.PureComponent { ); }; + public toggleOptionsFlyout() { + if (this.queryBar) { + this.queryBar.toggleOptionsFlyout(); + } + } + public render() { const onSubmit = (q: string) => { this.onSearchChanged(q); diff --git a/x-pack/plugins/code/server/indexer/lsp_indexer.ts b/x-pack/plugins/code/server/indexer/lsp_indexer.ts index fff532164a0ee..a0d7f496a8f8b 100644 --- a/x-pack/plugins/code/server/indexer/lsp_indexer.ts +++ b/x-pack/plugins/code/server/indexer/lsp_indexer.ts @@ -180,7 +180,7 @@ export class LspIndexer extends AbstractIndexer { reference: this.options.enableGlobalReference, }); - if (response && response.result.length > 0) { + if (response && response.result && response.result.length > 0 && response.result[0]) { const { symbols, references } = response.result[0]; for (const symbol of symbols) { await this.batchIndexHelper.index(SymbolIndexName(repoUri), symbol);