Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export class CodeQueryBar extends Component<Props, State> {

public inputRef: HTMLInputElement | null = null;

public optionFlyout: any | null = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems not right


private componentIsUnmounting = false;

public isDirty = () => {
Expand Down Expand Up @@ -384,6 +386,12 @@ export class CodeQueryBar extends Component<Props, State> {
}
}

public toggleOptionsFlyout() {
if (this.optionFlyout) {
this.optionFlyout.toggleOptionsFlyout();
}
}

public render() {
const inputRef = (node: HTMLInputElement | null) => {
if (node) {
Expand Down Expand Up @@ -442,6 +450,7 @@ export class CodeQueryBar extends Component<Props, State> {
repoSearchResults={this.props.repoSearchResults}
searchLoading={this.props.searchLoading}
searchOptions={this.props.searchOptions}
ref={element => (this.optionFlyout = element)}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ export const EmptyPlaceholder = (props: any) => {
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton fill={true}>Modify your search settings</EuiButton>
<EuiButton
fill={true}
onClick={() => {
if (props.toggleOptionsFlyout) {
props.toggleOptionsFlyout();
}
}}
>
Modify your search settings
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
);
Expand Down
13 changes: 12 additions & 1 deletion x-pack/plugins/code/public/components/search_page/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class SearchPage extends React.PureComponent<Props, State> {
public state = {
uri: '',
};

public searchBar: any = null;

public componentDidMount() {
chrome.breadcrumbs.push({ text: `Search` });
}
Expand Down Expand Up @@ -142,7 +145,14 @@ class SearchPage extends React.PureComponent<Props, State> {
repositorySearchResults,
} = this.props;

let mainComp = <EmptyPlaceholder query={query} />;
let mainComp = (
<EmptyPlaceholder
query={query}
toggleOptionsFlyout={() => {
this.searchBar.toggleOptionsFlyout();
}}
/>
);
let repoStats: any[] = [];
let languageStats: any[] = [];
if (
Expand Down Expand Up @@ -227,6 +237,7 @@ class SearchPage extends React.PureComponent<Props, State> {
repoScope={this.props.searchOptions.repoScope.map(r => r.uri)}
query={this.props.query}
onSearchScopeChanged={this.props.onSearchScopeChanged}
ref={element => (this.searchBar = element)}
/>
{mainComp}
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface Props {
}

export class SearchBar extends React.PureComponent<Props> {
public queryBar: any | null = null;
public queryBar: any = null;

public onSearchChanged = (query: string) => {
// Update the url and push to history as well.
Expand All @@ -45,6 +45,12 @@ export class SearchBar extends React.PureComponent<Props> {
);
};

public toggleOptionsFlyout() {
if (this.queryBar) {
this.queryBar.toggleOptionsFlyout();
}
}

public render() {
const onSubmit = (q: string) => {
this.onSearchChanged(q);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/code/server/indexer/lsp_indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down