Browse Source

Merge pull request #8436 from overleaf/tm-update-wording-subscription-dashboard

Update wording on subscription dashboard

GitOrigin-RevId: 4739677fcf46e5de4db3e3fe2411f6ed9898aa2c
Thomas 4 years ago
parent
commit
3a1bba07f7

+ 38 - 0
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,

+ 11 - 13
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

+ 1 - 8
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

+ 4 - 4
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

+ 2 - 5
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")

+ 5 - 0
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__</0> plan as a <1>member</1> of the group subscription <1>__groupName__</1> administered by <1>__adminEmail__</1>",
+  "you_are_a_manager_of_x_plan_as_member_of_group_subscription_y_administered_by_z": "You are a <1>manager</1> of the <0>__planName__</0> group subscription <1>__groupName__</1> administered by <1>__adminEmail__</1>",
+  "you_are_a_manager_and_member_of_x_plan_as_member_of_group_subscription_y_administered_by_z": "You are a <1>manager</1> and <1>member</1> of the <0>__planName__</0> group subscription <1>__groupName__</1> administered by <1>__adminEmail__</1>",
+  "you_are_on_x_plan_as_a_confirmed_member_of_institution_y": "You are on our <0>__planName__</0> plan as a <1>confirmed member</1> of <1>__institutionName__</1>",
+  "you_are_a_manager_of_commons_at_institution_x": "You are a <0>manager</0> of the Overleaf Commons subscription at <0>__institutionName__</0>",
   "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__:",