-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Add external_account type custom profile field. #12442
Conversation
@timabbott can you review the initial design of model? |
zerver/lib/validator.py
Outdated
|
||
if val.count('%(username)s') != 1: | ||
return _('username should appear exactly once in pattern.') | ||
val.replace('(username)', '') |
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.
Conceptually, I think we should replace it with just the string "username"
, in case the URL has a structure where a /%(username)s/ -> //
would be weird. (I don't think this is a super likely corner case, but it's more obviously correct that way).
@YJDave awesome, thanks for working on this! A few notes:
As a sidenote, we could have the validators for these do an HTTP HEAD request to check if the URL actually works for standard account types, in addition to the validation we have here. May not be something we can do for the |
fda23aa
to
6e5ce50
Compare
@timabbott thanks for the detail feedback. I have updated PR. |
Let me know changes, Demo:
I was imagining adding |
I merged the preparatory refactor commits, since those looked good. It's failing CI, with an error that looks like one is trying to send more complex objects to e.g. memcached than one should.
Reading this, maybe we want to s/text/label/ or maybe `s/text/name/``? I feel like that's clearer about the meaning. |
zerver/lib/validator.py
Outdated
|
||
if val.count('%(username)s') != 1: | ||
return _('username should appear exactly once in pattern.') | ||
val.replace('username', '') |
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.
This should be val.replace("%(username)s, "username")
, I think
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, I think you want to make a new variable name -- otherwise you're potentially mutating the argument, which you don't want.
if error: | ||
return json_error(error) | ||
|
||
validate_custom_field_data(field_type, field_data) |
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 think you can split this refactor into a prep commit to shrink the main commit a bit.
I see. I think the way we'd do that sort of thing if we did it is to have new realms have CustomProfileField objects created pointed at those. Let's just leave that off for now -- we should get the main feature working and then we can think about the policy decisions on whether we want to default-include any usernames here. |
I will go through the documentation and fix soon.
You mean, following?
We have dictionary key as value, so not sure we require |
ac98153
to
e7d7aac
Compare
@timabbott PR is ready for second review. I have registered
Should we dump the data then and parse in frontend?
|
e7d7aac
to
b915436
Compare
@timabbott I solved conflicts and parse the data. But it still shows the same error, which is not related to the changes 🤔 |
b915436
to
b6ee2ad
Compare
I'm pretty sure those errors are caused by your changes, just in some subtle way, since they consistently reproduce on this branch. I merged the first couple commits; I'll try to debug a bit. |
Here's a simpler test failure I figured out from running
(I think the exception you were seeing is an error from the parallel sub-process with the failure trying to send details on the failure to the parent process to print). |
OK and the bug there is you added a new field type to |
fa4658b
to
9cf57f7
Compare
9cf57f7
to
b2047bc
Compare
b2047bc
to
5c4f337
Compare
@timabbot Thanks for debugging, Updated! Also updated style for non editable input pills. |
var opts = { | ||
success_continuation: clear_form_data, | ||
}; | ||
field_data = read_field_data_from_form(parseInt(field_type, 10), $('.new-profile-field-form')); |
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 changed the .new-profile-field-form
element here to not fetch from e
because there will be only one element anyway in form. It should not create any race condition or other errors. It should work, I tested it manually as well as in casper tests.
Rename URL type custom profile field in populate db to avoid confusion with custom external account profile fields.
5c4f337
to
a9bd668
Compare
Add new custom profile field type, External account. External account field links user's social media profile with account. e.g. GitHub, Twitter, etc. Fixes part of zulip#12302
Type of input element in profile form was not defined for URL type custom fields. Because type was not passed to template.
For non editable input pills, add background color to be transparent and padding to 0px.
a9bd668
to
9b84b17
Compare
Rebased. |
This is awesome, merged, thanks @YJDave! There's a few follow-ups we should definitely do:
More speculatively, do we want the display for external account fields to be displayed as "[GitHub logo] timabbott", rather than the label-over-text style that we currently use; this would make them significantly more compact, and I think be pretty easy to implement for the built-in ones at least, since we just need to provide the logo URL in the |
Thank you! I have submitted followups work. I really like the idea of icon instead of label or maybe with label in profile setting if required. Icon will look really awesome in small user profile. We can add tooltip over icon/logo. |
External account + custom: Underneath the input box, in grey, maybe: Docs updates: sure Broader set of reasonable things: One question is whether we should include linkedin, which doesn't have usernames but is reasonable to connect to. I think the answer is yes? Display for external account fields: yeah, I think something like that would be good. I'm trying to think how to combine stuff with usernames (like github) with stuff without (which is maybe just linkedin). Maybe for linkedin we can just put some text like "Visit profile" where there would otherwise be a username? |
For the URL, we'd want them to enter I think LinkedIn has automatically generated usernames. E.g. I'm https://www.linkedin.com/in/tim-abbott-37828711/. I think we could easily handle this as https://www.linkedin.com/in/%(username)s/, with "help" text that somehow explains how to get it. |
Yeah, for LinkedIn we'd just display it as "[logo] LinkedIn" (or "Visit profile"), without a "name". |
The |
I think |
Switching to For now, how about: We could also add "Email support@zulipchat.com" to the error message for a misformed URL pattern. |
Issue #12302