Skip to content

Conversation

@oguzkocer
Copy link
Contributor

Relevant #3901. I've started this PR with the intention of adding the change role & remove user functionality's UI side, but I kept finding small issues that I didn't feel deserved a separate PR. However, it got a bit out of hand and became a bigger PR than I'd have liked. Having said that, this should be the last PR, aside from adding Analytics, and we can wrap up the v1 of this feature once this is merged.

A list of things that was accomplished in this PR:

  • Changing role: UI side
  • Removing a user: network call, db changes, UI etc.
  • Error handling for network calls: showing a toast message when a call fails
  • Using custom toolbar to match the other pages' design
  • When a new list of users is received from a network call, we delete the previous records - This is done to make sure that if the list is changed on remote we reflect it in the DB.
  • Remove the users from people table when a blog is removed from the app
  • Many other small improvements overall.

I've already added a bunch of comments to explain what certain parts of the code do, but if there is anything not immediately clear, please let me know so I can add more comments.

To test: Since this is the last PR, we should test the whole flow

Needs review: @hypest

if (!isAdded()) return;

Person person = PeopleTable.getPerson(mPersonID, mLocalTableBlogID);
Person person = getCurrentPerson();
Copy link
Contributor

@hypest hypest May 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking: Let's lose the "Current" from the function name as it has some connotations (like, a globally selected "current" user) beyond the actual usage here. What do you think about "loadPerson()"? Cheers!

Well, I should have added this comment on the function declaration line...

@hypest
Copy link
Contributor

hypest commented May 13, 2016

@oguzkocer , thanks for the effort on this one! I like how the feature operates. I've finished my review pass at this point.

The only issue left, from my point of view, is the dismissal and re-opening of the role popup that doesn't always show the currently active role. Lemme know if I should provide more info on that and whether I should make another review pass. Cheers!

}

@SuppressWarnings("deprecation")
// Remove the selectableItemBackground if the user can't be edited
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest reinstating this comment back to the line the function is called (line 177 at this point)? The function name is pretty clear and perfectly corresponding to its body, whereas the "if the user can't be edited" part is not implemented here but rather, at the caller's position. Sorry for the mind-blowing nitpicking! 😃 ❤️

@oguzkocer
Copy link
Contributor Author

There is an "issue" with the hiding of the People row in MySiteFragment. Not in the changeset of this PR ofc but, it can lead to user confusion: The site info is updated in a rate-limited fashion, no sooner than 6hours (https://github.com/wordpress-mobile/WordPress-Android/blob/develop/WordPress/src/main/java/org/wordpress/android/WordPress.java#L130). That means that if a the app user is promoted to Admin, the updated capability (list_users) won't be available until 6hours have passed since the last sites update call. So, the delay can be up to 6hours, leaving the app user in confusion as to why she cannot see the People's row in the app.

I think that this issue is not a blocker for this PR but is at least something we will need to keep in mind or even document for Support purposes.

I don't think this is a big deal in the sense that we have a lot of similar issues in the app. Ideally I agree that it shouldn't take that much time, but with the current architecture and this being a very edge case, most likely never even going to come up, I think it's fine to leave it as is. I'll still add this in the wrap-up post and give a heads up to Happiness Engineers. Thanks!

@oguzkocer
Copy link
Contributor Author

@hypest I think I've addressed all the comments & issues so far. If you like the fixes for the issues you've raised I think the only thing left is figuring out the design issue you've pinged @rickybanister about. Thanks!

Bundle args = getArguments();
if (args != null) {
String role = args.getString(ROLE_TAG);
mRoleListAdapter.setSelectedRole(role);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also cover the case where the device is rotating with the dialog open. In the usual drill, we can use the savedInstanceState to pass the currently selected Role. Cheers!

@hypest
Copy link
Contributor

hypest commented May 16, 2016

@oguzkocer I finished my current pass. The only "issue" now is the rotation of the role dialog not keeping the selection and a quite minor thing with the "Administrator" text.

Besides those, the design issue you mentioned (same styling of the person name and role fields) is not a blocker from my point of view. We can raise it as an issue and continue the discussion there.

@rickybanister
Copy link

An alternative design would be to use the header in a bigger way like this:

screen shot 2016-05-16 at 11 57 14 am

public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
String role = mRoleListAdapter.getSelectedRole();
if (role != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being extra careful doesn't hurt but there is actually no need to check for null at this point. For simplicity's sake, I'd recommend removing the check as there is no semantic value in it.

I would even go one step further and say that you can also remove the null-check around line 136 (radioButton.setChecked(mSelectedRole.equalsIgnoreCase(role)) by reversing the equals to role.equalsIgnoreCase(mSelectedRole) as the role is never expected to be null. Cheers!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right about the line 136 it makes it much better to do it the way you've suggested. However for this line, role could actually be empty if it wasn't passed during initialization and the user hasn't selected anything yet. So, I think it's good to make sure this is not null before writing into the bundle.

@hypest
Copy link
Contributor

hypest commented May 17, 2016

Thanks @rickybanister , that alternative design looks interesting and I can see it solving the styling issue I brought up! I'd most certainly want to see it in action as well!

As mentioned earlier, I will not block this PR over this particular issue but I'll leave it to @oguzkocer to decide whether to give it a stab as part of this PR or defer it to a subsequent one. Cheers!

@rickybanister
Copy link

I think it would be fine to merge this pr and work on that design in a new one.

@hypest hypest merged commit d1a1619 into feature/people-management-sync May 18, 2016
@hypest hypest deleted the feature/people-management-ui branch May 18, 2016 10:28
@oguzkocer oguzkocer mentioned this pull request May 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants