diff --git a/ghost/admin/app/components/gh-members-recipient-select.js b/ghost/admin/app/components/gh-members-recipient-select.js index f854e4727c..53b8216bd5 100644 --- a/ghost/admin/app/components/gh-members-recipient-select.js +++ b/ghost/admin/app/components/gh-members-recipient-select.js @@ -13,6 +13,7 @@ export default class GhMembersRecipientSelect extends Component { @service membersUtils; @service session; @service store; + @service feature; baseFilters = new TrackedSet(); specificFilters = new TrackedSet(); @@ -144,6 +145,29 @@ export default class GhMembersRecipientSelect extends Component { options.push(labelsGroup); } + if (this.feature.get('multipleProducts')) { + // fetch all products w̶i̶t̶h̶ c̶o̶u̶n̶t̶s̶ + // TODO: add `include: 'count.members` to query once API supports + const products = yield this.store.query('product', {limit: 'all'}); + + if (products.length > 1) { + const productsGroup = { + groupName: 'Products', + options: [] + }; + + products.forEach((product) => { + productsGroup.options.push({ + name: product.name, + segment: `product:${product.slug}`, + count: product.count?.members, + class: 'segment-product' + }); + }); + + options.push(productsGroup); + } + } this.specificOptions = options; } diff --git a/ghost/admin/app/components/gh-members-segment-select.js b/ghost/admin/app/components/gh-members-segment-select.js index 9c9aae9548..bacdeb4185 100644 --- a/ghost/admin/app/components/gh-members-segment-select.js +++ b/ghost/admin/app/components/gh-members-segment-select.js @@ -6,6 +6,7 @@ import {tracked} from '@glimmer/tracking'; export default class GhMembersSegmentSelect extends Component { @service store; + @service feature; @tracked _options = []; @@ -89,27 +90,28 @@ export default class GhMembersSegmentSelect extends Component { options.push(labelsGroup); } + if (this.feature.get('multipleProducts')) { + // fetch all products w̶i̶t̶h̶ c̶o̶u̶n̶t̶s̶ + // TODO: add `include: 'count.members` to query once API supports + const products = yield this.store.query('product', {limit: 'all'}); - // fetch all products w̶i̶t̶h̶ c̶o̶u̶n̶t̶s̶ - // TODO: add `include: 'count.members` to query once API supports - const products = yield this.store.query('product', {limit: 'all'}); + if (products.length > 0) { + const productsGroup = { + groupName: 'Products', + options: [] + }; - if (products.length > 0) { - const productsGroup = { - groupName: 'Products', - options: [] - }; - - products.forEach((product) => { - productsGroup.options.push({ - name: product.name, - segment: `product:${product.slug}`, - count: product.count?.members, - class: 'segment-product' + products.forEach((product) => { + productsGroup.options.push({ + name: product.name, + segment: `product:${product.slug}`, + count: product.count?.members, + class: 'segment-product' + }); }); - }); - options.push(productsGroup); + options.push(productsGroup); + } } this._options = options;