From 5d8b8ff012bb9095039d74f5383664d7a11c6e01 Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Mon, 25 Feb 2019 10:24:33 +0000 Subject: [PATCH] Merge pull request #1530 from sharelatex/spd-dont-cancel-groups-on-invite Only prompt for group cancellation if group is personal when accepting invite GitOrigin-RevId: 921807b25d64f037859d303e28c40cdc12eb7685 --- .../Features/Subscription/TeamInvitesController.coffee | 9 ++++++++- services/web/app/views/subscriptions/team/invite.pug | 3 ++- .../src/main/subscription/team-invite-controller.js | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/services/web/app/coffee/Features/Subscription/TeamInvitesController.coffee b/services/web/app/coffee/Features/Subscription/TeamInvitesController.coffee index 9a6e9dbaeb..72c28d3a79 100644 --- a/services/web/app/coffee/Features/Subscription/TeamInvitesController.coffee +++ b/services/web/app/coffee/Features/Subscription/TeamInvitesController.coffee @@ -37,10 +37,17 @@ module.exports = SubscriptionLocator.getUsersSubscription userId, (err, personalSubscription) -> return next(err) if err? + hasIndividualRecurlySubscription = + personalSubscription? && + !personalSubscription.planCode.match(/(free|trial)/)? && + personalSubscription.groupPlan == false && + personalSubscription.recurlySubscription_id? && + personalSubscription.recurlySubscription_id != "" + res.render "subscriptions/team/invite", inviterName: invite.inviterName inviteToken: invite.token - hasPersonalSubscription: personalSubscription? + hasIndividualRecurlySubscription: hasIndividualRecurlySubscription appName: settings.appName acceptInvite: (req, res, next) -> diff --git a/services/web/app/views/subscriptions/team/invite.pug b/services/web/app/views/subscriptions/team/invite.pug index 46a0e8e306..bb698e3c51 100644 --- a/services/web/app/views/subscriptions/team/invite.pug +++ b/services/web/app/views/subscriptions/team/invite.pug @@ -20,8 +20,9 @@ block content .page-header h1.text-centered #{translate("invited_to_group", {inviterName: inviterName, appName: appName})} - div(ng-show="view =='personalSubscription'") + div(ng-show="view =='hasIndividualRecurlySubscription'") p #{translate("cancel_personal_subscription_first")} + .alert.alert-danger(ng-show="cancel_error" ng-cloak) #{translate("something_went_wrong_canceling_your_subscription")} p a.btn.btn.btn-default(ng-click="keepPersonalSubscription()", ng-disabled="inflight") #{translate("not_now")} |   diff --git a/services/web/public/src/main/subscription/team-invite-controller.js b/services/web/public/src/main/subscription/team-invite-controller.js index 483964c703..ae16c30f72 100644 --- a/services/web/public/src/main/subscription/team-invite-controller.js +++ b/services/web/public/src/main/subscription/team-invite-controller.js @@ -31,7 +31,11 @@ define(['base'], App => $scope.inflight = false return ($scope.view = 'teamInvite') }) - return request.catch(() => console.log('the request failed')) + return request.catch(() => { + $scope.inflight = false + $scope.cancel_error = true + console.log('the request failed') + }) } return ($scope.joinTeam = function() {