From 3a1bba07f7a1da33e84320028fe124a53dd539a3 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 20 Jun 2022 15:01:00 +0200 Subject: [PATCH] Merge pull request #8436 from overleaf/tm-update-wording-subscription-dashboard Update wording on subscription dashboard GitOrigin-RevId: 4739677fcf46e5de4db3e3fe2411f6ed9898aa2c --- .../SubscriptionViewModelBuilder.js | 38 +++++++++++++++++++ .../dashboard/_group_memberships.pug | 24 ++++++------ .../dashboard/_institution_memberships.pug | 9 +---- .../dashboard/_managed_groups.pug | 8 ++-- .../dashboard/_managed_institutions.pug | 7 +--- services/web/locales/en.json | 5 +++ 6 files changed, 61 insertions(+), 30 deletions(-) diff --git a/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.js b/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.js index 6683d74f00..308ca51c31 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.js +++ b/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.js @@ -296,11 +296,22 @@ function buildUsersSubscriptionViewModel(user, callback) { } for (const memberGroupSubscription of memberGroupSubscriptions) { + if (memberGroupSubscription.manager_ids?.includes(user._id)) { + memberGroupSubscription.userIsGroupManager = true + } if (memberGroupSubscription.teamNotice) { memberGroupSubscription.teamNotice = sanitizeHtml( memberGroupSubscription.teamNotice ) } + buildGroupSubscriptionForView(memberGroupSubscription) + } + + for (const managedGroupSubscription of managedGroupSubscriptions) { + if (managedGroupSubscription.member_ids?.includes(user._id)) { + managedGroupSubscription.userIsGroupMember = true + } + buildGroupSubscriptionForView(managedGroupSubscription) } callback(null, { @@ -459,6 +470,33 @@ function _getRemainingTrialDays(subscription) { : -1 } +function buildGroupSubscriptionForView(groupSubscription) { + // most group plans in Recurly should be in form "group_plancode_size_usage" + const planLevelFromGroupPlanCode = groupSubscription.planCode.substr(6, 12) + if (planLevelFromGroupPlanCode === 'professional') { + groupSubscription.planLevelName = 'Professional' + } else if (planLevelFromGroupPlanCode === 'collaborator') { + groupSubscription.planLevelName = 'Standard' + } + // there are some group subscription entries that have the personal plancodes... + // this fallback tries to still show the right thing in these cases: + if (!groupSubscription.planLevelName) { + if (groupSubscription.planCode.startsWith('professional')) { + groupSubscription.planLevelName = 'Professional' + } else if (groupSubscription.planCode.startsWith('collaborator')) { + groupSubscription.planLevelName = 'Standard' + } else { + // if we still don't have anything, we can show the plan name (eg, v1 Pro): + const plan = PlansLocator.findLocalPlanInSettings( + groupSubscription.planCode + ) + groupSubscription.planLevelName = plan + ? plan.name + : groupSubscription.planCode + } + } +} + module.exports = { buildUsersSubscriptionViewModel, buildPlansList, diff --git a/services/web/app/views/subscriptions/dashboard/_group_memberships.pug b/services/web/app/views/subscriptions/dashboard/_group_memberships.pug index 2c0e907e5e..f168486e12 100644 --- a/services/web/app/views/subscriptions/dashboard/_group_memberships.pug +++ b/services/web/app/views/subscriptions/dashboard/_group_memberships.pug @@ -1,18 +1,16 @@ div(ng-controller="GroupMembershipController") each groupSubscription in memberGroupSubscriptions - if (user._id+'' != groupSubscription.admin_id._id+'') - div - p - | You are a member of - | - +teamName(groupSubscription) - if (groupSubscription.teamNotice && groupSubscription.teamNotice != '') - p - //- Team notice is sanitized in SubscriptionViewModelBuilder - em(ng-non-bindable) !{groupSubscription.teamNotice} - span - button.btn.btn-danger.text-capitalise(ng-click="removeSelfFromGroup('"+groupSubscription._id+"')") #{translate("leave_group")} - hr + unless (groupSubscription.userIsGroupManager) + if (user._id+'' != groupSubscription.admin_id._id+'') + div + p !{translate("you_are_on_x_plan_as_member_of_group_subscription_y_administered_by_z", {planName: groupSubscription.planLevelName, groupName: groupSubscription.teamName || '', adminEmail: groupSubscription.admin_id.email}, [{name: 'a', attrs: {href: '/user/subscription/plans'}}, 'strong'])} + if (groupSubscription.teamNotice && groupSubscription.teamNotice != '') + p + //- Team notice is sanitized in SubscriptionViewModelBuilder + em(ng-non-bindable) !{groupSubscription.teamNotice} + span + button.btn.btn-danger.text-capitalise(ng-click="removeSelfFromGroup('"+groupSubscription._id+"')") #{translate("leave_group")} + hr script(type='text/ng-template', id='LeaveGroupModalTemplate') .modal-header diff --git a/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug b/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug index ea627edc0f..b47d5e796b 100644 --- a/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug +++ b/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug @@ -4,12 +4,5 @@ if currentInstitutionsWithLicence === false else each institution in currentInstitutionsWithLicence -hasDisplayedSubscription = true - p - | You have a - | - strong(ng-non-bindable) Professional - | - | #{settings.appName} account as a confirmed member of - | - strong(ng-non-bindable)= institution.name + p !{translate("you_are_on_x_plan_as_a_confirmed_member_of_institution_y", {planName: 'Professional', institutionName: institution.name || ''}, [{name: 'a', attrs: {href: '/user/subscription/plans'}}, 'strong'])} hr diff --git a/services/web/app/views/subscriptions/dashboard/_managed_groups.pug b/services/web/app/views/subscriptions/dashboard/_managed_groups.pug index fd7c354db7..5bd63f3bf5 100644 --- a/services/web/app/views/subscriptions/dashboard/_managed_groups.pug +++ b/services/web/app/views/subscriptions/dashboard/_managed_groups.pug @@ -1,8 +1,8 @@ each managedGroupSubscription in managedGroupSubscriptions - p - | You are a manager of - | - +teamName(managedGroupSubscription) + if (managedGroupSubscription.userIsGroupMember) + p !{translate("you_are_a_manager_and_member_of_x_plan_as_member_of_group_subscription_y_administered_by_z", {planName: managedGroupSubscription.planLevelName, groupName: managedGroupSubscription.teamName || '', adminEmail: managedGroupSubscription.admin_id.email}, [{name: 'a', attrs: {href: '/user/subscription/plans'}}, 'strong'])} + else + p !{translate("you_are_a_manager_of_x_plan_as_member_of_group_subscription_y_administered_by_z", {planName: managedGroupSubscription.planLevelName, groupName: managedGroupSubscription.teamName || '', adminEmail: managedGroupSubscription.admin_id.email}, [{name: 'a', attrs: {href: '/user/subscription/plans'}}, 'strong'])} p a.btn.btn-primary(href="/manage/groups/" + managedGroupSubscription._id + "/members") i.fa.fa-fw.fa-users diff --git a/services/web/app/views/subscriptions/dashboard/_managed_institutions.pug b/services/web/app/views/subscriptions/dashboard/_managed_institutions.pug index ad868d2664..1844cf68fc 100644 --- a/services/web/app/views/subscriptions/dashboard/_managed_institutions.pug +++ b/services/web/app/views/subscriptions/dashboard/_managed_institutions.pug @@ -1,8 +1,5 @@ each institution in managedInstitutions - p - | You are a manager of - | - strong(ng-non-bindable)= institution.name + p !{translate("you_are_a_manager_of_commons_at_institution_x", {institutionName: institution.name || ''}, ['strong'])} p a.btn.btn-primary(href="/metrics/institutions/" + institution.v1Id) i.fa.fa-fw.fa-line-chart @@ -20,7 +17,7 @@ each institution in managedInstitutions | Manage institution managers div(ng-controller="MetricsEmailController", ng-cloak) p - span Monthly metrics emails: + span Monthly metrics emails:  a(href ng-bind-html="institutionEmailSubscription('"+institution.v1Id+"')" ng-show="!subscriptionChanging" ng-click="changeInstitutionalEmailSubscription('"+institution.v1Id+"')") span(ng-show="subscriptionChanging") i.fa.fa-spin.fa-refresh(aria-hidden="true") diff --git a/services/web/locales/en.json b/services/web/locales/en.json index 530b5e5630..5388f56f3d 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -1279,6 +1279,11 @@ "please_see_help_for_more_info": "Please see our help guide for more information", "this_project_will_appear_in_your_dropbox_folder_at": "This project will appear in your Dropbox folder at ", "member_of_group_subscription": "You are a member of a group subscription managed by __admin_email__. Please contact them to manage your subscription.\n", + "you_are_on_x_plan_as_member_of_group_subscription_y_administered_by_z": "You are on our <0>__planName__ plan as a <1>member of the group subscription <1>__groupName__ administered by <1>__adminEmail__", + "you_are_a_manager_of_x_plan_as_member_of_group_subscription_y_administered_by_z": "You are a <1>manager of the <0>__planName__ group subscription <1>__groupName__ administered by <1>__adminEmail__", + "you_are_a_manager_and_member_of_x_plan_as_member_of_group_subscription_y_administered_by_z": "You are a <1>manager and <1>member of the <0>__planName__ group subscription <1>__groupName__ administered by <1>__adminEmail__", + "you_are_on_x_plan_as_a_confirmed_member_of_institution_y": "You are on our <0>__planName__ plan as a <1>confirmed member of <1>__institutionName__", + "you_are_a_manager_of_commons_at_institution_x": "You are a <0>manager of the Overleaf Commons subscription at <0>__institutionName__", "about_henry_oswald": "is a software engineer living in London. He built the original prototype of __appName__ and has been responsible for building a stable and scalable platform. Henry is a strong advocate of Test Driven Development and makes sure we keep the __appName__ code clean and easy to maintain.", "about_james_allen": "has a PhD in theoretical physics and is passionate about LaTeX. He created one of the first online LaTeX editors, ScribTeX, and has played a large role in developing the technologies that make __appName__ possible.", "two_strong_principles_behind_sl": "There are two strong driving principles behind our work on __appName__:",