[Unified search] Display the solutions recommended queries in the help menu#223362
[Unified search] Display the solutions recommended queries in the help menu#223362stratoula merged 16 commits intoelastic:mainfrom
Conversation
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Unknown metric groupsAPI count
History
|
src/platform/plugins/shared/unified_search/public/query_string_input/esql_menu_popover.tsx
Show resolved
Hide resolved
sddonne
left a comment
There was a problem hiding this comment.
Looks nice! left two questions :)
src/platform/plugins/shared/unified_search/public/query_string_input/esql_menu_popover.tsx
Outdated
Show resolved
Hide resolved
src/platform/plugins/shared/unified_search/public/query_string_input/esql_menu_popover.tsx
Outdated
Show resolved
Hide resolved
| try { | ||
| // Fetch ESQL solutions recommended queries from the registry | ||
| const queriesFromRegistry: RecommendedQuery[] = await http.get( | ||
| `/internal/esql_registry/extensions/${activeSolutionId}/${queryForRecommendedQueries}` |
There was a problem hiding this comment.
Should this route be a constant imported from @kbn/esql-types?
| solutionsRecommendedQueries, | ||
| ]); | ||
|
|
||
| const toggleLanguageComponent = useCallback(async () => { |
There was a problem hiding this comment.
Why is toggleLanguageComponent callback async?
There was a problem hiding this comment.
It shouldn't and I fixed it here 552bf1d but is irrelevant with my changes
| panelProps={{ | ||
| ['data-test-subj']: 'esql-menu-popover', | ||
| css: { width: 240 }, | ||
| css: css` |
There was a problem hiding this comment.
The rule of thumb would be that if the style has less than 5 lines (and it's the only css tag in the component), it doesn't have to. However, since it doesn't have to be memoized but can be just defined outside, I'd move it outside of component so it gets serialized only once.
const esqlMenuPopoverStyles = css`
width: 240px;
max-height: 350px;
overflow-y: auto;
${useEuiScrollBar()};
`
and then here:
| css: css` | |
| css: esqlMenuPopoverStyles |
| renderESQLPopover(); | ||
|
|
||
| // Assert that http.get was NOT called | ||
| await waitFor(() => { |
There was a problem hiding this comment.
This assertion has a race condition. httpModule.http.get is called inside a useEffect, meaning that its called after the component has rendered. expect(httpModule.http.get).not.toHaveBeenCalled() is true before useEffect is executed.
There was a problem hiding this comment.
Removed them after discussing async with Nate 375ae6c
| renderESQLPopover(stubIndexPattern); | ||
|
|
||
| // Assert that http.get was NOT called | ||
| await waitFor(() => { |
There was a problem hiding this comment.
This assertion has a race condition. httpModule.http.get is called inside a useEffect, meaning that its called after the component has rendered. expect(httpModule.http.get).not.toHaveBeenCalled() is true before useEffect is executed.
There was a problem hiding this comment.
Removed them after discussing async with Nate 375ae6c
|
Starting backport for target branches: 8.19 https://github.com/elastic/kibana/actions/runs/15615598206 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
…p menu (#223602) ## Summary Reopening of #223362 In #221474 we introduced the mechanism to register queries per solution at the editor. This PR displays these queries in the unified search menu too. In the following screenshot the 2 first queries are the oblt solution registered queries. I also have a max-height just to be sure that this list doesnt get too long now that the solutions can register queries. <img width="439" alt="image" src="https://github.com/user-attachments/assets/8ca48b8a-1880-42f3-944f-dd1fb012661f" /> ### Note This change won't display anything in the popover as no solution has registered any queries yet. This PR sets the mechanism though on when they will do so. ### How to test If you want to test it the fastest way is to go to the esql plugin (server side) and add (change the examples as you wish): ``` this.extensionsRegistry.setRecommendedQueries( [ { name: 'Logs count by log level', query: 'from logs* | STATS count(*) by log_level', }, { name: 'Apache logs counts', query: 'from logs-apache_error | STATS count(*)', }, { name: 'Another index, not logs', query: 'from movies | STATS count(*)', }, ], 'oblt' ); ``` Then go to Discover (solutions mode) and type `from logs*` and hit the query. Open the popover and check the 2 first recommendations are been suggested. ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios <!--ONMERGE {"backportTargets":["8.19"]} ONMERGE--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…p menu (elastic#223362) ## Summary In elastic#221474 we introduced the mechanism to register queries per solution at the editor. This PR displays these queries in the unified search menu too. In the following screenshot the 2 first queries are the oblt solution registered queries. I also have a max-height just to be sure that this list doesnt get too long now that the solutions can register queries. <img width="439" alt="image" src="https://github.com/user-attachments/assets/8ca48b8a-1880-42f3-944f-dd1fb012661f" /> ### Note This change won't display anything in the popover as no solution has registered any queries yet. This PR sets the mechanism though on when they will do so. ### How to test If you want to test it the fastest way is to go to the esql plugin (server side) and add (change the examples as you wish): ``` this.extensionsRegistry.setRecommendedQueries( [ { name: 'Logs count by log level', query: 'from logs* | STATS count(*) by log_level', }, { name: 'Apache logs counts', query: 'from logs-apache_error | STATS count(*)', }, { name: 'Another index, not logs', query: 'from movies | STATS count(*)', }, ], 'oblt' ); ``` Then go to Discover (solutions mode) and type `from logs*` and hit the query. Open the popover and check the 2 first recommendations are been suggested. ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
… the help menu" (elastic#223598) Reverts elastic#223362 I accidentally merged the previous PR, I am so sorry. I am reverting and open it again to get the presentation team approval
…p menu (elastic#223602) ## Summary Reopening of elastic#223362 In elastic#221474 we introduced the mechanism to register queries per solution at the editor. This PR displays these queries in the unified search menu too. In the following screenshot the 2 first queries are the oblt solution registered queries. I also have a max-height just to be sure that this list doesnt get too long now that the solutions can register queries. <img width="439" alt="image" src="https://github.com/user-attachments/assets/8ca48b8a-1880-42f3-944f-dd1fb012661f" /> ### Note This change won't display anything in the popover as no solution has registered any queries yet. This PR sets the mechanism though on when they will do so. ### How to test If you want to test it the fastest way is to go to the esql plugin (server side) and add (change the examples as you wish): ``` this.extensionsRegistry.setRecommendedQueries( [ { name: 'Logs count by log level', query: 'from logs* | STATS count(*) by log_level', }, { name: 'Apache logs counts', query: 'from logs-apache_error | STATS count(*)', }, { name: 'Another index, not logs', query: 'from movies | STATS count(*)', }, ], 'oblt' ); ``` Then go to Discover (solutions mode) and type `from logs*` and hit the query. Open the popover and check the 2 first recommendations are been suggested. ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios <!--ONMERGE {"backportTargets":["8.19"]} ONMERGE--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…p menu (elastic#223602) ## Summary Reopening of elastic#223362 In elastic#221474 we introduced the mechanism to register queries per solution at the editor. This PR displays these queries in the unified search menu too. In the following screenshot the 2 first queries are the oblt solution registered queries. I also have a max-height just to be sure that this list doesnt get too long now that the solutions can register queries. <img width="439" alt="image" src="https://github.com/user-attachments/assets/8ca48b8a-1880-42f3-944f-dd1fb012661f" /> ### Note This change won't display anything in the popover as no solution has registered any queries yet. This PR sets the mechanism though on when they will do so. ### How to test If you want to test it the fastest way is to go to the esql plugin (server side) and add (change the examples as you wish): ``` this.extensionsRegistry.setRecommendedQueries( [ { name: 'Logs count by log level', query: 'from logs* | STATS count(*) by log_level', }, { name: 'Apache logs counts', query: 'from logs-apache_error | STATS count(*)', }, { name: 'Another index, not logs', query: 'from movies | STATS count(*)', }, ], 'oblt' ); ``` Then go to Discover (solutions mode) and type `from logs*` and hit the query. Open the popover and check the 2 first recommendations are been suggested. ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios <!--ONMERGE {"backportTargets":["8.19"]} ONMERGE--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 563abe2) # Conflicts: # src/platform/plugins/shared/unified_search/public/search_bar/search_bar.test.tsx
Summary
In #221474 we introduced the mechanism to register queries per solution at the editor.
This PR displays these queries in the unified search menu too. In the following screenshot the 2 first queries are the oblt solution registered queries. I also have a max-height just to be sure that this list doesnt get too long now that the solutions can register queries.
Note
This change won't display anything in the popover as no solution has registered any queries yet. This PR sets the mechanism though on when they will do so.
How to test
If you want to test it the fastest way is to go to the esql plugin (server side) and add (change the examples as you wish):
Then go to Discover (solutions mode) and type
from logs*and hit the query. Open the popover and check the 2 first recommendations are been suggested.Checklist