Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

billing: Add different modals for increasing / decreasing licenses.

Aman Agrawalbb557d519372
diff --git a/templates/corporate/billing.html b/templates/corporate/billing.html
index eefad746a52..e46d15126e7 100644
--- a/templates/corporate/billing.html
+++ b/templates/corporate/billing.html
@@ -225,23 +225,53 @@
{% endif %}
</div>
</div>
-<div id="confirm-licenses-modal" class="micromodal" aria-hidden="true">
+<div id="confirm-licenses-modal-increase" class="micromodal" aria-hidden="true">
<div class="modal__overlay" tabindex="-1">
<div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="dialog_title">
<header class="modal__header">
<h1 class="modal__title dialog_heading">
- {{ _('Confirm license change') }}
+ Confirm adding licenses
</h1>
<button class="modal__close" aria-label="{{ _('Close modal') }}" data-micromodal-close></button>
</header>
<main class="modal__content">
<p>
- Are you sure you want to change the licenses from
- <b><span id="current_license_count_holder"></span></b> to
- <b><span id="new_license_count_holder"></span></b>?
+ Are you sure you want to increase the number of licenses from
+ <b><span class="current_license_count_holder"></span></b> to
+ <b><span class="new_license_count_holder"></span></b>?
</p>
<p>
- You would be charged for the additional licenses.
+ You will be charged for
+ <b><span class="difference_license_count_holder"></span></b> additional licenses.
+ </p>
+ </main>
+ <footer class="modal__footer">
+ <button class="modal__btn dialog_exit_button" aria-label="{{ '(Close this dialog window)' }}" data-micromodal-close>{{ _('Cancel') }}</button>
+ <button class="modal__btn dialog_submit_button">
+ <span>{{ _('Confirm') }}</span>
+ </button>
+ </footer>
+ </div>
+ </div>
+</div>
+<div id="confirm-licenses-modal-decrease" class="micromodal" aria-hidden="true">
+ <div class="modal__overlay" tabindex="-1">
+ <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="dialog_title">
+ <header class="modal__header">
+ <h1 class="modal__title dialog_heading">
+ Confirm decreasing licenses
+ </h1>
+ <button class="modal__close" aria-label="{{ _('Close modal') }}" data-micromodal-close></button>
+ </header>
+ <main class="modal__content">
+ <p>
+ Are you sure you want to decrease the number of licenses from
+ <b><span class="current_license_count_holder"></span></b> to
+ <b><span class="new_license_count_holder"></span></b>?
+ </p>
+ <p>
+ Your organization will be limited to at most
+ <b><span class="new_license_count_holder"></span></b> users.
</p>
</main>
<footer class="modal__footer">
diff --git a/web/src/billing/billing.ts b/web/src/billing/billing.ts
index d03f974b714..c52eda0e223 100644
--- a/web/src/billing/billing.ts
+++ b/web/src/billing/billing.ts
@@ -118,10 +118,14 @@ export function initialize(): void {
e.preventDefault();
const {new_current_manual_license_count, old_current_manual_license_count} =
get_old_and_new_license_count_for_current_cycle();
- $("#new_license_count_holder").text(new_current_manual_license_count);
- $("#current_license_count_holder").text(old_current_manual_license_count);
- $("#confirm-licenses-modal .dialog_submit_button").attr("data-cycle", "current");
- portico_modals.open("confirm-licenses-modal");
+ const $modal = $("#confirm-licenses-modal-increase");
+ $modal.find(".new_license_count_holder").text(new_current_manual_license_count);
+ $modal.find(".current_license_count_holder").text(old_current_manual_license_count);
+ $modal
+ .find(".difference_license_count_holder")
+ .text(new_current_manual_license_count - old_current_manual_license_count);
+ $modal.find(".dialog_submit_button").attr("data-cycle", "current");
+ portico_modals.open("confirm-licenses-modal-increase");
});
$("#next-manual-license-count-update-button").on("click", (e) => {
@@ -131,23 +135,37 @@ export function initialize(): void {
e.preventDefault();
const {new_next_manual_license_count, old_next_manual_license_count} =
get_old_and_new_license_count_for_next_cycle();
- $("#new_license_count_holder").text(new_next_manual_license_count);
- $("#current_license_count_holder").text(old_next_manual_license_count);
- $("#confirm-licenses-modal .dialog_submit_button").attr("data-cycle", "next");
- portico_modals.open("confirm-licenses-modal");
- });
-
- $("#confirm-licenses-modal .dialog_submit_button").on("click", () => {
- portico_modals.close("confirm-licenses-modal");
- if ($("#confirm-licenses-modal .dialog_submit_button").attr("data-cycle") === "current") {
- create_update_current_cycle_license_request();
- } else if (
- $("#confirm-licenses-modal .dialog_submit_button").attr("data-cycle") === "next"
- ) {
- create_update_next_cycle_license_request();
+ let $modal;
+ if (new_next_manual_license_count > old_next_manual_license_count) {
+ $modal = $("#confirm-licenses-modal-increase");
+ } else {
+ $modal = $("#confirm-licenses-modal-decrease");
}
+
+ $modal.find(".new_license_count_holder").text(new_next_manual_license_count);
+ $modal.find(".current_license_count_holder").text(old_next_manual_license_count);
+ $modal
+ .find(".difference_license_count_holder")
+ .text(new_next_manual_license_count - old_next_manual_license_count);
+ $modal.find(".dialog_submit_button").attr("data-cycle", "next");
+ portico_modals.open($modal.attr("id")!);
});
+ $("#confirm-licenses-modal-increase, #confirm-licenses-modal-decrease").on(
+ "click",
+ ".dialog_submit_button",
+ (e) => {
+ portico_modals.close_active();
+ const is_current_cycle = $(e.currentTarget).attr("data-cycle") === "current";
+
+ if (is_current_cycle) {
+ create_update_current_cycle_license_request();
+ } else {
+ create_update_next_cycle_license_request();
+ }
+ },
+ );
+
$("#confirm-cancel-subscription-modal .dialog_submit_button, #reactivate-subscription").on(
"click",
(e) => {
diff --git a/web/src/portico/portico_modals.ts b/web/src/portico/portico_modals.ts
index 243247318ad..1967df8921e 100644
--- a/web/src/portico/portico_modals.ts
+++ b/web/src/portico/portico_modals.ts
@@ -18,7 +18,7 @@ function active_modal(): string | undefined {
return `#${CSS.escape($micromodal.attr("id")!)}`;
}
-function close_active(): void {
+export function close_active(): void {
if (!is_open()) {
blueslip.warn("close_active() called without checking is_open()");
return;
diff --git a/web/styles/portico/billing.css b/web/styles/portico/billing.css
index 435b9f1bd04..a49f0b5ffc1 100644
--- a/web/styles/portico/billing.css
+++ b/web/styles/portico/billing.css
@@ -493,3 +493,15 @@ input[name="licenses"] {
#billing-page .support-link {
text-align: center;
}
+
+#confirm-licenses-modal-decrease,
+#confirm-licenses-modal-increase,
+#confirm-cancel-subscription-modal {
+ .modal__title {
+ font-weight: 600;
+ }
+
+ .modal__content {
+ font-weight: 400;
+ }
+}