-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send the whole user preferences object to the backend when saving #28817
Conversation
web/packages/teleport/src/services/userPreferences/userPreferences.ts
Outdated
Show resolved
Hide resolved
a19330d
to
4252ce0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confused as to exactly why this is necessary. IIUC we're planning to add boolean fields to this UserPreferences
object: why can we not make these fields optional/nullable and use that to represent whether or not we wish to update them? (I'm presuming you've thought of that and have a good answer, just asking for my own understanding).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by per Ryan's request.
// fieldmask is the field mask of the user preferences to update. | ||
google.protobuf.FieldMask fieldmask = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// fieldmask is the field mask of the user preferences to update. | |
google.protobuf.FieldMask fieldmask = 3; | |
// User preferences update mask. | |
// Field names are specified using the proto names, for example $EXAMPLES_HERE. | |
// If absent a full update is performed, in accordance to legacy semantics. | |
google.protobuf.FieldMask update_mask = 3; |
Are full updates of entire fields allowed, like "assist", or does one need to specify particular fields, like "assist.preferred_logins"?
Is the comment above correct in regards to full updates/legacy?
Reference for the update_mask
name: https://cloud.google.com/apis/design/standard_methods#update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment it's the full path, i.e. assist.preferred_logins
. This is because the frontend code doesn't check if you're updating all of the object's values to simplify assist.view_mode
and assist.preferred_logins
into assist
.
Do you think I should add support for specifying assist
?
Also, I updated all the names to update mask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no hard-and-fast rules for this, I think. Just document your decision and it's alright.
lib/fieldmask/fieldmask.go
Outdated
// } | ||
// | ||
// ``` | ||
func FromStruct(s any) *fieldmaskpb.FieldMask { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This defeats the purpose of the field mask, I think. You are supposed to write explicitly what fields you want to touch in the updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - field masks work best when the client sets them. Inferring field masks just moves the issues around presence detection to where you infer the field mask.
4252ce0
to
0bcad8d
Compare
0bcad8d
to
ec7228d
Compare
To leave my two cents here: If everyone wants to follow this path I won't block it but for me, it doesn't make much sense to ask for fieldmasks from the client without there being a 1:1 guarantee between the object they send and the protobuf object. |
Agree with @tigrato - the mask paths are supposed to come from the originator of the update, otherwise we are mostly shifting the problem around. |
web/packages/teleport/src/services/userPreferences/userPreferences.ts
Outdated
Show resolved
Hide resolved
cfcb8c8
to
8de25d1
Compare
There are lots of eyes here already, some with fuller reviews than myself, so I'll un-assign me. Feel free to call me in again for design discussions, anytime. :) |
This PR has a lot of conversations, so let me summarize. Currently, on login WebUI already fetches the user preferences. If any changes are made, WebUI can apply those changes to the local copy and send the full version to the backend. This will keep the logic simple. Let's change the API to take the full user preferences. This solves the default/not set problem. It also removes the merge/patch logic in the backend. |
8de25d1
to
dd5c658
Compare
relates to #29234 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
dd5c658
to
81b4d5a
Compare
6fa51bc
to
4a7c902
Compare
@ryanclark See the table below for backport results.
|
This changes the UI to always send the whole user preferences object when the user changes a preference. This is so we can support
bool
andint
values in the future.