mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
5268ad1f77
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
28 lines
773 B
JavaScript
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;
|
|
}
|
|
}
|