Ghost/ghost/admin/app/components/gh-product-card.js
Kevin Ansfield 4b646d40ea Added non-Stripe members setting screen acceptance tests
refs https://github.com/TryGhost/Team/issues/1358

- added acceptance tests for members settings screen
  - subscription access management
  - default post access management
  - free tier management
- fixed `enableLabsFlag()` test helper overwriting existing flag settings when enabling another one
- updated API mocks and fixtures
  - matched product fixtures to default tiers-enabled products
  - updated product API mocks to include benefit handling
2022-02-18 22:36:01 +00:00

53 lines
1.3 KiB
JavaScript

import Component from '@glimmer/component';
import {action} from '@ember/object';
import {getSymbol} from 'ghost-admin/utils/currency';
import {inject as service} from '@ember/service';
import {tracked} from '@glimmer/tracking';
export default class extends Component {
@service membersUtils;
@service ghostPaths;
@service ajax;
@service store;
@service config;
@tracked showProductModal = false;
get product() {
return this.args.product;
}
get showArchiveOption() {
return this.product.type === 'paid' && !!this.product.monthlyPrice;
}
get productCurrency() {
if (this.isFreeProduct) {
const firstPaidProduct = this.args.products.find((product) => {
return product.type === 'paid';
});
return firstPaidProduct?.monthlyPrice?.currency || 'usd';
} else {
return this.product?.monthlyPrice?.currency;
}
}
get isPaidProduct() {
return this.product.type === 'paid';
}
get hasCurrencySymbol() {
const currencySymbol = getSymbol(this.product?.monthlyPrice?.currency);
return currencySymbol?.length !== 3;
}
get isFreeProduct() {
return this.product.type === 'free';
}
@action
async openEditProduct(product) {
this.args.openEditProduct(product);
}
}