Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
billing: Show success message for license change after page reload.
Aman Agrawal67bddb3d7226
diff --git a/corporate/views/billing_page.py b/corporate/views/billing_page.pyindex cf0cd1c52e0..1f851e24fe7 100644--- a/corporate/views/billing_page.py+++ b/corporate/views/billing_page.py@@ -32,7 +32,7 @@ from zerver.decorator import require_billing_access, zulip_login_requiredfrom zerver.lib.exceptions import JsonableErrorfrom zerver.lib.request import REQ, has_request_variablesfrom zerver.lib.response import json_success-from zerver.lib.validator import check_bool, check_int, check_int_in+from zerver.lib.validator import check_bool, check_int, check_int_in, check_stringfrom zerver.models import Realm, UserProfilebilling_logger = logging.getLogger("corporate.stripe")@@ -109,7 +109,9 @@ def sponsorship_request(request: HttpRequest) -> HttpResponse:@zulip_login_required@has_request_variablesdef billing_home(- request: HttpRequest, onboarding: bool = REQ(default=False, json_validator=check_bool)+ request: HttpRequest,+ onboarding: bool = REQ(default=False, json_validator=check_bool),+ success_message: str = REQ(default="", str_validator=check_string),) -> HttpResponse:user = request.userassert user.is_authenticated@@ -222,6 +224,7 @@ def billing_home(billing_frequency=billing_frequency,fixed_price=fixed_price,price_per_license=price_per_license,+ success_message=success_message,)return render(request, "corporate/billing.html", context=context)diff --git a/templates/corporate/billing.html b/templates/corporate/billing.htmlindex 3f35e7fec1b..94f4cdcff6b 100644--- a/templates/corporate/billing.html+++ b/templates/corporate/billing.html@@ -9,6 +9,9 @@<div id="billing-page" class="register-account flex full-page"><div class="center-block new-style">{% if admin_access and has_active_plan %}+ {% if success_message %}+ <div class="alert alert-success billing-page-success" id="billing-success-message-top">{{ success_message }}</div>+ {% endif %}<div class="pitch"><h1>Zulip Cloud billing for {{ org_name }}</h1></div>@@ -89,9 +92,6 @@<div id="next-license-change-error" class="alert alert-danger billing-page-error"></div></div>{% endif %}- <div id="licensechange-success" class="alert alert-success billing-page-success">- Plan updated. The page will now reload.- </div>{% endif %}<div id="cardchange-error" class="alert alert-danger"></div><div class="input-box billing-page-field no-validation">diff --git a/web/src/billing/billing.ts b/web/src/billing/billing.tsindex 280df72b7ab..0183bb93b63 100644--- a/web/src/billing/billing.ts+++ b/web/src/billing/billing.ts@@ -13,8 +13,12 @@ export function create_update_current_cycle_license_request(): void {[],"PATCH",() => {- window.location.replace("/billing/");- $("#licensechange-success").show();+ window.location.replace(+ "/billing/?success_message=" ++ encodeURIComponent(+ "Updated number of licenses for the current billing period.",+ ),+ );$("#current-manual-license-count-update-button .loader").hide();$("#current-manual-license-count-update-button .billing-button-text").text("Update");},@@ -34,8 +38,10 @@ export function create_update_next_cycle_license_request(): void {[],"PATCH",() => {- window.location.replace("/billing/");- $("#licensechange-success").show();+ window.location.replace(+ "/billing/?success_message=" ++ encodeURIComponent("Updated number of licenses for the next billing period."),+ );$("#next-manual-license-count-update-button .loader").hide();$("#next-manual-license-count-update-button .billing-button-text").text("Update");},diff --git a/web/styles/portico/billing.css b/web/styles/portico/billing.cssindex 7ecba30bf1a..d4717dffc34 100644--- a/web/styles/portico/billing.css+++ b/web/styles/portico/billing.css@@ -552,3 +552,8 @@ input[name="licenses"] {#free-trial-top-banner {text-align: left;}++#billing-success-message-top {+ display: block;+ text-align: center;+}