opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.66k stars 868 forks source link

[CCI] Standardize error handling for query input in the SearchBar #4182

Open SergeyMyssak opened 1 year ago

SergeyMyssak commented 1 year ago

Is your feature request related to a problem? Please describe.

After auditing advanced_settings and saved_objects_management plugins - https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3963#issuecomment-1568573835, it was discovered that the same code is used to control query change callback of the OuiSearchBar in two places.

Describe the solution you'd like

This problem aims to discuss options to standardize this process: 1) Add functionality to the OuiSearchBar (OUI library) component to automatically display an error inside of the component if an incorrect query is entered. 2) Implement a hook that control the onChange callback and consequently returns an error if required (in Dashboards).

Additional context

search.tsx (advanced_settings) https://github.com/opensearch-project/OpenSearch-Dashboards/blob/20c928fccf9b2516b36613874b335e9291b69f81/src/plugins/advanced_settings/public/management_app/components/search/search.tsx#L61-L75

table.tsx (saved_objects_management) https://github.com/opensearch-project/OpenSearch-Dashboards/blob/20c928fccf9b2516b36613874b335e9291b69f81/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.tsx#L120-L134

joshuarrrr commented 1 year ago

@SergeyMyssak Let's hold off on any implementation here until we tackle updates in https://github.com/opensearch-project/OpenSearch-Dashboards/issues/4329 (and get similar design guidance for Saved Object Management). The underlying problem in both cases is that the OUI component is more tailored for queries (which may be invalid), than for simple search cases. Arguably in both of these usages, there should not be any need for invalid query handling, if we're just filtering a list of objects for users.