Skip to content

Commit 3694d07

Browse files
authored
[Code] connect the modify search settings button with the search scope settings (#33691)
* [Code] connect the modify search settings button with the search scope setting * [Code] a minor fix * [Code] minor style improvement
1 parent e509652 commit 3694d07

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

x-pack/plugins/code/public/components/query_bar/components/query_bar.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ export class CodeQueryBar extends Component<Props, State> {
109109

110110
public inputRef: HTMLInputElement | null = null;
111111

112+
public optionFlyout: any | null = null;
113+
112114
private componentIsUnmounting = false;
113115

114116
public isDirty = () => {
@@ -384,6 +386,12 @@ export class CodeQueryBar extends Component<Props, State> {
384386
}
385387
}
386388

389+
public toggleOptionsFlyout() {
390+
if (this.optionFlyout) {
391+
this.optionFlyout.toggleOptionsFlyout();
392+
}
393+
}
394+
387395
public render() {
388396
const inputRef = (node: HTMLInputElement | null) => {
389397
if (node) {
@@ -442,6 +450,7 @@ export class CodeQueryBar extends Component<Props, State> {
442450
repoSearchResults={this.props.repoSearchResults}
443451
searchLoading={this.props.searchLoading}
444452
searchOptions={this.props.searchOptions}
453+
ref={element => (this.optionFlyout = element)}
445454
/>
446455
</div>
447456
</div>

x-pack/plugins/code/public/components/search_page/empty_placeholder.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ export const EmptyPlaceholder = (props: any) => {
2828
</EuiText>
2929
</EuiFlexItem>
3030
<EuiFlexItem grow={false}>
31-
<EuiButton fill={true}>Modify your search settings</EuiButton>
31+
<EuiButton
32+
fill={true}
33+
onClick={() => {
34+
if (props.toggleOptionsFlyout) {
35+
props.toggleOptionsFlyout();
36+
}
37+
}}
38+
>
39+
Modify your search settings
40+
</EuiButton>
3241
</EuiFlexItem>
3342
</EuiFlexGroup>
3443
);

x-pack/plugins/code/public/components/search_page/search.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class SearchPage extends React.PureComponent<Props, State> {
6666
public state = {
6767
uri: '',
6868
};
69+
70+
public searchBar: any = null;
71+
6972
public componentDidMount() {
7073
chrome.breadcrumbs.push({ text: `Search` });
7174
}
@@ -142,7 +145,14 @@ class SearchPage extends React.PureComponent<Props, State> {
142145
repositorySearchResults,
143146
} = this.props;
144147

145-
let mainComp = <EmptyPlaceholder query={query} />;
148+
let mainComp = (
149+
<EmptyPlaceholder
150+
query={query}
151+
toggleOptionsFlyout={() => {
152+
this.searchBar.toggleOptionsFlyout();
153+
}}
154+
/>
155+
);
146156
let repoStats: any[] = [];
147157
let languageStats: any[] = [];
148158
if (
@@ -227,6 +237,7 @@ class SearchPage extends React.PureComponent<Props, State> {
227237
repoScope={this.props.searchOptions.repoScope.map(r => r.uri)}
228238
query={this.props.query}
229239
onSearchScopeChanged={this.props.onSearchScopeChanged}
240+
ref={element => (this.searchBar = element)}
230241
/>
231242
{mainComp}
232243
</EuiFlexItem>

x-pack/plugins/code/public/components/search_page/search_bar.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface Props {
2828
}
2929

3030
export class SearchBar extends React.PureComponent<Props> {
31-
public queryBar: any | null = null;
31+
public queryBar: any = null;
3232

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

48+
public toggleOptionsFlyout() {
49+
if (this.queryBar) {
50+
this.queryBar.toggleOptionsFlyout();
51+
}
52+
}
53+
4854
public render() {
4955
const onSubmit = (q: string) => {
5056
this.onSearchChanged(q);

x-pack/plugins/code/server/indexer/lsp_indexer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export class LspIndexer extends AbstractIndexer {
180180
reference: this.options.enableGlobalReference,
181181
});
182182

183-
if (response && response.result.length > 0) {
183+
if (response && response.result && response.result.length > 0 && response.result[0]) {
184184
const { symbols, references } = response.result[0];
185185
for (const symbol of symbols) {
186186
await this.batchIndexHelper.index(SymbolIndexName(repoUri), symbol);

0 commit comments

Comments
 (0)