From 682abe9ca5831d52a1d9650b247a128a559ae124 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 17 May 2021 16:19:48 +0200 Subject: [PATCH] Merge pull request #3980 from overleaf/tm-show-error-if-plan-change-fails Show error in plan change modal if plan change fails GitOrigin-RevId: 698aab43feacdb5ced41f239167c5d132f7ca8de --- .../dashboard/_personal_subscription_recurly.pug | 4 ++++ .../web/frontend/js/main/subscription-dashboard.js | 14 ++++++++++---- services/web/locales/en.json | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/services/web/app/views/subscriptions/dashboard/_personal_subscription_recurly.pug b/services/web/app/views/subscriptions/dashboard/_personal_subscription_recurly.pug index a16f04a1ea..06aae4fc5f 100644 --- a/services/web/app/views/subscriptions/dashboard/_personal_subscription_recurly.pug +++ b/services/web/app/views/subscriptions/dashboard/_personal_subscription_recurly.pug @@ -94,6 +94,8 @@ script(type='text/ng-template', id='confirmChangePlanModalTemplate') .modal-header h3 #{translate("change_plan")} .modal-body + .alert.alert-warning(ng-show="genericError") + strong #{translate("generic_something_went_wrong")}. #{translate("try_again")}. #{translate("generic_if_problem_continues_contact_us")}. p !{translate("sure_you_want_to_change_plan", {planName: '{{plan.name}}'}, ['strong'])} div(ng-show="planChangesAtTermEnd") p #{translate("existing_plan_active_until_term_end")} @@ -114,6 +116,8 @@ script(type='text/ng-template', id='cancelPendingPlanChangeModalTemplate') .modal-header h3 #{translate("change_plan")} .modal-body + .alert.alert-warning(ng-show="genericError") + strong #{translate("generic_something_went_wrong")}. #{translate("try_again")}. #{translate("generic_if_problem_continues_contact_us")}. p !{translate("sure_you_want_to_cancel_plan_change", {planName: '{{plan.name}}'}, ['strong'])} .modal-footer button.btn.btn-default( diff --git a/services/web/frontend/js/main/subscription-dashboard.js b/services/web/frontend/js/main/subscription-dashboard.js index a6f585edf0..2984f060b9 100644 --- a/services/web/frontend/js/main/subscription-dashboard.js +++ b/services/web/frontend/js/main/subscription-dashboard.js @@ -144,12 +144,16 @@ App.controller( _csrf: window.csrfToken, } + $scope.genericError = false $scope.inflight = true return $http .post(`${SUBSCRIPTION_URL}?origin=confirmChangePlan`, body) .then(() => location.reload()) - .catch(() => console.log('something went wrong changing plan')) + .catch(() => { + $scope.genericError = true + $scope.inflight = false + }) } return ($scope.cancel = () => $modalInstance.dismiss('cancel')) @@ -164,14 +168,16 @@ App.controller( _csrf: window.csrfToken, } + $scope.genericError = false $scope.inflight = true return $http .post('/user/subscription/cancel-pending', body) .then(() => location.reload()) - .catch(() => - console.log('something went wrong reverting pending plan change') - ) + .catch(() => { + $scope.genericError = true + $scope.inflight = false + }) } return ($scope.cancel = () => $modalInstance.dismiss('cancel')) diff --git a/services/web/locales/en.json b/services/web/locales/en.json index 29d73871df..dd6ba5cf50 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -969,6 +969,7 @@ "ask_proj_owner_to_upgrade_for_history": "Please ask the project owner to upgrade to use the History feature.", "anonymous": "Anonymous", "generic_something_went_wrong": "Sorry, something went wrong", + "generic_if_problem_continues_contact_us": "If the problem continues please contact us", "restoring": "Restoring", "restore_to_before_these_changes": "Restore to before these changes", "profile_complete_percentage": "Your profile is __percentval__% complete",