mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
cdf0565d3b
refs https://github.com/TryGhost/Team/issues/1220 - added array support to `{{card-is-available}}` helper where every key needs to be present for the card to be available - changed gifs card `isAvailable` property to require both the feature flag and the tenor api key to be set in config
35 lines
982 B
JavaScript
35 lines
982 B
JavaScript
import Helper from '@ember/component/helper';
|
|
import {get} from '@ember/object';
|
|
import {isArray} from '@ember/array';
|
|
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 (isArray(card.isAvailable)) {
|
|
cardIsAvailable = card.isAvailable.every((key) => {
|
|
return get(this, key);
|
|
});
|
|
}
|
|
|
|
if (card.developerExperiment) {
|
|
cardIsAvailable = cardIsAvailable && this.config.get('enableDeveloperExperiments');
|
|
}
|
|
|
|
if (postType && card.postType) {
|
|
cardIsAvailable = cardIsAvailable && card.postType === postType;
|
|
}
|
|
|
|
return cardIsAvailable;
|
|
}
|
|
}
|