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