Merge pull request #3897 from overleaf/tm-meta-tags-billing

[views] migrate subscription templates to meta tags, re-issue

GitOrigin-RevId: c18bb7c96186cc8c34344ecf7cee35f9da19698e
This commit is contained in:
Jakob Ackermann 2021-04-15 16:23:12 +02:00 committed by Copybot
parent b276587c42
commit d2e6449e79
10 changed files with 39 additions and 38 deletions

View file

@ -7,6 +7,10 @@ block head-scripts
block append meta
meta(name="ol-managedInstitutions", data-type="json", content=managedInstitutions)
if (personalSubscription && personalSubscription.recurly)
meta(name="ol-recurlyApiKey" content=settings.apis.recurly.publicKey)
meta(name="ol-subscription" data-type="json" content=personalSubscription)
meta(name="ol-recomendedCurrency" content=personalSubscription.recurly.currency)
block content
main.content.content-alt(ng-cloak)

View file

@ -1,8 +1,3 @@
script(type="text/javascript", nonce=scriptNonce).
window.recurlyApiKey = "!{settings.apis.recurly.publicKey}"
window.subscription = !{StringHelper.stringifyJsonForScript(personalSubscription)}
window.recomendedCurrency = "#{personalSubscription.recurly.currency}"
div(ng-controller="RecurlySubscriptionController")
div(ng-show="!showCancellation")
if (personalSubscription.recurly.account.has_past_due_invoice && personalSubscription.recurly.account.has_past_due_invoice._ == 'true')

View file

@ -1,11 +1,12 @@
extends ../layout
block append meta
meta(name="ol-countryCode" content=countryCode)
meta(name="ol-recurlyApiKey" content=settings.apis.recurly.publicKey)
meta(name="ol-recomendedCurrency" content=String(currency).slice(0,3))
block head-scripts
script(type="text/javascript", nonce=scriptNonce, src="https://js.recurly.com/v4/recurly.js")
script(type="text/javascript", nonce=scriptNonce).
window.countryCode = !{StringHelper.stringifyJsonForScript(countryCode || '')}
window.recurlyApiKey = "!{settings.apis.recurly.publicKey}"
window.recomendedCurrency = !{StringHelper.stringifyJsonForScript(String(currency).slice(0,3))}
block content
main.content.content-alt

View file

@ -6,11 +6,9 @@ include _plans_page_tables
block vars
- metadata = { viewport: true }
block head-scripts
script(type="text/javascript", nonce=scriptNonce).
window.recomendedCurrency = '#{recomendedCurrency}';
window.abCurrencyFlag = '#{abCurrencyFlag}';
window.groupPlans = !{StringHelper.stringifyJsonForScript(groupPlans)};
block append meta
meta(name="ol-recomendedCurrency" content=recomendedCurrency)
meta(name="ol-groupPlans" data-type="json" content=groupPlans)
block content
.content.content-alt

View file

@ -28,9 +28,3 @@ block content
| The #{settings.appName} Team
p
a.btn.btn-primary(href="/project") < #{translate("back_to_your_projects")}
script(type="text/javascript", nonce=scriptNonce).
window.ab = [
{step:1, bucket:"student_control", testName:"editor_plan"},
{step:1, bucket:"collab_test", testName:"editor_plan"},
]

View file

@ -1,10 +1,8 @@
extends ../../layout
block head-scripts
script(type="text/javascript", nonce=scriptNonce).
window.teamId = '#{teamId}'
window.hasIndividualRecurlySubscription = #{hasIndividualRecurlySubscription}
window.inviteToken = '#{inviteToken}'
block append meta
meta(name="ol-hasIndividualRecurlySubscription" data-type="boolean" content=hasIndividualRecurlySubscription)
meta(name="ol-inviteToken" content=inviteToken)
block content
main.content.content-alt.team-invite

View file

