-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Manage user groups in UserEdit #3450
Manage user groups in UserEdit #3450
Conversation
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.
Nice!
- When we don't render the select field, we should render the list of groups the user belongs to.
- We shouldn't allow removing all groups from a user, a user should always have at least 1 group association.
- How hard will it be to add this to the create user form?
Besides that, see comments inline.
Thanks :)
redash/handlers/users.py
Outdated
@@ -216,7 +216,7 @@ def post(self, user_id): | |||
user.hash_password(params.pop('password')) | |||
params.pop('old_password') | |||
|
|||
if 'groups' in params and not self.current_user.has_permission('admin'): | |||
if 'group_ids' in params and not self.current_user.has_permission('admin'): |
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.
Need to check that the group ids belong to the current org.
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.
We should rather abort with an error message or simply remove the non-belonging groups? (in frontend side I guess those groups won't even appear, this is more to guarantee the behavior)
- We shouldn't allow removing all groups from a user, a user should always have at least 1 group association.
I guess I should add the rule here in the backend as well (frontend it was as easy as putting the field required)
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.
@arikfr, please check and consider me inexperienced in those parts 😂
initialValue: this.state.groups.filter(group => includes(user.groupIds, group.value)) | ||
.map(group => group.value), | ||
} : null, | ||
], isNull).map(field => ({ ...field, readOnly: user.isDisabled })); |
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.
Considering that it might take some time to load the groups, maybe have some loading state for the data? I know Ant's Select components have support for this, so it's only a matter of communicating this between the components.
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.
Cool, locally it's already done, I also added a "Loading..." placeholder. (better than a whole blank select imo)
I don't think this should be in the form, but I'll try to come up with a place to put it. (perhaps below or beside the heading as tags).
In case the route for creating a user is pretty similar to this one I would say this will be easy once we migrate the page. I would separate the |
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.
I tested the feature on netlify and found the following:
-
Save not working
Add group -> save -> refresh page - changes not saved. -
Autocomplete not working
Focus on select ->"admin" group shows in suggestions -> type "a" -> no suggestions (should show "admin")
I suppose this won't work on netlify since there are some backend changes on the user handler.
Good catch, I didn't notice this one, by default Ant Select filter works with Option values (in this case they are the group ids). Changing Once I fix Arik's comments I'll comment here 🙂 |
I had assumed this would be in the form (and considering I'm currently using BTW, I don't know exactly how to handle UserShow jest tests now (after this, it now requires Angular 🤔). |
Two options:
Why? |
Indeed not a bad idea, I totally forgot about those tricks... Thanks! 🙂
Because of this. I'm not sure if I'm missing something, but my first guess was that the |
Oh, right. Maybe stub it until we have a better solution? |
Is this ready? |
Yes, I've just updated with master :) |
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 👍
One thing perhaps is to swap
<div class="ant-tag other-classnames">
<a href="">Group Name</a>
</div>
for
<a href="" class="ant-tag other-classnames">Group Name</a>
so that it could have a hover state to better indicate that it's linkable.
I'm currently using the .ant-tag {
a:hover {
color: @somecolor
}
} |
@gabrieldutra in that case never mind. Leave as is. Not worth the complication. Feel free to merge. |
Description
The idea here is to improve UX for editing user groups by adding an option to manage this in the user edit page.
Some discussion
Changes
groups
seemed not be be a user attr,group_ids
was instead)Possible stuff to change depending on comments
DynamicFormUploadField
,DynamicFormSelectField
) instead of render methodsPreview (Admin editing other user)