Conversation
05a235f to
74fbcc1
Compare
|
Okay, this is ready for review now. |
ravicious
left a comment
There was a problem hiding this comment.
I didn't have time to get to the last commit (which is the most important one), I'll continue the review tomorrow.
There was a problem hiding this comment.
Should this say something like "Could not update view preferences" before showing the error message from the attempt? Off the top of my head I don't know what kind of errors will be shown here, but based on just the UI alone it might not be clear which part of the app has failed.
Same situation with other error boxes above.
There was a problem hiding this comment.
Good point, changed.
I also realized that the first error was rendered differently, and it was covering another error box, when we had more than one error.
I see that this logic was added here #34369.
I think we can simplify errors rendering and just render them above everything and don't think if they cover something or not (it is hard to do it reliably - we can have more than one error, we can have the search box or not).
cc @avatus
The error box is still sticky, so it is visible when the user scrolls down.
There was a problem hiding this comment.
The code which achieves that is a bit hard to understand, mostly because it uses some approaches which are not common in our codebase (useAsync((value) => value), storing a promise in a ref).
The way I understand this problem is that if someone clicks a button to change from cards to a list but we're yet to know what the actual preferences are like, we want to disregard the actual prefs we get from the cluster and wait for the updated prefs instead.
Isn't this a matter of having two different attempts, one that fetches the current prefs and another that updates them, and returning only one of them from the hook? If an update is in progress, we take the prefs from the update response. If there's no update, we use the actual prefs.
There was a problem hiding this comment.
In general that would be nice to have only one attempt, but a problem I see is that when you click on a pin, all items would disappear (I mean you would see a skeleton) because the entire attempt would be in a progress state. Also we read pins from the preferences, so if there are no preferences we can't read them.
In other words:
- if unified view preferences are changed -> we can show skeleton
- if pins are changed -> do not show skeleton (async action is handled inside shared unified view)
Currently, we ignore the update user preferences loading state and show only errors.
I was wondering if we could expose separate functions for updating unified view preferences and for updating pins. The first one would trigger a normal update useAsync action, and the latter would manually call the RPC and then set makeSuccessAttempt/makeErrorAttempt. This would solve an issue with missing pins when updating them. But OTOH this could cause a problem for updating the fallback: we wouldn't be able to detected a stale response and not update the workspace (also, I don't know if it would really help).
|
Eh, now I thought about an edge case related to the fact that we return the updated preferences from the server. If you are on a cluster that supports resource pinning but doesn't support the list view mode, changing the view to list and then pinning a resource will reset the view, because the server will return I think we could fix this by removing the default values from
EDIT: this is no longer relevant, the local state has more priority now, so the user can switch to list view even if the cluster preferences doesn't support it. When the app is opened again, it will simply go back to the card view. |
|
Aaaand one more problem: I forgot to add I think we should keep a map of |
|
Re concurrent requests, wouldn't it be simpler to add support for |
|
I refactored the PR with Rafał's help, I hope it is cleaner now. I'm pasting the original plan:
|
|
(I still have to address concurrent requests) |
…me time We know upfront that we won't fetch resources, so we can avoid showing errors related to them.
…out preferences update failure
…ently of font weight
56af8e5 to
2b92b0d
Compare


This is the frontend part of #35139
e counterpart https://github.com/gravitational/teleport.e/pull/2810
We decided to show the
UnifiedResourcescomponent as soon as possible, before the user preferences are fetched.During that time, when we don't know yet which tab and view should be highlighted, nothing is selected (it also means that we don't show any skeleton).
To make the component work with such async behavior, the
unifiedResourcePreferencesprop has been changed to acceptAttempt.We don't cache any preferences - if you open a new tab, they will be download again. By doing this, we will always have the fresh data.
The disadvantage of this solution is that we force the user to wait longer for the resources to be displayed. To remedy this, we may store the last
unifiedResourcePreferencesresponse in the workspace state and use it as a fallback, until we get the fresh data.I will add this after we make sure that this is the direction that we want to go.