diff --git a/src/common/catalog-entity.ts b/src/common/catalog-entity.ts index 8a00297d3c..e32e7149ef 100644 --- a/src/common/catalog-entity.ts +++ b/src/common/catalog-entity.ts @@ -45,6 +45,7 @@ export interface CatalogEntityActionContext { export type CatalogEntityContextMenu = { icon: string; title: string; + onlyVisibleForSource?: string; // show only if empty or if matches with entity source onClick: () => Promise; confirm?: { message: string; diff --git a/src/renderer/components/+catalog/catalog.tsx b/src/renderer/components/+catalog/catalog.tsx index 1a1d02f587..bbd2f1d29e 100644 --- a/src/renderer/components/+catalog/catalog.tsx +++ b/src/renderer/components/+catalog/catalog.tsx @@ -124,6 +124,7 @@ export class Catalog extends React.Component { @autobind() renderItemMenu(item: CatalogEntityItem) { + const menuItems = this.contextMenu.menuItems.filter((menuItem) => !menuItem.onlyVisibleForSource || menuItem.onlyVisibleForSource === item.entity.metadata.source); const onOpen = async () => { await item.onContextMenuOpen(this.contextMenu); }; @@ -136,7 +137,7 @@ export class Catalog extends React.Component { this.removeFromHotbar(item) }> Remove from Hotbar - { this.contextMenu.menuItems.map((menuItem, index) => { + { menuItems.map((menuItem, index) => { return ( this.onMenuItemClick(menuItem)}> {menuItem.title} diff --git a/src/renderer/components/hotbar/hotbar-icon.tsx b/src/renderer/components/hotbar/hotbar-icon.tsx index 201bc2df02..29902bc6a0 100644 --- a/src/renderer/components/hotbar/hotbar-icon.tsx +++ b/src/renderer/components/hotbar/hotbar-icon.tsx @@ -100,6 +100,7 @@ export class HotbarIcon extends React.Component { await entity.onContextMenuOpen(this.contextMenu); this.toggleMenu(); }; + const menuItems = this.contextMenu?.menuItems.filter((menuItem) => !menuItem.onlyVisibleForSource || menuItem.onlyVisibleForSource === entity.metadata.source); return (
@@ -117,7 +118,7 @@ export class HotbarIcon extends React.Component { this.removeFromHotbar(entity) }> Remove from Hotbar - { this.contextMenu && this.contextMenu.menuItems.map((menuItem) => { + { this.contextMenu && menuItems.map((menuItem) => { return ( this.onMenuItemClick(menuItem) }> {menuItem.title}