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 block append meta
meta(name="ol-managedInstitutions", data-type="json", content=managedInstitutions) 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 block content
main.content.content-alt(ng-cloak) 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-controller="RecurlySubscriptionController")
div(ng-show="!showCancellation") div(ng-show="!showCancellation")
if (personalSubscription.recurly.account.has_past_due_invoice && personalSubscription.recurly.account.has_past_due_invoice._ == 'true') if (personalSubscription.recurly.account.has_past_due_invoice && personalSubscription.recurly.account.has_past_due_invoice._ == 'true')

View file

@ -1,11 +1,12 @@
extends ../layout 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 block head-scripts
script(type="text/javascript", nonce=scriptNonce, src="https://js.recurly.com/v4/recurly.js") 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 block content
main.content.content-alt main.content.content-alt

View file

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

View file

@ -28,9 +28,3 @@ block content
| The #{settings.appName} Team | The #{settings.appName} Team
p p
a.btn.btn-primary(href="/project") < #{translate("back_to_your_projects")} 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 extends ../../layout
block head-scripts block append meta
script(type="text/javascript", nonce=scriptNonce). meta(name="ol-hasIndividualRecurlySubscription" data-type="boolean" content=hasIndividualRecurlySubscription)
window.teamId = '#{teamId}' meta(name="ol-inviteToken" content=inviteToken)
window.hasIndividualRecurlySubscription = #{hasIndividualRecurlySubscription}
window.inviteToken = '#{inviteToken}'
block content block content
main.content.content-alt.team-invite main.content.content-alt.team-invite

View file

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

View file

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

View file

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

View file

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