From aa35d99de4c47d7e3cba672bc3cce94c380148f7 Mon Sep 17 00:00:00 2001 From: Rishabh Garg Date: Thu, 17 Jun 2021 13:09:43 +0530 Subject: [PATCH] Add UI for complimentary products with multiple products feature (#2008) * Added v1 comped subscription handling * Cleanup * Added cancellation for existing subscriptions * Added loader for fetching products * Refined complimentary popup * Added default product selection * Updated add complimentary for multiple products * Updated products add comped button Co-authored-by: Peter Zimon --- .../components/gh-member-settings-form-cp.hbs | 39 ++++++-- .../components/gh-member-settings-form-cp.js | 5 + .../app/components/modal-member-product.hbs | 95 ++++++++----------- .../app/components/modal-member-product.js | 93 +++++++++--------- ghost/admin/app/styles/components/modals.css | 1 + ghost/admin/app/styles/layouts/members.css | 4 + ghost/admin/app/styles/patterns/forms.css | 21 +++- ghost/admin/public/assets/icons/check.svg | 1 + 8 files changed, 144 insertions(+), 115 deletions(-) create mode 100644 ghost/admin/public/assets/icons/check.svg diff --git a/ghost/admin/app/components/gh-member-settings-form-cp.hbs b/ghost/admin/app/components/gh-member-settings-form-cp.hbs index 592371a9cc..dd12711738 100644 --- a/ghost/admin/app/components/gh-member-settings-form-cp.hbs +++ b/ghost/admin/app/components/gh-member-settings-form-cp.hbs @@ -197,20 +197,39 @@ {{/each}} - {{#if this.isAddComplimentaryAllowed}} - + {{#if (not (feature "multipleProducts"))}} + {{#if this.isAddComplimentaryAllowed}} + + {{/if}} {{/if}} {{/each}} + {{#if (feature "multipleProducts")}} + {{#if (and this.products this.isAddComplimentaryAllowed)}} + + {{/if}} + {{/if}}
diff --git a/ghost/admin/app/components/gh-member-settings-form-cp.js b/ghost/admin/app/components/gh-member-settings-form-cp.js index 95e9eade46..48ee7c8dc9 100644 --- a/ghost/admin/app/components/gh-member-settings-form-cp.js +++ b/ghost/admin/app/components/gh-member-settings-form-cp.js @@ -15,6 +15,8 @@ export default class extends Component { ajax @service store + @service + feature constructor(...args) { super(...args); @@ -33,6 +35,9 @@ export default class extends Component { if (!this.membersUtils.isStripeEnabled) { return false; } + if (this.feature.get('multipleProducts')) { + return true; + } let subscriptions = this.member.get('subscriptions') || []; const hasZeroPriceSub = subscriptions.filter((sub) => { return ['active', 'trialing', 'unpaid', 'past_due'].includes(sub.status); diff --git a/ghost/admin/app/components/modal-member-product.hbs b/ghost/admin/app/components/modal-member-product.hbs index 7f0c4c8b3d..40bfffaf4e 100644 --- a/ghost/admin/app/components/modal-member-product.hbs +++ b/ghost/admin/app/components/modal-member-product.hbs @@ -1,72 +1,59 @@ -