mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
simpliyfied dashboard & fixed error with leave group shown to group owner
- always show the manage button if you are the group owne - only show the recurly subscription part if you are the subscription owner - always try and loop through groups you can leave
This commit is contained in:
parent
5ce0100371
commit
101e98ed83
4 changed files with 24 additions and 18 deletions
|
@ -43,7 +43,7 @@ module.exports =
|
|||
callback err, hasValidSubscription, subscription
|
||||
|
||||
userIsMemberOfGroupSubscription: (user, callback = (error, isMember, subscriptions) ->) ->
|
||||
logger.log user_id: user._ud, "checking is user is member of subscription groups"
|
||||
logger.log user_id: user._id, "checking is user is member of subscription groups"
|
||||
SubscriptionLocator.getMemberSubscriptions user._id, (err, subscriptions = []) ->
|
||||
return callback(err) if err?
|
||||
callback err, subscriptions.length > 0, subscriptions
|
||||
|
|
|
@ -82,9 +82,9 @@ module.exports = SubscriptionController =
|
|||
logger.log user: user, "redirecting to plans"
|
||||
res.redirect "/user/subscription/plans"
|
||||
else
|
||||
SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel user, (error, subscription, groups) ->
|
||||
SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel user, (error, subscription, groupSubscriptions) ->
|
||||
return next(error) if error?
|
||||
logger.log user: user, subscription:subscription, hasSubOrIsGroupMember:hasSubOrIsGroupMember, groups:groups, "showing subscription dashboard"
|
||||
logger.log user: user, subscription:subscription, hasSubOrIsGroupMember:hasSubOrIsGroupMember, groupSubscriptions:groupSubscriptions, "showing subscription dashboard"
|
||||
plans = SubscriptionViewModelBuilder.buildViewModel()
|
||||
res.render "subscriptions/dashboard",
|
||||
title: "your_subscription"
|
||||
|
@ -92,8 +92,9 @@ module.exports = SubscriptionController =
|
|||
taxRate:subscription?.taxRate
|
||||
plans: plans
|
||||
subscription: subscription || {}
|
||||
groups: groups
|
||||
groupSubscriptions: groupSubscriptions
|
||||
subscriptionTabActive: true
|
||||
user:user
|
||||
|
||||
|
||||
userCustomSubscriptionPage: (req, res, next)->
|
||||
|
|
|
@ -8,7 +8,7 @@ _ = require("underscore")
|
|||
|
||||
module.exports =
|
||||
|
||||
buildUsersSubscriptionViewModel: (user, callback = (error, subscription, groups) ->) ->
|
||||
buildUsersSubscriptionViewModel: (user, callback = (error, subscription, memberSubscriptions) ->) ->
|
||||
SubscriptionLocator.getUsersSubscription user, (err, subscription) ->
|
||||
return callback(err) if err?
|
||||
SubscriptionLocator.getMemberSubscriptions user, (err, memberSubscriptions = []) ->
|
||||
|
@ -19,6 +19,7 @@ module.exports =
|
|||
RecurlyWrapper.getSubscription subscription.recurlySubscription_id, (err, recurlySubscription)->
|
||||
tax = recurlySubscription?.tax_in_cents || 0
|
||||
callback null, {
|
||||
admin_id:subscription.admin_id
|
||||
name: plan.name
|
||||
nextPaymentDueAt: SubscriptionFormatters.formatDate(recurlySubscription?.current_period_ends_at)
|
||||
state: recurlySubscription?.state
|
||||
|
|
|
@ -43,12 +43,8 @@ block content
|
|||
.card(ng-if="view == 'overview'")
|
||||
.page-header
|
||||
h1 #{translate("your_subscription")}
|
||||
-if (groups.length != 0)
|
||||
each groupSubscription in groups
|
||||
p !{translate("member_of_group_subscription", {admin_email: "<strong>" + groupSubscription.admin_id.email + "</strong>"})}
|
||||
span
|
||||
button.btn.btn-danger(ng-click="removeSelfFromGroup('#{groupSubscription.admin_id._id}')") #{translate("leave_group")}
|
||||
- else if (subscription)
|
||||
|
||||
- if (subscription && user._id+'' == subscription.admin_id+'')
|
||||
case subscription.state
|
||||
when "free-trial"
|
||||
p !{translate("on_free_trial_expiring_at", {expiresAt:"<strong>" + subscription.expiresAt + "</strong>"})}
|
||||
|
@ -72,15 +68,9 @@ block content
|
|||
p !{translate("your_subscription_has_expired")}
|
||||
a(href="/user/subscription/plans") !{translate("create_new_subscription")}
|
||||
default
|
||||
-if(groups.length == 0)
|
||||
-if(groupSubscriptions.length == 0)
|
||||
p !{translate("problem_with_subscription_contact_us")}
|
||||
|
||||
-if(subscription.groupPlan)
|
||||
a(href="/subscription/group").btn.btn-primary !{translate("manage_group")}
|
||||
|
||||
|
||||
|
||||
|
||||
div(ng-show="changePlan", ng-cloak)#changePlanSection
|
||||
h2.col-md-7 !{translate("change_plan")}
|
||||
span.dropdown.col-md-1.changePlanButton(ng-controller="CurrenyDropdownController", style="display:none", dropdown)
|
||||
|
@ -105,6 +95,20 @@ block content
|
|||
mixin printPlans(plans.individualMonthlyPlans)
|
||||
mixin printPlans(plans.individualAnnualPlans)
|
||||
|
||||
|
||||
each groupSubscription in groupSubscriptions
|
||||
- if (user._id+'' != groupSubscription.admin_id._id+'')
|
||||
div
|
||||
p !{translate("member_of_group_subscription", {admin_email: "<strong>" + groupSubscription.admin_id.email + "</strong>"})}
|
||||
span
|
||||
button.btn.btn-danger(ng-click="removeSelfFromGroup('#{groupSubscription.admin_id._id}')") #{translate("leave_group")}
|
||||
|
||||
-if(subscription.groupPlan && user._id+'' == subscription.admin_id+'')
|
||||
div
|
||||
a(href="/subscription/group").btn.btn-primary !{translate("manage_group")}
|
||||
|
||||
|
||||
|
||||
.card(ng-if="view == 'cancelation'")
|
||||
.page-header
|
||||
h1 #{translate("Cancel Subscription")}
|
||||
|
|
Loading…
Reference in a new issue