mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
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.
This commit is contained in:
parent
6e540cf2ef
commit
10f83ebd45
@ -5,7 +5,7 @@
|
||||
{{section.title}}
|
||||
</div>
|
||||
{{#each section.items as |item|}}
|
||||
{{#if (or (not item.developerExperiment) (enable-developer-experiments))}}
|
||||
{{#if (card-is-available item)}}
|
||||
<div
|
||||
class="{{if (eq item @selectedItem) "kg-cardmenu-card-selected"}} {{kg-style "cardmenu-card"}}"
|
||||
data-kg="cardmenu-card"
|
||||
|
@ -0,0 +1,22 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
export {default} from 'koenig-editor/helpers/card-is-available';
|
Loading…
Reference in New Issue
Block a user