Ghost/ghost/admin/lib/koenig-editor/addon/helpers/card-is-available.js
Kevin Ansfield 5268ad1f77 Swapped feature card setting for isAvailable
no issue

- the number of properties that cards have in their definition was growing so it made sense to drop the single-use `feature` property in favor of the `isAvailable` property that can perform the same functionality
2021-11-15 16:43:44 +00:00

28 lines
773 B
JavaScript

import Helper from '@ember/component/helper';
import {get} from '@ember/object';
import {inject as service} from '@ember/service';
export default class CardIsAvailableHelper extends Helper {
@service config;
@service feature;
@service settings;
compute([card], {postType} = {}) {
let cardIsAvailable = true;
if (typeof card.isAvailable === 'string') {
cardIsAvailable = get(this, card.isAvailable);
}
if (card.developerExperiment) {
cardIsAvailable = cardIsAvailable && this.config.get('enableDeveloperExperiments');
}
if (postType && card.postType) {
cardIsAvailable = cardIsAvailable && card.postType === postType;
}
return cardIsAvailable;
}
}