From 6a3e6973968cd0a1fc923875f2ddbe66686d05fa Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Mon, 9 Nov 2020 10:35:18 +0000 Subject: [PATCH] Merge pull request #3358 from overleaf/jel-send-email-confirmation-error Handle errors in dash UI when resending email confirmation GitOrigin-RevId: 560e229845b72987a8d7132d87506cfb58323232 --- .../app/views/project/list/notifications.pug | 27 ++++++++++--------- .../project-list/notifications-controller.js | 21 ++++++++++----- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/services/web/app/views/project/list/notifications.pug b/services/web/app/views/project/list/notifications.pug index 83a4a4c7b2..89d9c9837d 100644 --- a/services/web/app/views/project/list/notifications.pug +++ b/services/web/app/views/project/list/notifications.pug @@ -174,19 +174,22 @@ include ../../_mixins/saml ng-repeat="userEmail in userEmails", ng-if="showConfirmEmail(userEmail) && projects.length > 0" ) - .alert.alert-warning(ng-if="!userEmail.confirmationInflight") + .alert.alert-warning .notification-body - | #{translate("please_confirm_email", {emailAddress: "{{ userEmail.email }}"})} - | - a( - href - ng-click="resendConfirmationEmail(userEmail)" - ) (#{translate('resend_confirmation_email')}) - .alert.alert-warning(ng-if="userEmail.confirmationInflight") - .notification-body - i.fa.fa-spinner.fa-spin(aria-hidden="true") - | - | #{translate('resending_confirmation_email')}… + div(ng-if="!userEmail.confirmationInflight") + | #{translate("please_confirm_email", {emailAddress: "{{ userEmail.email }}"})} + | + a( + href + ng-click="resendConfirmationEmail(userEmail)" + ) (#{translate('resend_confirmation_email')}) + div(ng-if="userEmail.confirmationInflight") + i.fa.fa-spinner.fa-spin(aria-hidden="true") + | + | #{translate('resending_confirmation_email')}… + div(ng-if="!userEmail.confirmationInflight && userEmail.error" aria-live="polite") + | #{translate('generic_something_went_wrong')} + - var hasPaidAffiliation = userAffiliations.some(affiliation => affiliation.licence && affiliation.licence !== 'free') if settings.enableSubscriptions && !hasSubscription && !hasPaidAffiliation ul.list-unstyled( diff --git a/services/web/frontend/js/main/project-list/notifications-controller.js b/services/web/frontend/js/main/project-list/notifications-controller.js index e3963b5b37..14cab1ec8a 100644 --- a/services/web/frontend/js/main/project-list/notifications-controller.js +++ b/services/web/frontend/js/main/project-list/notifications-controller.js @@ -112,12 +112,19 @@ App.controller('EmailNotificationController', function( $scope.resendConfirmationEmail = function(userEmail) { userEmail.confirmationInflight = true - return UserAffiliationsDataService.resendConfirmationEmail( - userEmail.email - ).then(function() { - userEmail.hide = true - userEmail.confirmationInflight = false - $scope.$emit('project-list:notifications-received') - }) + userEmail.error = false + UserAffiliationsDataService.resendConfirmationEmail(userEmail.email) + .then(() => { + userEmail.hide = true + $scope.$emit('project-list:notifications-received') + }) + .catch(error => { + userEmail.error = true + console.error(error) + $scope.$emit('project-list:notifications-received') + }) + .finally(() => { + userEmail.confirmationInflight = false + }) } })