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

Added method for managers to update a user's email #1363

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

raul-fuentes
Copy link

@raul-fuentes raul-fuentes commented Mar 14, 2018

References

consuldemocracy#2499

Objectives

Added method and interface for a manager user to change emails of confirmed users

Visual Changes

peek 2018-03-14 16-24

Notes

none

Copy link

@MariaCheca MariaCheca left a comment

Choose a reason for hiding this comment

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

I've left some comments, also the design I see in the gif is not the one in the issue...Please review the requirements and in case you've questions ask us :)

@@ -1,3 +1,4 @@
<h2><%= t("management.account.show.title") %></h2>

<%= render 'management/users/erase_user_account' %>
<%= render 'management/users/edit_user_account' %>

Choose a reason for hiding this comment

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

There should be a block to check if the user has email, as it's warned in the issue's "Notes" section.

Copy link
Author

Choose a reason for hiding this comment

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

In the notes section warns about users without email, in that case the form will appear empty.
Maybe there is something that I don't understand, but any user can have an email even if they don't have one at the moment, isn't it?

Copy link

@bertocq bertocq Mar 19, 2018

Choose a reason for hiding this comment

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

I think you're right @raul-fuentes. The edit_user_account form should always be displayed as scenarios are:

  • User has an email: Manager should be able to change it
  • User does not have an email: Manager should be able to set a value for it

Copy link
Author

Choose a reason for hiding this comment

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

That's the actual behaviour, should I remark it some way?

Copy link

Choose a reason for hiding this comment

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

No it's good 👍 I just wrote it as "I think.." because I needed to double check it afterwards

@@ -1,9 +1,11 @@
<%= link_to t("management.users.erase_account_link"), "#", class: "button hollow alert js-toggle-link", data: { "toggle-selector" => "#erase-account-form" } %>
<%= link_to t("management.users.erase_account_link"), "#", class: "button hollow alert js-toggle-link edit-account-form", data: { "toggle-selector" => "#erase-account-form" },

Choose a reason for hiding this comment

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

I would indent this element more like this one here to make it more readable.

@@ -121,6 +121,8 @@ en:
erase_account_confirm: Are you sure you want to erase the account? This action can not be undone
erase_warning: This action can not be undone. Please make sure you want to erase this account.
erase_submit: Delete account
edit_account: Edit account

Choose a reason for hiding this comment

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

As the email is the only field we're changing here...I would go for an "Edit email" and "Update email"

@@ -121,6 +121,8 @@ es:
erase_account_confirm: '¿Seguro que quieres borrar a este usuario? Esta acción no se puede deshacer'
erase_warning: Esta acción no se puede deshacer. Por favor asegúrese de que quiere eliminar esta cuenta.
erase_submit: Borrar cuenta
edit_account: Editar cuenta

Choose a reason for hiding this comment

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

Same as the comment above.

@raul-fuentes raul-fuentes force-pushed the 2499_managers_can_upadte_users_email branch from 7be4f9c to 16bdde3 Compare March 19, 2018 11:04
@bertocq
Copy link

bertocq commented Mar 19, 2018

@raul-fuentes after changing the "Edit account" texts that maria requested, you're missing some changes in the specs expectations as well https://travis-ci.org/AyuntamientoMadrid/consul/jobs/355308112 at spec/features/management/account_spec.rb

@raul-fuentes raul-fuentes force-pushed the 2499_managers_can_upadte_users_email branch from 16bdde3 to a1b1c2e Compare March 19, 2018 14:56
@bertocq
Copy link

bertocq commented Mar 21, 2018

@raul-fuentes it's always a good idea to comment on the PR so we can notice requested changes has been applied 👍 we don't cycle through all pending changes PR's refreshing to see if there are changes.

@raul-fuentes
Copy link
Author

Thanks for the advise, I 'll do it from now on

@bertocq
Copy link

bertocq commented Mar 21, 2018

