From 6f63cd7ca0431559f3d09dbddd74431e1ee30937 Mon Sep 17 00:00:00 2001 From: Tim Alby Date: Thu, 11 Oct 2018 15:39:54 +0100 Subject: [PATCH] add notification to confirm unconfirmed emails --- .../app/views/project/list/notifications.pug | 27 +++++++++++++++++++ .../notifications-controller.coffee | 21 +++++++++++++++ .../main/project-list/project-list.coffee | 3 +++ 3 files changed, 51 insertions(+) diff --git a/services/web/app/views/project/list/notifications.pug b/services/web/app/views/project/list/notifications.pug index 04ba3827dc..b6b8c23af4 100644 --- a/services/web/app/views/project/list/notifications.pug +++ b/services/web/app/views/project/list/notifications.pug @@ -82,3 +82,30 @@ span(ng-controller="NotificationsController").userNotifications button(ng-click="dismiss(notification)").close.pull-right span(aria-hidden="true") × span.sr-only #{translate("close")} + + ul.list-unstyled.notifications-list( + ng-controller="EmailNotificationController", + ng-cloak + ) + li.notification_entry( + ng-repeat="userEmail in userEmails", + ng-if="!userEmail.confirmedAt && !userEmail.hide" + ) + .row + .col-xs-12 + .alert.alert-warning + .notification_inner( + ng-if="!userEmail.confirmationInflight" + ) + | #{translate("please_confirm_email", {emailAddress: "{{ userEmail.email }}"})} + | + a( + href + ng-click="resendConfirmationEmail(userEmail)" + ) (#{translate('resend_confirmation_email')}) + .notification_inner( + ng-if="userEmail.confirmationInflight" + ) + i.fa.fa-spinner.fa-spin + | + | #{translate('resending_confirmation_email')}… diff --git a/services/web/public/coffee/main/project-list/notifications-controller.coffee b/services/web/public/coffee/main/project-list/notifications-controller.coffee index 647ffd8c88..79fe6924e0 100644 --- a/services/web/public/coffee/main/project-list/notifications-controller.coffee +++ b/services/web/public/coffee/main/project-list/notifications-controller.coffee @@ -53,3 +53,24 @@ define [ localStorage('overleaf_v1_notification_hidden_at', Date.now()) else localStorage('overleaf_v1_notification_hidden_at', null) + + App.controller "EmailNotificationController", ($scope, $http, UserAffiliationsDataService) -> + $scope.userEmails = [] + for userEmail in $scope.userEmails + userEmail.hide = false + + _getUserEmails = () -> + UserAffiliationsDataService + .getUserEmails().then (emails) -> + $scope.userEmails = emails + $scope.$emit "project-list:notifications-received" + _getUserEmails() + + $scope.resendConfirmationEmail = (userEmail) -> + userEmail.confirmationInflight = true + UserAffiliationsDataService + .resendConfirmationEmail userEmail.email + .then () -> + userEmail.hide = true + userEmail.confirmationInflight = false + $scope.$emit "project-list:notifications-received" diff --git a/services/web/public/coffee/main/project-list/project-list.coffee b/services/web/public/coffee/main/project-list/project-list.coffee index 8bdec6f42a..6d6009557f 100644 --- a/services/web/public/coffee/main/project-list/project-list.coffee +++ b/services/web/public/coffee/main/project-list/project-list.coffee @@ -38,6 +38,9 @@ define [ recalculateProjectListHeight() $scope.$apply() + $scope.$on "project-list:notifications-received", () -> + $scope.$applyAsync () -> recalculateProjectListHeight() + # Allow tags to be accessed on projects as well projectsById = {} for project in $scope.projects