Skip to content
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

Merged
merged 12 commits into from
Oct 29, 2019
Merged

Conversation

gabrieldutra
Copy link
Member

@gabrieldutra gabrieldutra commented Oct 18, 2019

What type of PR is this? (check all applicable)

  • Refactor

Description

Migration of the PermissionsEditor to React.

  • Make it availble on the Dashboard Page
  • Get rid of the old code
  • Review UI/UX

Related Tickets & Documents

--

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

react-permissions-editor

@ranbena
Copy link
Contributor

ranbena commented Oct 19, 2019

@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:

Screen-Shot-2019-10-19-at-13 06 32

Notice I added:

  • Title change suggestion
  • Description under title
  • Help trigger to here
  • Assuming admins have omni-permission, was added to list with indication.

@gabrieldutra
Copy link
Member Author

gabrieldutra commented Oct 19, 2019

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 :)

@arikfr
Copy link
Member

arikfr commented Oct 20, 2019

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:

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 :)

We can add a note about admins having access instead.

@ranbena
Copy link
Contributor

ranbena commented Oct 20, 2019

but Antd's Select wouldn't support the Avatars.

@gabrieldutra Not sure what you mean. The way QuerySelector is built, you can put any content in the <option>.

We can add a note about admins having access instead.

Sure. Can put it in the dialog description.

@gabrieldutra
Copy link
Member Author

Not sure what you mean. The way QuerySelector is built, you can put any content in the <option>.

My bad 😅, I mixed up the value it can have with the Options. The Options really can have ath... So I've updated to be the UI you suggested and now will improve usability from there.

@gabrieldutra
Copy link
Member Author

@ranbena I didn't go much further from what the implementation is today, so lmk if you got any quick wins here :)

@gabrieldutra gabrieldutra marked this pull request as ready for review October 26, 2019 18:18
@gabrieldutra gabrieldutra requested a review from ranbena October 26, 2019 18:18
@gabrieldutra gabrieldutra self-assigned this Oct 26, 2019
Copy link
Contributor

@ranbena ranbena left a 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>) : (
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Member Author

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)

Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Member Author

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)}
Copy link
Contributor

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
Copy link
Member

@arikfr arikfr left a 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.

client/app/pages/dashboards/dashboard.js Outdated Show resolved Hide resolved
Co-Authored-By: Arik Fraimovich <arik@arikfr.com>
Copy link
Contributor

@ranbena ranbena left a 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.

Comment on lines 142 to 146
<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' }}>
Copy link
Contributor

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.

@gabrieldutra gabrieldutra merged commit 82f488d into master Oct 29, 2019
@gabrieldutra
Copy link
Member Author

Merging, so I can add it to the Dashboard migration 👌

@gabrieldutra gabrieldutra deleted the react-permissions-editor branch October 29, 2019 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants