From 2463fef390e42686a6d17a73d05a1d0cad103cda Mon Sep 17 00:00:00 2001 From: Chrystal Maria Griffiths Date: Mon, 4 Feb 2019 11:10:54 +0000 Subject: [PATCH] Merge pull request #1454 from sharelatex/hb-subscriptions-page-messaging Subscription page messaging updates GitOrigin-RevId: c29999d22636dfe11c55b3f6110a38992645fad3 --- .../SubscriptionController.coffee | 59 +++++++++++-------- .../web/app/views/subscriptions/dashboard.pug | 20 ++++--- .../dashboard/_institution_memberships.pug | 2 +- .../dashboard/_v1_subscription_status.pug | 4 +- 4 files changed, 49 insertions(+), 36 deletions(-) diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee index ae1a36d085..c450f3e570 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee @@ -49,14 +49,14 @@ module.exports = SubscriptionController = LimitationsManager.userHasV1OrV2Subscription user, (err, hasSubscription)-> return next(err) if err? if hasSubscription or !plan? - res.redirect "/user/subscription" + res.redirect "/user/subscription?hasSubscription=true" else # LimitationsManager.userHasV2Subscription only checks Mongo. Double check with # Recurly as well at this point (we don't do this most places for speed). SubscriptionHandler.validateNoSubscriptionInRecurly user._id, (error, valid) -> return next(error) if error? if !valid - res.redirect "/user/subscription" + res.redirect "/user/subscription?hasSubscription=true" return else currency = req.query.currency?.toUpperCase() @@ -100,30 +100,37 @@ module.exports = SubscriptionController = managedPublishers, v1SubscriptionStatus } = results - logger.log { - user, - personalSubscription, - memberGroupSubscriptions, - managedGroupSubscriptions, - confirmedMemberInstitutions, - managedInstitutions, - managedPublishers, - v1SubscriptionStatus - }, "showing subscription dashboard" - plans = SubscriptionViewModelBuilder.buildViewModel() - data = { - title: "your_subscription" - plans, - user, - personalSubscription, - memberGroupSubscriptions, - managedGroupSubscriptions, - confirmedMemberInstitutions, - managedInstitutions, - managedPublishers, - v1SubscriptionStatus - } - res.render "subscriptions/dashboard", data + LimitationsManager.userHasV1OrV2Subscription user, (err, hasSubscription) -> + return next(error) if error? + fromPlansPage = req.query.hasSubscription + logger.log { + user, + hasSubscription, + fromPlansPage, + personalSubscription, + memberGroupSubscriptions, + managedGroupSubscriptions, + confirmedMemberInstitutions, + managedInstitutions, + managedPublishers, + v1SubscriptionStatus + }, "showing subscription dashboard" + plans = SubscriptionViewModelBuilder.buildViewModel() + data = { + title: "your_subscription" + plans, + user, + hasSubscription, + fromPlansPage, + personalSubscription, + memberGroupSubscriptions, + managedGroupSubscriptions, + confirmedMemberInstitutions, + managedInstitutions, + managedPublishers, + v1SubscriptionStatus + } + res.render "subscriptions/dashboard", data createSubscription: (req, res, next)-> user = AuthenticationController.getSessionUser(req) diff --git a/services/web/app/views/subscriptions/dashboard.pug b/services/web/app/views/subscriptions/dashboard.pug index d60074292b..bdcfcb3d69 100644 --- a/services/web/app/views/subscriptions/dashboard.pug +++ b/services/web/app/views/subscriptions/dashboard.pug @@ -7,29 +7,29 @@ block content .container .row .col-md-8.col-md-offset-2 + -if (fromPlansPage) + .alert.alert-warning + p You already have a subscription .card .page-header h1 #{translate("your_subscription")} - -var hasAnySubscription = false + -var hasDisplayedSubscription = false -if (personalSubscription) - -hasAnySubscription = true + -hasDisplayedSubscription = true include ./dashboard/_personal_subscription -if (managedGroupSubscriptions && managedGroupSubscriptions.length > 0) - -hasAnySubscription = true include ./dashboard/_managed_groups -if (managedInstitutions && managedInstitutions.length > 0) - -hasAnySubscription = true include ./dashboard/_managed_institutions -if (managedPublishers && managedPublishers.length > 0) - -hasAnySubscription = true include ./dashboard/_managed_publishers -if (memberGroupSubscriptions && memberGroupSubscriptions.length > 0) - -hasAnySubscription = true + -hasDisplayedSubscription = true include ./dashboard/_group_memberships -if (confirmedMemberInstitutions && confirmedMemberInstitutions.length > 0) @@ -38,7 +38,13 @@ block content -if (v1SubscriptionStatus) include ./dashboard/_v1_subscription_status - -if (!hasAnySubscription) + -if (hasSubscription && !hasDisplayedSubscription) + -hasDisplayedSubscription = true + p You're on an #{settings.appName} Paid plan. Contact + a(href="mailto:support@overleaf.com") support@overleaf.com + | to find out more. + + -if (!hasSubscription) p You're on the #{settings.appName} Free plan. | a(href="/user/subscription/plans").btn.btn-primary Upgrade now diff --git a/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug b/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug index 902cd3953f..b8aedc2ec7 100644 --- a/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug +++ b/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug @@ -1,6 +1,6 @@ each institution in confirmedMemberInstitutions if (institution.licence != 'free') - -hasAnySubscription = true + -hasDisplayedSubscription = true p | You have a | diff --git a/services/web/app/views/subscriptions/dashboard/_v1_subscription_status.pug b/services/web/app/views/subscriptions/dashboard/_v1_subscription_status.pug index 808c692e64..27b58dbe0e 100644 --- a/services/web/app/views/subscriptions/dashboard/_v1_subscription_status.pug +++ b/services/web/app/views/subscriptions/dashboard/_v1_subscription_status.pug @@ -1,5 +1,5 @@ - if (v1SubscriptionStatus['team'] && v1SubscriptionStatus['team']['default_plan_name'] != 'free') - - hasAnySubscription = true + - hasDisplayedSubscription = true p | You have a legacy group licence from Overleaf v1. - if (v1SubscriptionStatus['team']['will_end_at']) @@ -29,7 +29,7 @@ hr - if (v1SubscriptionStatus['product']) - - hasAnySubscription = true + - hasDisplayedSubscription = true p | You have a legacy Overleaf v1 |