2021-07-20 12:48:12 +03:00
|
|
|
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;
|
2021-11-15 19:38:57 +03:00
|
|
|
@service settings;
|
2021-07-20 12:48:12 +03:00
|
|
|
|
2021-09-10 11:24:38 +03:00
|
|
|
compute([card], {postType} = {}) {
|
2021-07-20 12:48:12 +03:00
|
|
|
let cardIsAvailable = true;
|
|
|
|
|
2021-11-15 19:38:57 +03:00
|
|
|
if (typeof card.isAvailable === 'string') {
|
|
|
|
cardIsAvailable = get(this, card.isAvailable);
|
|
|
|
}
|
|
|
|
|
2021-07-20 12:48:12 +03:00
|
|
|
if (card.developerExperiment) {
|
2021-11-15 19:38:57 +03:00
|
|
|
cardIsAvailable = cardIsAvailable && this.config.get('enableDeveloperExperiments');
|
2021-07-20 12:48:12 +03:00
|
|
|
}
|
|
|
|
|
2021-09-10 11:24:38 +03:00
|
|
|
if (postType && card.postType) {
|
2021-11-15 19:38:57 +03:00
|
|
|
cardIsAvailable = cardIsAvailable && card.postType === postType;
|
2021-09-10 11:24:38 +03:00
|
|
|
}
|
|
|
|
|
2021-07-20 12:48:12 +03:00
|
|
|
return cardIsAvailable;
|
|
|
|
}
|
|
|
|
}
|