mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
7e98f1b9f4
no issue Using the slash menu it was possible to insert cards that shouldn't have been accessible based on their availability checks. This was happening because we were only hiding the visibility of the cards in the template rather than completely removing them from the slash command matching logic. - added `{{card-menu-items}}` helper that combines the availability matching and snippet section addition to return a complete array of sections+items that match the current system state and post type - added `@menuItems` argument set to the output of `{{card-menu-items}}` to the two card menu components so they are working against a pre-filtered list of menu items - lets us remove duplication of code that handled pushing snippets section into the menus - removed availability check conditionals from `<KoenigMenuContent>` as the menu items passed in are now pre-filtered
27 lines
1.4 KiB
Handlebars
27 lines
1.4 KiB
Handlebars
{{#each @itemSections as |section sectionIndex|}}
|
|
{{#if section.items}}
|
|
<div class="flex flex-column justify-center flex-shrink-0 {{unless (eq sectionIndex 0) "mt3 bt b--whitegrey"}} mb2 pl4 pr4 pt3 midlightgrey ttu f-supersmall fw5 tracked-3" style="min-width: calc(100% - 3.2rem);">
|
|
{{section.title}}
|
|
</div>
|
|
{{#each section.items as |item|}}
|
|
<div
|
|
class="{{if (eq item @selectedItem) "kg-cardmenu-card-selected"}} {{kg-style "cardmenu-card"}}"
|
|
data-kg="cardmenu-card"
|
|
role="menuitem"
|
|
title="{{item.label}}"
|
|
{{on "click" (fn @itemClicked item)}}
|
|
{{did-update this.scrollIntoView (eq item @selectedItem)}}
|
|
>
|
|
<div class="{{kg-style "cardmenu-icon"}} {{item.iconClass}}" aria-hidden="true">{{svg-jar item.icon class="w7 h7"}}</div>
|
|
<div class="{{kg-style "cardmenu-text"}}">
|
|
<div class="{{kg-style "cardmenu-label"}}">{{item.label}}</div>
|
|
<div class="{{kg-style "cardmenu-desc"}}">{{item.desc}}</div>
|
|
</div>
|
|
{{#if item.deleteClicked}}
|
|
<span class="kg-cardmenu-action-icon red" {{on "click" item.deleteClicked}}>{{svg-jar "trash"}}</span>
|
|
{{/if}}
|
|
</div>
|
|
{{/each}}
|
|
{{/if}}
|
|
{{/each}}
|