Added support for the active flag to Products API

refs https://github.com/TryGhost/Team/issues/1252

This will be used to archive and unarchive Tiers. There is a restriction
on archiving "free" Tiers because our current system expects only one,
and it should always be active.
This commit is contained in:
Fabien "egg" O'Carroll 2022-01-19 14:27:45 +02:00
parent 233bb828fa
commit c59a42c87b

View File

@ -134,6 +134,7 @@ class ProductRepository {
const productData = { const productData = {
type: 'paid', type: 'paid',
active: true,
name: data.name, name: data.name,
description: data.description, description: data.description,
benefits: data.benefits benefits: data.benefits
@ -277,8 +278,13 @@ class ProductRepository {
benefits: data.benefits benefits: data.benefits
}; };
if (Reflect.has(data, 'active')) {
productData.active = data.active;
}
if (existingProduct.get('type') === 'free') { if (existingProduct.get('type') === 'free') {
delete productData.name; delete productData.name;
delete productData.active;
} }
let product = await this._Product.edit(productData, { let product = await this._Product.edit(productData, {