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

Add add-on data attr if subdomain is set #1036

Merged
merged 2 commits into from
Aug 25, 2021
Merged

Add add-on data attr if subdomain is set #1036

merged 2 commits into from
Aug 25, 2021

Conversation

maxxcrawford
Copy link
Contributor

@maxxcrawford maxxcrawford commented Aug 25, 2021

Expected:
If you're a user who is premium AND logged in AND have registered a subdomain, then the data-attr data-premium-subdomain-set will be set to whatever the subdomain is in the firefox-private-relay-addon-data custom element.

Otherwise, that data-attr will have the value of None in the firefox-private-relay-addon-data element.

privaterelay/templates/profile.html Outdated Show resolved Hide resolved
{% if settings.PREMIUM_ENABLED %}
{% with request.user.profile_set.first as user_profile %}
{% if user_profile.subdomain %}
data-premium-subdomain-set="true"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rather than just setting true, can I get an output from the variable? Similar to var foo = (x > y) in JS?

Copy link
Member

Choose a reason for hiding this comment

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

Yup, the user_profile.subdomain value should be a string of the user's subdomain. So it could be:

Suggested change
data-premium-subdomain-set="true"
data-premium-subdomain-set="{{ user_profile.subdomain }}"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would setting it to a string of the user's subdomain be necessary to check if a user has one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@codemist So…if one isn't set is appears as:

data-premium-subdomain-set="None"

So, in your add-on logic, you'll need to catch this. if subdomain === "None", etc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahhhh I see!

privaterelay/templates/profile.html Outdated Show resolved Hide resolved
{% if settings.PREMIUM_ENABLED %}
{% with request.user.profile_set.first as user_profile %}
{% if user_profile.subdomain %}
data-premium-subdomain-set="true"
Copy link
Member

Choose a reason for hiding this comment

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

Yup, the user_profile.subdomain value should be a string of the user's subdomain. So it could be:

Suggested change
data-premium-subdomain-set="true"
data-premium-subdomain-set="{{ user_profile.subdomain }}"

@maxxcrawford maxxcrawford merged commit 566ac9a into main Aug 25, 2021
@maxxcrawford maxxcrawford deleted the addon-data-flag branch August 25, 2021 17:32
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