@ -6,6 +6,7 @@ import _ from 'lodash'
*/
/* global recurly */
import App from '../base'
import getMeta from '../utils/meta'
export default App.controller(
'NewSubscriptionController',
@ -63,7 +64,7 @@ export default App.controller(
city: '',
company: '',
vat_number: '',
country: window.countryCode,
country: getMeta('ol-countryCode'),
coupon: window.couponCode
}
@ -80,7 +81,7 @@ export default App.controller(
)
recurly.configure({
publicKey: window.recurlyApiKey,
publicKey: getMeta('ol-recurlyApiKey'),
style: {
all: {
fontFamily: '"Open Sans", sans-serif',

View file

@ -3,8 +3,9 @@
max-len
*/
import App from '../base'
import getMeta from '../utils/meta'
App.factory('MultiCurrencyPricing', function () {
const currencyCode = window.recomendedCurrency
const currencyCode = getMeta('ol-recomendedCurrency')
return {
currencyCode,
@ -384,11 +385,12 @@ App.controller(
]
}
$scope.prices = window.groupPlans
$scope.prices = getMeta('ol-groupPlans')
let currency = 'USD'
if (['USD', 'GBP', 'EUR'].includes(window.recomendedCurrency)) {
currency = window.recomendedCurrency
const recomendedCurrency = getMeta('ol-recomendedCurrency')
if (['USD', 'GBP', 'EUR'].includes(recomendedCurrency)) {
currency = recomendedCurrency
}
// default selected

View file

@ -18,13 +18,14 @@ import _ from 'lodash'
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../base'
import getMeta from '../utils/meta'
const SUBSCRIPTION_URL = '/user/subscription/update'
const ensureRecurlyIsSetup = _.once(() => {
if (typeof recurly === 'undefined' || !recurly) {
return false
}
recurly.configure(window.recurlyApiKey)
recurly.configure(getMeta('ol-recurlyApiKey'))
return true
})
@ -105,7 +106,8 @@ App.controller(
$scope.$watch('plan', function (plan) {
if (!plan) return
const planCode = plan.planCode
const { currency, taxRate } = window.subscription.recurly
const subscription = getMeta('ol-subscription')
const { currency, taxRate } = subscription.recurly
$scope.price = '...' // Placeholder while we talk to recurly
RecurlyPricing.loadDisplayPriceWithTax(planCode, currency, taxRate).then(
price => {
@ -171,7 +173,8 @@ App.controller('GroupMembershipController', function ($scope, $modal) {
App.controller('RecurlySubscriptionController', function ($scope) {
const recurlyIsSetup = ensureRecurlyIsSetup()
$scope.showChangePlanButton = recurlyIsSetup && !window.subscription.groupPlan
const subscription = getMeta('ol-subscription')
$scope.showChangePlanButton = recurlyIsSetup && !subscription.groupPlan
if (
window.subscription.recurly.account.has_past_due_invoice &&
window.subscription.recurly.account.has_past_due_invoice._ === 'true'
@ -201,7 +204,7 @@ App.controller(
'RecurlyCancellationController',
function ($scope, RecurlyPricing, $http) {
if (!ensureRecurlyIsSetup()) return
const subscription = window.subscription
const subscription = getMeta('ol-subscription')
const sevenDaysTime = new Date()
sevenDaysTime.setDate(sevenDaysTime.getDate() + 7)
const freeTrialEndDate = new Date(subscription.recurly.trial_ends_at)
@ -222,7 +225,7 @@ App.controller(
$scope.showBasicCancel = true
}
const { currency, taxRate } = window.subscription.recurly
const { currency, taxRate } = subscription.recurly
$scope.studentPrice = '...' // Placeholder while we talk to recurly
RecurlyPricing.loadDisplayPriceWithTax('student', currency, taxRate).then(
price => {

View file

@ -10,11 +10,15 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../base'
import getMeta from '../../utils/meta'
export default App.controller('TeamInviteController', function ($scope, $http) {
$scope.inflight = false
const hasIndividualRecurlySubscription = getMeta(
'ol-hasIndividualRecurlySubscription'
)
if (window.hasIndividualRecurlySubscription) {
if (hasIndividualRecurlySubscription) {
$scope.view = 'hasIndividualRecurlySubscription'
} else {
$scope.view = 'teamInvite'
@ -40,7 +44,8 @@ export default App.controller('TeamInviteController', function ($scope, $http) {
return ($scope.joinTeam = function () {
$scope.inflight = true
const request = $http.put(`/subscription/invites/${window.inviteToken}/`, {
const inviteToken = getMeta('ol-inviteToken')
const request = $http.put(`/subscription/invites/${inviteToken}/`, {
_csrf: window.csrfToken
})
request.then(function (response) {