Account for request errors when displaying "no results" message in the search bar#25061
Account for request errors when displaying "no results" message in the search bar#25061
Conversation
| type ActionPickerStatus = | ||
| | { status: 'no-input'; hasSelectedAllFilters: boolean } | ||
| | { status: 'processing' } | ||
| | { | ||
| status: 'finished'; | ||
| hasNoResults: boolean; | ||
| nonRetryableResourceSearchErrors: ResourceSearchError[]; | ||
| clustersWithExpiredCerts: Set<uri.ClusterUri>; | ||
| }; |
There was a problem hiding this comment.
When making ActionPickerStatus, I tried to follow the principle of making sure that impossible states are impossible to express with data structures. Initially some properties were included directly in the ActionPickerState while others were gated behind a discriminated union.
For example, I knew that hasNoResults would make no sense if status was different than finished, because if the search hasn't finished yet how we could be sure that there's no results.
But there are fields which technically aren't tied to the status. hasSelectedAllFilters can be true or false no matter whether the search is in progress or not. clustersWithExpiredCerts could technically include only clusters from ClustersService when the search is still in progress.
Initially I included those directly on the object. However, soon I refactored the code to include them only where necessary and tied all of them to particular statuses. When reading the type alone, it's more clear in what situation the given property is used. If there was a field used by 2/3 of the statuses, then I'd probably repeat it for those two statuses.
gzdunek
left a comment
There was a problem hiding this comment.
Found one bug, but except that it looks good.
1e5b01a to
0661ee5
Compare
|
@ravicious See the table below for backport results.
|
|
@ravicious See the table below for backport results.
|
What needs to be fixed
When the user types in a query for which there's no search results, we look at
ClustersServiceto see if there are any clusters that are not "connected", that is clusters with expired certs. We then tell the user that those clusters were not included in the search because the user is not logged in to them.However, the
connectedproperty is updated only in a couple of scenarios, the most relevant being the start of the app. After that we pretty much don't touch it at all, so at the moment it only tells us whether the user had valid certs when the app was started.Naturally, this approach doesn't handle a scenario in which the user was logged in to multiple clusters, left the app running, then came back to it, ran a search and then refreshed the cert for the active workspace (#24880). If they type a query with no search results now, those other clusters with expired certs will not be listed in that "no results" message. Instead, those failed requests will be treated like any other failed requests, even though we know that they failed due to expired certs.
How this PR fixes that
This PR makes it so that the list of clusters with expired certs is based not only on the state of
ClustersService, but also the results of the resource search requests.To do this, I refactored how any extra top messages above the results are rendered. The business and presentational logic used to be scattered around
ActionPickerand auxiliary components that were passed toResultListasExtraTopComponent. Instead, I made the distinction more clear cut:getActionPickerStatusis a function which takes necessary arguments and returnsActionPickerStatus, a discriminated union describing possible states for the action picker.ExtraTopComponentstakesActionPickerStatusand renders relevant top messages through auxiliary components.The idea here being that all business logic is performed in
getActionPickerStatusso that afterActionPickerStatusis returned, the other components can just display what's necessary.Other business logic changes