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
realm_plan_type: Restrict settings by plan type #12554
Conversation
So the bug here is relates to the For avoiding that sort of issue in the future, one possible solution is to lint-ban |
Ah, I see. Thanks for letting me know! |
When a realm's plan type is updated using "do_change_plan_type" we notify active users of the realm. This way certain plan features could be enabled instantaneously for active users.
Ok, this PR is now ready for a serious round of review. @rishig and @timabbott could you please review this? |
@timabbott the PR where this was fixed is #11861 . |
zerver/lib/events.py
Outdated
@@ -216,6 +216,10 @@ def fetch_initial_state_data(user_profile: UserProfile, | |||
state['realm_push_notifications_enabled'] = push_notifications_enabled() | |||
state['realm_upload_quota'] = realm.upload_quota_bytes() | |||
state['realm_plan_type'] = realm.plan_type | |||
state['plan_includes_wide_organization_logo'] = realm.plan_type != Realm.LIMITED | |||
state['upgrade_text_for_wide_organization_logo'] = "Available on all paid plans. Upgrade " |
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.
let's make this string a constant UPGRADE_TEXT_STANDARD, and also mark the whole string for translation.
Not sure the best way to make Upgrade
a link to /plans. Doing it in the template as it is currently isn't ideal; maybe Tim will have ideas. (Also, I see in the html you've linked to /upgrade. I should have specified that the link should be to /plans).
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.
let's make this string a constant UPGRADE_TEXT_STANDARD, and also mark the whole string for translation.
Right, I've made this variable as a member of the Realm class.
Not sure the best way to make Upgrade a link to /plans. Doing it in the template as it is currently isn't ideal; maybe Tim will have ideas
Agreed, I wasn't completely sure of what we wanted this string to look like with the hyperlink (because we're marking the string for translation, I don't think including HTML in it would be pretty, so I didn't implement it the way you mentioned it in the issue).
Also, I see in the html you've linked to /upgrade. I should have specified that the link should be to /plans
Change made.
@@ -575,6 +579,7 @@ def apply_event(state: Dict[str, Any], | |||
|
|||
if event['property'] == 'plan_type': | |||
# Then there are some extra fields that also need to be set. | |||
state['plan_includes_wide_organization_logo'] = event['value'] != Realm.LIMITED |
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.
hm, ideally this check would not be replicated. Not familiar with the code enough to know the right way to handle it though.
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.
ideally this check would not be replicated.
I didn't get what you're saying, could you please elaborate a bit about what check is being replicated here?
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.
oh, it just seems like there are two places in this file where we do the logic of
plan_includes_wide_organization_logo = plan_type != Realm.LIMITED
and I would have expected that logic to only appear once.
I'm not familiar with this code though, so maybe Tim will have a different opinion.
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.
Oh, that's how it's supposed to be. I mean we could make a function and try extracting the logic, but IMHO, that's just really going out of our way in this case.
<span> | ||
<h5> | ||
{{#unless plan_includes_wide_organization_logo}} | ||
{{t upgrade_text_for_wide_organization_logo}} <a href="https://zulipchat.com/upgrade/"> <i class="fa fa-rocket" aria-hidden="true"></i> </a> |
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.
Instead of using <h5>
and adding the icon in the html, let's style the whole thing using a CSS class. I think we can potentially even add the rocket with a :before
type thing?
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 did this, and for the time being (until Tim Abbott's review), I've changed the hyperlink to cover the entire string (now excluding the rocket because of a ::after
clause). This is just a placeholder until we decide where we want the hyperlink to go and how.
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.
@timabbott, are we sure that the way we hyperlinked the whole string is a good idea (speaking from the perspective of aesthetics)?
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.
Thanks @Hypro999! I've left a few comments, though Tim will have to review the events part.
Namely, here we add the "plan_includes_wide_organization_logo" and "upgrade_text_for_wide_organization_logo" to the page_params (which is set in zerver/lib/events.py). "plan_includes_wide_organization_logo" is True if the plan is not of the Realm.LIMITED type. We need to add this extra boolean parameter instead of just using "realm_plan_type" to make things a lot easier to work with on the frontend side, especially considering that handlebars won't allow checking for equality in its {{#if}} blocks.
Using the page_param variable "plan_includes_wide_organization_logo" disallow users in a realm with a "LIMITED" plan type from uploading their own wide organization logos and instead suggest that they upgrade their plan using the page_param variable "upgrade_text_for_wide_organization_logo" for the suggestion message. Backend validation for this feature already exists.
Thanks for the review @rishig! I've made most of the requested changes and extended the conversation where I couldn't make a satisfactory change. |
Merged, after adding @rishig one question for a quick follow-up: Do we want the string to say "... all paid or sponsored plans", to make clear it's available to open source orgs? |
Our current offering is that sponsored plans are identical to Zulip Standard, so I think we don't want to create a distinction between paid and sponsored. How about "Available on Zulip Standard and Plus. Upgrade"? |
A WIP PR for issue #12541. A pre-requisite step for this feature would be to do a
send_event
whenever a realm's plan is changed via.do_change_plan_type
. As of right now, that is all that this PR contains. I'm currently stuck on a bug for making this small change.