-
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
Migrate PermissionsEditor to React #4266
Conversation
@gabrieldutra I took it for a spin and I don't think the two pane SelectItemsDialog is optimal for this use case - it's confusing and unintuitive. In all other cases using SelectItemsDialog, the selected list and remove action are separate therefore more suitable. I actually think the original layout works best and perhaps SelectItemsDialog can be fitted to be like this: Notice I added:
|
Thanks @ranbena, I actually had the same thoughts and it was not easy to create a satisfactory flow with the SelectItemsDialog. I also thought about recreating the existing Dialog, but Antd's Select wouldn't support the Avatars. I have another idea in mind to apply here that I'll explore later today (or tomorrow): Something similar to Google docs's Share Dialog, one dialog for View/Edit/Remove (at some point with a Select for the Permission Type, but for now we can use a Tag) and another SelectItemsDialog only for adding new users. Edit: From a second look, only thing similar to Google is the Dialog with the permission type Select 😅 Regarding your suggestions the only one I have downside in mind is showing the Admins in the list, that can become confusing and not objective when there are many Admins, we better have that implicit :) |
I like @ranbena's suggestion. I don't think SelectItemsDialog is a good fit here, because in some cases it's unfeasible to show a list of all users and it's better to let them search. But I also agree about this one:
We can add a note about admins having access instead. |
@gabrieldutra Not sure what you mean. The way
Sure. Can put it in the dialog description. |
My bad 😅, I mixed up the |
@ranbena I didn't go much further from what the implementation is today, so lmk if you got any quick wins here :) |
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.
Great work. Got some suggestions and questions.
renderItem={user => ( | ||
<List.Item> | ||
<UserPreviewCard key={user.id} user={user}> | ||
{user.id === owner.id ? (<Tag>Owner</Tag>) : ( |
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'd rename to author
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.
Also, reset the .ant-tag
right margin so it aligns to the edge.
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'd rename to
author
Author does look better, but do you think it can be confusing in code, considering all the other places use owner
? (including the backend)
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 do that stuff all the time and i think it’s ok as long as it says author only on the presentation layer.
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.
Currently there is no difference between Owner and Author. But it's very possible we will allow changing the user reference here and in this case semantically it becomes more correct to call it Owner, no?
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.
It's not that important. Just making sure users understand the label and I think author
is clearer.
const [grantees, setGrantees] = useState([]); | ||
const { loadGrantees, addPermission, removePermission } = useGrantees(aclUrl); | ||
const loadUsersWithPermissions = useCallback(() => { | ||
setLoadingGrantees(true); |
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.
Swapping the list for a loading indicator on each add and remove is quite jarring.
How about adding a small indicator to the top right of the scrollbox?
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.
That was bothering me too, I was waiting for you to say sth about it. I tried a few options like using an indicator in the Search bar, but ended up with more complexity and not satisfactory. Will try that one 👍
> | ||
<UserSelect | ||
onSelect={userId => addPermission(userId).then(loadUsersWithPermissions)} | ||
previewCardAddon={user => (userHasPermission(user) ? '(already has permission)' : null)} |
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.
Wdyt of omitting the already permitted from search results?
- omit users with permissions - remove margin from Tag - use small loading indicator
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.
Looks great. See one small bug fix/code suggestion.
Co-Authored-By: Arik Fraimovich <arik@arikfr.com>
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.
Looks great. One layout suggestion.
<div className="d-flex align-items-center"> | ||
<h5 className="flex-fill">Users with permissions</h5> | ||
{loadingGrantees && <i className="fa fa-spinner fa-pulse" />} | ||
</div> | ||
<div className="scrollbox p-5 m-t-10" style={{ maxHeight: '40vh' }}> |
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.
A small layout suggestion.
- Give the "d-flex align-items-center" element
m-t-5
. - Remove the
m-t-10
from scrollbox.
Merging, so I can add it to the Dashboard migration 👌 |
What type of PR is this? (check all applicable)
Description
Migration of the PermissionsEditor to React.
Related Tickets & Documents
--
Mobile & Desktop Screenshots/Recordings (if there are UI changes)