-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
improve transfer ownership error message #2651
Conversation
BundleMonUnchanged files (7)
No change in files bundle size Final result: ✅ View report in BundleMon website ➡️ |
test/plausible_web/controllers/site/membership_controller_test.exs
Outdated
Show resolved
Hide resolved
5fa66a6
to
45fffd8
Compare
|
||
message = | ||
case errors do | ||
%{invitation: [error | _]} -> String.capitalize(error) |
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.
:invitation
is not a schema field, but a custom error key.
|> unique_constraint([:email, :site_id],
name: :invitations_site_id_email_index,
error_key: :invitation,
message: "invitation already exists"
)
Should we still concat the other possible errors? I'm worried it might lead to confusing messages.
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.
Just the first one is fine. If anything confusing comes up we can address on case by case basis?
45fffd8
to
9dd6be2
Compare
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.
Tests fail. Please don't force push with ongoing review, it makes it more difficult to track changes. Thx.
Sorry, my bad. |
|
||
message = | ||
case errors do | ||
%{invitation: ["already sent" | _]} -> "Invitation has already been sent" |
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.
To avoid failing tests, changing too much in a single PR, and to still show a reasonable error message, I decided to reuse the approach used for duplicate invitations above:
analytics/lib/plausible_web/controllers/site/membership_controller.ex
Lines 84 to 85 in 1d1ec9a
{"already sent", _} -> | |
"This invitation has been already sent. To send again, remove it from pending invitations first." |
role: "admin" | ||
}) | ||
|
||
conn = get(recycle(conn), redirected_to(conn, 302)) |
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.
TIL: recycle, nice
Changes
Fixes #2640 by adding a more descriptive error message in case a transfer to an invited (but not joined) user is requested.
Tests
Changelog
Documentation
Dark mode