Ghost/ghost/admin/lib/koenig-editor/addon/helpers/card-is-available.js
Kevin Ansfield 10f83ebd45 Added support for feature-gated editor cards
refs https://github.com/TryGhost/Team/issues/910

- added `card-is-available` helper that handles the previous `card.developerExperiment` and the new `card.feature` options
- updated `<KoenigMenuContent>` to use the `card-is-available` helper in the conditional when adding cards to the list

Cards can be gated by feature when specifying them in `cards.js`, in the card definition object you can add `feature: 'flagName'` which will mean the card is only available when that feature is enabled.
2021-07-20 10:48:41 +01:00

23 lines
565 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;
compute([card]) {
let cardIsAvailable = true;
if (card.developerExperiment) {
cardIsAvailable = this.config.get('enableDeveloperExperiments');
}
if (card.feature) {
cardIsAvailable = get(this.feature, card.feature);
}
return cardIsAvailable;
}
}