I'm sorry to contradict decabeza's mockups, but after reviewing consuldemocracy#2500 as well, this is going to get crazy if we keep adding more and more options as ajax forms that appear and dissapear as a toggle

kapture 2018-03-21 at 21 06 22

We're talking about a section that is used by Public Workers only:

  • Not end users, no need to fancy them with animations
  • Probably on legacy systems (think Windows XP SP1 with IE6 or IE7 if we're lucky)
  • Used to hardcore old school apps with menus and stuff written in Java, not in JS.

So with @decabeza 's agreement I'm proposing to:

1- Create a submenu under "Edit user account" menu item with "Edit Email" title. That menu will display the email change form (✅ working as expected) and nothing more
2- Create a second submenu under "Edit user account" with title "Delete User" that will have that pre-existing "Delete User" button that is toggled to the email form
3- Removing the "Edit email" button from the to right corner
4- Keep the new red "Change user" link in the left bottom corner 👍 I think at least the red color improves the usability as its a "destructive" action.

Also with this we can avoid those render_fails and toggle usages that really doesn't add value to the feature, only make the code harder to follow and maintain in the future if we keep adding stuff to this panel

@raul-fuentes raul-fuentes force-pushed the 2499_managers_can_upadte_users_email branch 2 times, most recently from c696efd to c899d16 Compare March 22, 2018 15:31
@raul-fuentes
Copy link
Author

raul-fuentes commented Mar 22, 2018

I have completed the requested changes and so do @iagirre, should we merge our PR's into one? (this one) We think that doing so we could easily merge the interface

This is the new interface

  • Edit email

screenshot from 2018-03-22 16-44-45

  • Delete account

screenshot from 2018-03-22 16-45-09

@bertocq
Copy link

bertocq commented Mar 22, 2018

Great! Those changes in the menu look much better 🙇 👍 But I still have some concerns:

[1] User experience still is not good enough

After the manager sets the new email, its true on localhost we are redirected to the email the user would see... but the Manager in Production will not, he'll see:

Instead he will see the following:
kapture 2018-03-22 at 19 57 06

The old email is still present, and there's no clue about what just happened, just a "Cambios guardados" that could be good enough if at least the manager or the user had our knowledge (that an email has been sent and everything else) but they don't, and assuming they know might get us some tickets "email change not working properly". Again, this an interface for public workers helping really-low-technical-knowledge users.

Think about showing under "Cuenta de usuario" a message that clearly explains what just happened and next steps (like you greatly did with the "Borrar cuenta" submenu 👏)

Se ha enviado un mensaje de correo electrónico a la nueva dirección de email introducida. Será necesario usar un enlace que aparece en ese mensaje para que el cambio de email se complete con éxito

An email message has been sent on to the introduced email address. It will be necessary to follow a link on that email message for the email address change to be completed effectively.

[2] Commit history needs rebase

After changes for [1] are done, I would recommend to rebase all commits as the final result will be hard to follow for a person in the future trying to figure out either what new feature we added or why a change in a certain file was done. As a personal tip, I sometimes just go:

git reset master
git add..
git commit..

as rebasing multiple commits can be far tedious than just creating them from scratch

@bertocq
Copy link

bertocq commented Mar 22, 2018

As you can see #1370 was merged and some conflicts appeared (nothing serious as far as I have seen). Your PR has a fix for an spec that was failing in itziar's 👍, and the "Change user" red link 👌 . But it would be nice it you could merge from his changes the "Dropdown" effect that the her PR added:

kapture 2018-03-22 at 23 00 43

@raul-fuentes raul-fuentes force-pushed the 2499_managers_can_upadte_users_email branch from c899d16 to 8751cfc Compare March 23, 2018 09:46
@raul-fuentes
Copy link
Author

@bertocq all the requested changes are done. Just one thing.
I changed the flash message after sent the new mail conformation request this way

screenshot from 2018-03-23 10-47-38

Its correct or is too long and maybe its better to show it in a green warn square like the warning before deleting an account?

@bertocq
Copy link

bertocq commented Mar 23, 2018

@raul-fuentes yes I was thinking about an square below the "Cuenta de usuario" title.

Think about showing under "Cuenta de usuario" a message that clearly explains what just happened and next steps (like you greatly did with the "Borrar cuenta" submenu 👏)

@raul-fuentes raul-fuentes force-pushed the 2499_managers_can_upadte_users_email branch from 8751cfc to 1cb7d2c Compare March 23, 2018 14:52
@raul-fuentes
Copy link
Author

@bertocq here are the new changes.

screenshot from 2018-03-23 15-53-05

@bertocq
Copy link

bertocq commented Mar 23, 2018

Great @raul-fuentes ! Only left the merge conflicts

@raul-fuentes raul-fuentes force-pushed the 2499_managers_can_upadte_users_email branch from 1cb7d2c to 7ddd2b6 Compare March 23, 2018 15:23
@raul-fuentes
Copy link
Author

@bertocq, also merged the conflicts
this are the results:

screenshot from 2018-03-23 16-26-40

@bertocq
Copy link

bertocq commented Mar 23, 2018

There are some spec/i18n_spec.rb and spec/features/management/users_spec.rb test failures raul :(

@raul-fuentes raul-fuentes force-pushed the 2499_managers_can_upadte_users_email branch from 7ddd2b6 to a16c4b1 Compare March 26, 2018 07:58
@raul-fuentes
Copy link
Author

Hello @bertocq I just saw Travis a moment ago!
I have already made the necessary changes so that the tests work properly.

@aitbw aitbw deleted the 2499_managers_can_upadte_users_email branch August 2, 2018 16:53
@aitbw aitbw restored the 2499_managers_can_upadte_users_email branch August 2, 2018 17:33
@raul-fuentes raul-fuentes force-pushed the 2499_managers_can_upadte_users_email branch 4 times, most recently from 7dc5477 to 5c0fdfb Compare August 20, 2018 09:38
@raul-fuentes
Copy link
Author

PR updated!

@@ -72,7 +72,7 @@
expect(user.date_of_birth).to have_content Date.new(1980, 12, 31)
end

scenario 'Delete a level 2 user account from document verification page', :js do
scenario 'Delete a level 2 user account from document verification page', js: true do

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/bbatsov/ruby-style-guide#consistent-string-literals)


click_button "Update email"

expect(page).to have_content 'has already been taken'

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/bbatsov/ruby-style-guide#consistent-string-literals)


click_link "Edit email"

fill_in 'user_email', with: user1.email

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/bbatsov/ruby-style-guide#consistent-string-literals)


end

scenario 'Update user email errors', :js do

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/bbatsov/ruby-style-guide#consistent-string-literals)


click_button "Update email"

expect(user.reload.unconfirmed_email).to eq '[email protected]'

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/bbatsov/ruby-style-guide#consistent-string-literals)


click_link "Edit email"

fill_in 'user_email', with: '[email protected]'

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/bbatsov/ruby-style-guide#consistent-string-literals)

@@ -104,4 +113,37 @@
expect(page).to have_css("div.for-print-only", text: 'another_new_password', visible: false)
end

scenario 'Update user email', :js do

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/bbatsov/ruby-style-guide#consistent-string-literals)

end

accept_alert do
within '#erase-account-form' do

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/bbatsov/ruby-style-guide#consistent-string-literals)

user = create(:user, :level_two)
login_managed_user(user)

visit management_account_path

click_link "Delete user"
accept_confirm { click_link "Delete account" }
within '.is-active' do

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/bbatsov/ruby-style-guide#consistent-string-literals)


expect(page).to have_content "No verified user logged in yet"
end

scenario 'Delete a user account', :js do
scenario 'Delete user account', :js do

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/bbatsov/ruby-style-guide#consistent-string-literals)

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.

5 participants